Skip to content

GetSchema("DataType") is not compatible with Azure SQL Edge #2086

Closed

Description

@MaceWindu

Describe the bug

GetSchema('DataType") loads UDT types using CLR features of SQL Server, not supported on Azure SQL Edge leading to exception from server.

You can see that addUDTsToDataTypesTable method checks only SQL Server version here.

Unhandled exception: Common Language Runtime(CLR) is not enabled on this instance.
   at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at Microsoft.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows)
   at Microsoft.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more)
   at Microsoft.Data.SqlClient.SqlDataReader.Read()
   at Microsoft.Data.SqlClient.SqlMetaDataFactory.addUDTsToDataTypesTable(DataTable dataTypesTable, SqlConnection connection, String ServerVersion)
   at Microsoft.Data.SqlClient.SqlMetaDataFactory.GetDataTypesTable(SqlConnection connection)
   at Microsoft.Data.SqlClient.SqlMetaDataFactory.PrepareCollection(String collectionName, String[] restrictions, DbConnection connection)
   at Microsoft.Data.ProviderBase.DbMetaDataFactory.GetSchema(DbConnection connection, String collectionName, String[] restrictions)
   at Microsoft.Data.ProviderBase.DbConnectionInternal.GetSchema(DbConnectionFactory factory, DbConnectionPoolGroup poolGroup, DbConnection outerConnection, String collectionName, String[] restrictions)
   at Microsoft.Data.SqlClient.SqlConnection.GetSchema(String collectionName, String[] restrictionValues)
   at Microsoft.Data.SqlClient.SqlConnection.GetSchema(String collectionName)

To reproduce

connection.GetSchema("DataType")

Expected behavior

API doesn't try to access unsupported by server functionality.

Further technical details

Microsoft.Data.SqlClient version: 5.1.1

Additional context

Azure Edge unsupported features

Original issue : linq2db/linq2db#4195

Activity

  1. changed the title [-]GetSchema("DataTypes") is not compatible with Azure SQL Edge[/-] [+]GetSchema("DataType") is not compatible with Azure SQL Edge[/+] on Jul 7, 2023
  2. Kaur-Parminder commented on Jul 8, 2023

    @Kaur-Parminder
    Contributor

    @MaceWindu I will look into it and report back.

  3. ErikEJ commented on Jul 8, 2023

    @ErikEJ
    Contributor

    @MaceWindu Does it work with Azure SQL database or is it same issue?

  4. MaceWindu commented on Jul 8, 2023

    @MaceWindu
    ContributorAuthor

    @ErikEJ , Azure SQL has own limitations, but this part works fine.

    For Azure SQL we personally skip read of objects description from missing view sys.extended_properties, but it looks like SqlClient doesn't use it for schema API

  5. added a commit that references this issue on Jul 23, 2023
    e5380f2
  6. added a commit that references this issue on Aug 15, 2023
    80905bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions