mysql_stmt_store_result() does not work after an unsuccessfull call to mysql_stmt_bind_result()

Bug #737442 reported by Philip Stoev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
New
Undecided
Unassigned

Bug 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);
}

Changed in maria:
assignee: nobody → Sergei (sergii)
Changed in maria:
assignee: Sergei (sergii) → nobody
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.