Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-2521

COM_STMT_EXECUTE maybe return empty result

    XMLWordPrintable

Details

    • MXS-SPRINT-85

    Description

      insert into randselect values(1, 'a'),... (10, 'ab');

      string sqlstr="select names from randselect where id = ?;"
      stmt = mysql_stmt_init(conn);
      if(NULL == stmt)

      { cerr << "stmt init failed: " << mysql_error(conn); return 1; }

      if (mysql_stmt_prepare(stmt, sql.c_str(), strlen(sql.c_str())) != 0)

      { print_stmt_error(stmt,"stmt prepare fail"); return 1; }

      memset(param,0,sizeof(param));
      memset(result,0,sizeof(result));

      result[0].buffer_type = MYSQL_TYPE_STRING;
      result[0].buffer = (char*)&value;
      result[0].is_unsigned = 0;
      result[0].is_null = 0;
      result[0].buffer_length = MAX_SIZE;
      result[0].length = &length;

      if (mysql_stmt_bind_result(stmt,result) !=0)

      { print_stmt_error(stmt,"bind result error"); return 1; }

      param[0].buffer_type = MYSQL_TYPE_LONG;
      param[0].buffer = (void *) &id;
      param[0].is_unsigned = 1;
      param[0].is_null = 0;
      param[0].length = 0;

      if (mysql_stmt_bind_param(stmt, param) != 0)

      { print_stmt_error(stmt,"bind param error"); return 1; }

      int j = 1;
      while (j < 10)
      {

      id = j;
      //mysql_stmt_bind_param(stmt, param);
      if(mysql_stmt_execute(stmt) !=0)

      { print_stmt_error(stmt,"execute stmt error"); return 1; }

      if (mysql_stmt_store_result(stmt) != 0)

      { print_stmt_error(stmt, "Could not buffer result set"); return 1; }

      cout << "id" << id << endl;
      while (!mysql_stmt_fetch(stmt))

      { cout << " column (string) : " << value << length << endl; }

      j++;
      }

      mysql_stmt_close(stmt);

      when multi stmt_exec router to diff db backends,maybe some exec don't get result(empty),only exec first stmt_exec node will reture result, other db backends will return empty result.

      maybe because stmt_exec(https://dev.mysql.com/doc/internals/en/com-stmt-execute.html) have new-params-bound-flag,and only set when mysql_stmt_bind_param,otherwise new-params-bound-flag=0 and client not send param type lead to db return empty。

      Attachments

        Issue Links

          Activity

            People

              markus makela markus makela
              xzh xiangzhong
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.