Uploaded image for project: 'MariaDB Connector/ODBC'
  1. MariaDB Connector/ODBC
  2. ODBC-423

SQL batch with PREPARE/EXECUTE statements via .NET gives AccessViolationException

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Done
    • 3.1.20
    • 3.2.2
    • General
    • None
    • Windows .net 4.8

    Description

      When I try to execute from .NET via ODBC multistatement with PREPARE and EXECUTE, it ends with exception like:

      System.AccessViolationException : Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
         at System.Data.Common.UnsafeNativeMethods.SQLMoreResults(OdbcStatementHandle StatementHandle)
         at System.Data.Odbc.OdbcStatementHandle.MoreResults()
         at System.Data.Odbc.OdbcDataReader.NextResult(Boolean disposing, Boolean allresults)
         at System.Data.Odbc.OdbcDataReader.Close(Boolean disposing)
         at System.Data.Odbc.OdbcDataReader.Dispose(Boolean disposing)
         at System.Data.Common.DbDataReader.Dispose()
         at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
         at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
         at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
         at System.Data.Odbc.OdbcCommand.ExecuteReader()
      

      Example of query we executed:

      SELECT COUNT(*) FROM information_schema.tables
      WHERE TABLE_SCHEMA='information_schema' AND TABLE_NAME='TABLESPACES'
      INTO @tableExists;
       
      SELECT 
      	IF(@tableExists>0 
      	,'SELECT    tablespace_name,    engine,    tablespace_type,    logfile_group_name,    extent_size FROM    information_schema.tablespaces ORDER BY tablespace_name , engine'
      	,'SELECT NULL LIMIT 0')
      INTO @query;
       
      PREPARE s FROM @query;
      EXECUTE s;
       
      DEALLOCATE PREPARE s;
      

      Is supported to use EXECUTE statment via ODBC connector?

      Attachments

        Issue Links

          Activity

            Could you please try version 3.2.2? The 3.2 series substitutes 3.1, and it's already GA. I believe your problem has been solved in 3.2. 3.1 uses prepared statements aka binary protocol in almost all cases, in particular for batch statements. It splits it to individual statement, and prepare+execute them one by one. And here we probably have problem with preparing PREPARE statement, it's not supported by the server.
            I think this ticket can be closed, but I'll wait till your confirmation.

            Lawrin Lawrin Novitsky added a comment - Could you please try version 3.2.2? The 3.2 series substitutes 3.1, and it's already GA. I believe your problem has been solved in 3.2. 3.1 uses prepared statements aka binary protocol in almost all cases, in particular for batch statements. It splits it to individual statement, and prepare+execute them one by one. And here we probably have problem with preparing PREPARE statement, it's not supported by the server. I think this ticket can be closed, but I'll wait till your confirmation.
            tomas.vladik Tomas Vladik added a comment -

            Well the 3.2.2. version works nice with MariaDB and MySQL 8.0

            But for MySQL 8.4 it fails with error

            System.Data.Odbc.OdbcException : No message provided
               at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
               at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
               at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
               at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
               at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
               at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
               at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
               at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
               at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
               at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
               at System.Data.Odbc.OdbcConnection.Open()
            

            tomas.vladik Tomas Vladik added a comment - Well the 3.2.2. version works nice with MariaDB and MySQL 8.0 But for MySQL 8.4 it fails with error System.Data.Odbc.OdbcException : No message provided at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode) at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle) at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions) at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.Odbc.OdbcConnection.Open()
            Lawrin Lawrin Novitsky added a comment - - edited

            Could you please provide the ODBC Trace for this error? n.m. it looks like it can't connect

            Lawrin Lawrin Novitsky added a comment - - edited Could you please provide the ODBC Trace for this error? n.m. it looks like it can't connect

            Could you please try to reset SSLVERIFY options? i.e. in the DSN uncheck "Verify Certificate", or add to the connection string "SSLVERIFY=0"?

            Lawrin Lawrin Novitsky added a comment - Could you please try to reset SSLVERIFY options? i.e. in the DSN uncheck "Verify Certificate", or add to the connection string "SSLVERIFY=0"?

            But anyway, this would be another problem, and if connection does not work - we will continue in the new ticket, and I am gonna close this one

            Lawrin Lawrin Novitsky added a comment - But anyway, this would be another problem, and if connection does not work - we will continue in the new ticket, and I am gonna close this one

            The problem has been fixed in the new driver version series(3.2)

            Lawrin Lawrin Novitsky added a comment - The problem has been fixed in the new driver version series(3.2)

            People

              Lawrin Lawrin Novitsky
              tomas.vladik Tomas Vladik
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.