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

Issue reading table data with C# VS2013

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 2.0.11
    • None
    • None
    • Server Ver 14.14 Distrib 5.5.30, for Win64 (x86) (Windows server 2008 R2 standard), Client running C# application (Windows 7 enterprise)

    Description

      C# Application gets exceptions reading tables using MariaDB connector ODBC 2.0.10 64bit. No issues running with MySQL connector ODBC.

      C# Application included - change DB host, database, username, password before running to point to your database. Application should not have any exceptions reading tables. Works fine with MySQL connector ODBC driver.

      Exception:
      Arithmetic operation resulted in an overflow.

      Attachments

        1. fileContentLargeBlobSizes.csv
          2 kB
        2. maodbc.dll
          1.28 MB
        3. maodbc.dll
          1.66 MB
        4. MariaDbCSharpConnectorTest.zip
          6 kB

        Activity

          Thank you for your report. I will look into it. One question - do I understand correctly that this happens with any table?

          Lawrin Lawrin Novitsky added a comment - Thank you for your report. I will look into it. One question - do I understand correctly that this happens with any table?
          quadcell Steven Riat added a comment -

          The first exception is from second table read, with field name "id", INT data type, Auto Increment. If you have a database that has all data types, that will be a good test. Below is the first two tables

          first table

          CREATE TABLE myFirstTable(
          `entry` VARCHAR(100) NOT NULL COLLATE 'utf8_unicode_ci'
          )
          second table
          CREATE TABLE mySecondTable(
          `id` INT(11) NOT NULL AUTO_INCREMENT,
          `jobletId` INT(11) NOT NULL,
          `extraId` INT(11) NULL DEFAULT NULL,
          `audittime` DATETIME NULL DEFAULT NULL,
          `author` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
          `detailKey` MEDIUMTEXT NULL COLLATE 'utf8_unicode_ci',
          `param0` MEDIUMTEXT NULL COLLATE 'utf8_unicode_ci',
          `param1` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
          `param2` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
          `param3` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
          `param4` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
          `severity` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci'
          )

          quadcell Steven Riat added a comment - The first exception is from second table read, with field name "id", INT data type, Auto Increment. If you have a database that has all data types, that will be a good test. Below is the first two tables first table CREATE TABLE myFirstTable( `entry` VARCHAR(100) NOT NULL COLLATE 'utf8_unicode_ci' ) second table CREATE TABLE mySecondTable( `id` INT(11) NOT NULL AUTO_INCREMENT, `jobletId` INT(11) NOT NULL, `extraId` INT(11) NULL DEFAULT NULL, `audittime` DATETIME NULL DEFAULT NULL, `author` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci', `detailKey` MEDIUMTEXT NULL COLLATE 'utf8_unicode_ci', `param0` MEDIUMTEXT NULL COLLATE 'utf8_unicode_ci', `param1` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci', `param2` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci', `param3` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci', `param4` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci', `severity` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci' )

          The problem was in 64bit connector - in SQLGetData variable used for data length had larger size, than "unsigned long" expected for length in MYSQL_BIND structure. That resulted in bogus values eventually returned to the application.

          I have attached the dll with the fix. Feel free to re-open this if the problem hasn't gone, or file a new bug report in case of other problems.

          Lawrin Lawrin Novitsky added a comment - The problem was in 64bit connector - in SQLGetData variable used for data length had larger size, than "unsigned long" expected for length in MYSQL_BIND structure. That resulted in bogus values eventually returned to the application. I have attached the dll with the fix. Feel free to re-open this if the problem hasn't gone, or file a new bug report in case of other problems.
          quadcell Steven Riat added a comment -

          Got past the first exception, now I get exception "'System.AccessViolationException' when its reading field 7 'hide'

          CREATE TABLE file(
          `fileName` VARCHAR(255) NOT NULL COLLATE 'utf8_unicode_ci',
          `version` INT(11) NOT NULL,
          `fileType` VARCHAR(128) NOT NULL COLLATE 'utf8_unicode_ci',
          `md5Checksum` VARCHAR(32) NOT NULL COLLATE 'utf8_unicode_ci',
          `fileContents` LONGBLOB NOT NULL,
          `remoteUNC` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
          `isDefault` BIT(1) NULL DEFAULT b'0',
          `hide` BIT(1) NULL DEFAULT b'0'
          )

          quadcell Steven Riat added a comment - Got past the first exception, now I get exception "'System.AccessViolationException' when its reading field 7 'hide' CREATE TABLE file( `fileName` VARCHAR(255) NOT NULL COLLATE 'utf8_unicode_ci', `version` INT(11) NOT NULL, `fileType` VARCHAR(128) NOT NULL COLLATE 'utf8_unicode_ci', `md5Checksum` VARCHAR(32) NOT NULL COLLATE 'utf8_unicode_ci', `fileContents` LONGBLOB NOT NULL, `remoteUNC` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci', `isDefault` BIT(1) NULL DEFAULT b'0', `hide` BIT(1) NULL DEFAULT b'0' )

          Ok, reopening.

          Lawrin Lawrin Novitsky added a comment - Ok, reopening.

          Strange passed for me with your table without exception. I will try to figure out from the code what and why could happen with bit field

          Lawrin Lawrin Novitsky added a comment - Strange passed for me with your table without exception. I will try to figure out from the code what and why could happen with bit field
          quadcell Steven Riat added a comment -

          Note: 13 tables were read successful before 'file' table was read and caused the exception with reading 'hide' field using GetValue()

          quadcell Steven Riat added a comment - Note: 13 tables were read successful before 'file' table was read and caused the exception with reading 'hide' field using GetValue()

          Well, "file" wasn't only/first table in my test database either. There should be smth more for it. Would it be possible to post other 13 tables structure/test data here? Or send to my email @mariadb.com? I have one more idea to check. But I guess with your db structure it would go faster anyway.

          Lawrin Lawrin Novitsky added a comment - Well, "file" wasn't only/first table in my test database either. There should be smth more for it. Would it be possible to post other 13 tables structure/test data here? Or send to my email @mariadb.com? I have one more idea to check. But I guess with your db structure it would go faster anyway.
          quadcell Steven Riat added a comment -

          The table/data are for internal use only, sorry. Is it possible to send pdb's , source or both, for me to debug it and get back to you with exception tree?

          quadcell Steven Riat added a comment - The table/data are for internal use only, sorry. Is it possible to send pdb's , source or both, for me to debug it and get back to you with exception tree?
          quadcell Steven Riat added a comment -

          I narrowed it down to the 'file' table only, I sent earlier. Deleted all the other tables. Then in the 'file' table, deleted all fields except 'filecontent', 'isDefault', and 'hide'. Around the 200 record read, it failed on 'hide' again. I can't send the table, but I believe its related to the LARGEBLOB field 'filecontent'. I exported the table and its around 132 megs. So on average around 664K per record. You might want to create a table and fill with 'filecontent' with random data of about 1 meg per record or so for testing.

          quadcell Steven Riat added a comment - I narrowed it down to the 'file' table only, I sent earlier. Deleted all the other tables. Then in the 'file' table, deleted all fields except 'filecontent', 'isDefault', and 'hide'. Around the 200 record read, it failed on 'hide' again. I can't send the table, but I believe its related to the LARGEBLOB field 'filecontent'. I exported the table and its around 132 megs. So on average around 664K per record. You might want to create a table and fill with 'filecontent' with random data of about 1 meg per record or so for testing.
          quadcell Steven Riat added a comment -

          I attached the 'filecontent' largeblob data sizes in a csv file if that helps any.

          quadcell Steven Riat added a comment - I attached the 'filecontent' largeblob data sizes in a csv file if that helps any.

          Thanks, I guess this can help. I will try to recreate your problem

          Lawrin Lawrin Novitsky added a comment - Thanks, I guess this can help. I will try to recreate your problem

          I could not re-create your problem, but I have some good reasons to think that I have fixed it. I removed old library from this page, and attached the new one. Could you please check if now it works for you?

          Lawrin Lawrin Novitsky added a comment - I could not re-create your problem, but I have some good reasons to think that I have fixed it. I removed old library from this page, and attached the new one. Could you please check if now it works for you?
          quadcell Steven Riat added a comment -

          It worked. Can you also give me a 32 bit version? Thank you very much.

          quadcell Steven Riat added a comment - It worked. Can you also give me a 32 bit version? Thank you very much.

          Closing. There was combination of bugs here. Most of them was pure 64bit problem. And I guess part of last problem was bug in (old) underlying Connector/C. And partly that was problem in SQLGetData, and I think 32bit was affected by it, too

          Lawrin Lawrin Novitsky added a comment - Closing. There was combination of bugs here. Most of them was pure 64bit problem. And I guess part of last problem was bug in (old) underlying Connector/C. And partly that was problem in SQLGetData, and I think 32bit was affected by it, too

          I attached 32bit dll here as well. But you know, this is not official release or something. Only good for testing purposes. But enjoy

          Lawrin Lawrin Novitsky added a comment - I attached 32bit dll here as well. But you know, this is not official release or something. Only good for testing purposes. But enjoy

          People

            Lawrin Lawrin Novitsky
            quadcell Steven Riat
            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.