Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-281

mysql_stmt_fetch_column() should work without mysql_stmt_store_result()

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 2.3.3, 3.0.2
    • 2.3.4, 3.0.3
    • None
    • None
    • Ubuntu Linux, test compiled from source, run against MySQL 5.7.19

    Description

      It seems that fetching columns of blob or varchar type via mysql_stmt_fetch_column() requires a call to mysql_stmt_store_result() after mysql_stmt_execute(). Otherwise all attempts to fetch the data result in CR_NO_DATA. This is different in the MySQL C connector, and I don't see why I need to bring the entire result set to the client just to make available all blobs in a row. (At least this is how I understand the documentation.) This might severely impact the performance of the new RMariaDB database backend for R.

      Removing all calls to mysql_stmt_store_result() from the tests gives two failures, see [1] for a patch:

      1. port: 0
      2. socketname: (null)
        1..13
      3. Testing against MySQL Server 5.7.19-0ubuntu0.17.04.1
      4. Host: Localhost via UNIX socket
      5. Client library: 10.2.6
      6. Error: (/home/muelleki/git/mariadb-connector-c/unittest/libmariadb/fetch.c: 241)
        not ok 1 - test_fetch_seek
      7. truncation: 1
      8. Error: (/home/muelleki/git/mariadb-connector-c/unittest/libmariadb/fetch.c: 316)
        not ok 2 - test_fetch_offset
        ok 3 - test_fetch_column
        ok 4 - test_fetch_nobuffs
        ok 5 - test_fetch_null
        ok 6 - test_fetch_date
        ok 7 - test_fetch_str
        ok 8 - test_fetch_long
        ok 9 - test_fetch_short
        ok 10 - test_fetch_tiny
        ok 11 - test_fetch_bigint
        ok 12 - test_fetch_float
        ok 13 - test_fetch_double
      9. close default
      10. Failed 2 tests!

      [1] https://github.com/krlmlr/mariadb-connector-c/commit/5db25b0e0448046adec7bdf8ee8cbf47228be5ac

      Attachments

        Issue Links

          Activity

            georg Georg Richter added a comment - - edited

            Brad,

            I don't think this is related to the original issue (wrong length calculation). The CR_NO_DATA error (2051) is immediately returned at the beginning of the function mysql_stmt_fetch_column():

            if (stmt->state < MYSQL_STMT_USER_FETCHING || column >= stmt->field_count ||
                  stmt->state == MYSQL_STMT_FETCH_DONE)  {
                SET_CLIENT_STMT_ERROR(stmt, CR_NO_DATA, SQLSTATE_UNKNOWN, 0);
                return(1);
              }
            

            It would be helpful to start a debug session and check which of the conditions above will fail.

            georg Georg Richter added a comment - - edited Brad, I don't think this is related to the original issue (wrong length calculation). The CR_NO_DATA error (2051) is immediately returned at the beginning of the function mysql_stmt_fetch_column() : if (stmt->state < MYSQL_STMT_USER_FETCHING || column >= stmt->field_count || stmt->state == MYSQL_STMT_FETCH_DONE) { SET_CLIENT_STMT_ERROR(stmt, CR_NO_DATA, SQLSTATE_UNKNOWN, 0 ); return ( 1 ); } It would be helpful to start a debug session and check which of the conditions above will fail.
            bradh352 Brad House added a comment -

            Unfortunately I don't have access to the customer's systems and I'm not able to reproduce myself. I'm testing on Percona XtraDB Cluster 5.7.22, but the customer is on the official Oracle Enterprise MySQL 5.6.40. Reverting back to the 3.0.3 release resolved the customer issue.

            I can say we do reuse statement handles, so it could be related to CONC-344 possibly somehow.

            If we can figure out how to reproduce, I'll open another ticket.

            bradh352 Brad House added a comment - Unfortunately I don't have access to the customer's systems and I'm not able to reproduce myself. I'm testing on Percona XtraDB Cluster 5.7.22, but the customer is on the official Oracle Enterprise MySQL 5.6.40. Reverting back to the 3.0.3 release resolved the customer issue. I can say we do reuse statement handles, so it could be related to CONC-344 possibly somehow. If we can figure out how to reproduce, I'll open another ticket.

            Hi, it is easy to repro with connector 3.0.7 and MySQL 5.7.22

            Just fetch any table with a varchar binding with `buffer_length == 0`. Resize the buffer and update length after `mysql_stmt_fetch` and `mysql_stmt_fetch_column` will always returns `CR_NO_DATA`.

            Regards,
            Mauro.

            mxmauro Mauro Leggieri added a comment - Hi, it is easy to repro with connector 3.0.7 and MySQL 5.7.22 Just fetch any table with a varchar binding with `buffer_length == 0`. Resize the buffer and update length after `mysql_stmt_fetch` and `mysql_stmt_fetch_column` will always returns `CR_NO_DATA`. Regards, Mauro.
            nguri77 Heo Yuna added a comment -

            It was fixed in connector 3.0.3, but at 3.0.4 or later (I've also checked versions 3.0.7 and 3.0.8), the issue reoccurs. As Mauro said, this issue can easily be reproduced.

            nguri77 Heo Yuna added a comment - It was fixed in connector 3.0.3, but at 3.0.4 or later (I've also checked versions 3.0.7 and 3.0.8), the issue reoccurs. As Mauro said, this issue can easily be reproduced.

            As a workaround set MYSQL_REPORT_DATA_TRUNCATION option to zero in the connection options. Checked with source code.

            mxmauro Mauro Leggieri added a comment - As a workaround set MYSQL_REPORT_DATA_TRUNCATION option to zero in the connection options. Checked with source code.

            People

              georg Georg Richter
              krlmlr Kirill Müller
              Votes:
              0 Vote for this issue
              Watchers:
              6 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.