Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-683

LP:737442 - mysql_stmt_store_result() does not work after an unsuccessfull call to mysql_stmt_bind_result()

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.0.1, 5.5.30, 5.1.67, 5.2.14, 5.3.12
    • 10.2(EOL)
    • None

    Description

      A mysql_stmt_bind_result() call that results in an error prevents future mysql_stmt_store_result() from working since stmt->lasterrno is now set.

      Example:

      int test_store_result_1(MYSQL *mysql)
      {
        MYSQL *stmt;
        int rc;
        char *query= "SELECT 'foo' FROM DUAL";
       
        stmt = mysql_stmt_init(mysql);
        FAIL_IF(!stmt, "stmt_init failed");
       
        rc= mysql_stmt_prepare(stmt, query, strlen(query));
        FAIL_IF(rc, mysql_stmt_error(stmt));
       
        rc= mysql_stmt_execute(stmt);
        FAIL_IF(rc, mysql_stmt_error(stmt));
       
        /* here we store the result set without binding, bind variables
           are required for fetch only */
        rc= mysql_stmt_store_result(stmt);   /* <------- this works ok */
        FAIL_IF(rc, mysql_stmt_error(stmt));
       
        mysql_stmt_close(stmt);
      }
       
      int test_store_result_2(MYSQL *mysql)
      {
        MYSQL *stmt;
        MYSQL_BIND bind[1];
        int rc;
        char *query= "SELECT 'foo' FROM DUAL";
       
        stmt = mysql_stmt_init(mysql);
        FAIL_IF(!stmt, "stmt_init failed");
       
        rc= mysql_stmt_prepare(stmt, query, strlen(query));
        FAIL_IF(rc, mysql_stmt_error(stmt));
       
        rc= mysql_stmt_execute(stmt);
        FAIL_IF(rc, mysql_stmt_error(stmt));
       
        /* Geometry is not supported, mysql_bind_result should fail */
        memset(bind, 0, sizeof(bind));
        bind[0].buffer_type= MYSQL_TYPE_GEOMETRY;
       
        rc= mysql_stmt_bind_result(stmt, bind);
        FAIL_IF(!rc, "Expected error (unsupported buffer type)");
       
        /* We didn't bind as in test_store_result_1, but stmt_store_result
           fails, since it checks for stmt->lasterrno */
        rc= mysql_stmt_store_result(stmt);  /* <-----  this doesn't work */
        FAIL_IF(rc, mysql_stmt_error(stmt));
       
        mysql_stmt_close(stmt);
      }

      Attachments

        Activity

          People

            georg Georg Richter
            philipstoev Philip Stoev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.