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

.NET: Updating driver throws System.AccessViolationException instead of System.Data.Odbc.OdbcException.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Duplicate
    • 3.2.0, 3.2.1, 3.2.2
    • N/A
    • General
    • None
    • Windows 11. .NET6.0

    Description

      Updating the driver to 3.2 from 3.1 changes the exception thrown when database already exists to a less informative System.AccessViolationException, instead of the previous more informative System.Data.Odbc.OdbcException.

      Expected behavior:
      Exception thrown:
      {{System.Data.Odbc.OdbcException
      Can't create database 'my_database'; database exists}}

      Actual behavior
      Exception thrown:
      {{System.AccessViolationException
      Attempted to read or write protected memory. This is often an indication that other memory is corrupt.}}

      Code to reproduce (just fill in the server, port, username and password):

       private static void Main()
      {
          const string driver = "MariaDB ODBC 3.2 Driver";
          const string database = "my_database";
          const string user = "";
          const string password = "";
          const string server = "";
          const string port = "";
       
          const string connectionString = $"Driver={driver};integratedsecurity=False;database=;uid={user};PWD={password};server={server};port={port};sslmode=DISABLED;no_cache=1;forward_cursor=1;no_schema=0;schemanoerror=1";
       
       
          var commands = new[] { $"CREATE DATABASE {database};", $"CREATE DATABASE {database};" };
          
          try
          {
              using var connection = new OdbcConnection(connectionString);
              connection.Open();
              foreach (var commandText in commands)
              {
                  using var command = connection.CreateCommand();
                  command.CommandText = commandText;
                  command.ExecuteNonQuery();
              }
          }
          catch (Exception ex)
          {
              Console.WriteLine($"Caught exception:\n{ex}");
          }
       
          Console.WriteLine("Program ran to completion");
      }
      

      Attachments

        Issue Links

          Activity

            People

              Lawrin Lawrin Novitsky
              davidlarsson David Larsson
              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.