Details
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); }
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
Launchpad bug id: 737442