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

Error code not set in mysql_stmt_send_long_data

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 2.1
    • 3.0.0, 2.2.0
    • None
    • None
    • All

    Description

      If you call mysql_stmt_send_long_data while the MYSQL* is in the wrong state, it returns the fact that there is an error, but no error code.
      See line 1826 of my_stmt.c.

      To correct, I think the conditional on line 1816 needs to be changed from:
      if (stmt->mysql->status== MYSQL_STATUS_READY && (length || !stmt->params[param_number].long_data_used))
      {

      To:
      if (stmt->mysql->status != MYSQL_STATUS_READY)
      SET_CLIENT_STMT_ERROR(stmt, CR_COMMANDS_OUT_OF_SYNC, SQLSTATE_UNKNOWN, 0);
      DBUG_RETURN(1);
      }

      if (length || !stmt->params[param_number].long_data_used))
      {

      Attachments

        Activity

          georg Georg Richter added a comment - - edited

          Hi Matt,

          thanks for your bug report.

          The extra check for status is redundant, since it will be checked in simple_command/mthd_my_send_cmd. To be compatible with libmysql we also should allow to pass a zero length buffer instead of returning an error.:

          --- a/libmariadb/my_stmt.c
          +++ b/libmariadb/my_stmt.c
          @@ -1811,7 +1811,7 @@ my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
               DBUG_RETURN(1);
             }
           
          -  if (stmt->mysql->status== MYSQL_STATUS_READY && (length || !stmt->params[param_number].long_data_used))
          +  if (length || !stmt->params[param_number].long_data_used)
             {
               int ret;
               size_t packet_len;
          @@ -1824,7 +1824,7 @@ my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number,
               my_free(cmd_buff);
               DBUG_RETURN(ret); 
             } 
          -  DBUG_RETURN(1);
          +  DBUG_RETURN(0);
           }
           
           my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt)

          georg Georg Richter added a comment - - edited Hi Matt, thanks for your bug report. The extra check for status is redundant, since it will be checked in simple_command/mthd_my_send_cmd. To be compatible with libmysql we also should allow to pass a zero length buffer instead of returning an error.: --- a/libmariadb/my_stmt.c +++ b/libmariadb/my_stmt.c @@ -1811,7 +1811,7 @@ my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, DBUG_RETURN(1); } - if (stmt->mysql->status== MYSQL_STATUS_READY && (length || !stmt->params[param_number].long_data_used)) + if (length || !stmt->params[param_number].long_data_used) { int ret; size_t packet_len; @@ -1824,7 +1824,7 @@ my_bool STDCALL mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, my_free(cmd_buff); DBUG_RETURN(ret); } - DBUG_RETURN(1); + DBUG_RETURN(0); } my_ulonglong STDCALL mysql_stmt_insert_id(MYSQL_STMT *stmt)
          georg Georg Richter added a comment -

          fixed (changeset a6f40f2b97b35a15b75c3a419fcfe3a894628675)

          georg Georg Richter added a comment - fixed (changeset a6f40f2b97b35a15b75c3a419fcfe3a894628675)

          People

            georg Georg Richter
            A812371 Matt Fagan
            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.