You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Fix for CONC-282: mysql_stmt_fetch_column doesn't work with prior call to mysql_stmt_store_result
- If no bind variables were bound or the function mysql_stmt_store_result was not called before, the internal bind variables (stmt->bind) was not filled (lengths and null values)
This commit is contained in:
@@ -347,10 +347,6 @@ int mthd_stmt_fetch_to_bind(MYSQL_STMT *stmt, unsigned char *row)
|
||||
uint i;
|
||||
size_t truncations= 0;
|
||||
unsigned char *null_ptr, bit_offset= 4;
|
||||
|
||||
if (!stmt->bind_result_done) /* nothing to do */
|
||||
return(0);
|
||||
|
||||
row++; /* skip status byte */
|
||||
null_ptr= row;
|
||||
row+= (stmt->field_count + 9) / 8;
|
||||
@@ -360,12 +356,15 @@ int mthd_stmt_fetch_to_bind(MYSQL_STMT *stmt, unsigned char *row)
|
||||
/* save row position for fetching values in pieces */
|
||||
if (*null_ptr & bit_offset)
|
||||
{
|
||||
if (!stmt->bind[i].is_null)
|
||||
stmt->bind[i].is_null= &stmt->bind[i].is_null_value;
|
||||
*stmt->bind[i].is_null= 1;
|
||||
stmt->bind[i].u.row_ptr= NULL;
|
||||
} else
|
||||
{
|
||||
stmt->bind[i].u.row_ptr= row;
|
||||
if (stmt->bind[i].flags & MADB_BIND_DUMMY)
|
||||
if (!stmt->bind_result_done ||
|
||||
stmt->bind[i].flags & MADB_BIND_DUMMY)
|
||||
{
|
||||
unsigned long length;
|
||||
|
||||
@@ -374,6 +373,9 @@ int mthd_stmt_fetch_to_bind(MYSQL_STMT *stmt, unsigned char *row)
|
||||
else
|
||||
length= net_field_length(&row);
|
||||
row+= length;
|
||||
if (!stmt->bind[i].length)
|
||||
stmt->bind[i].length= &stmt->bind[i].length_value;
|
||||
*stmt->bind[i].length= stmt->bind[i].length_value= length;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1622,6 +1624,7 @@ int STDCALL mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, unsigned lon
|
||||
SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
|
||||
goto fail;
|
||||
}
|
||||
memset(stmt->bind, 0, sizeof(MYSQL_BIND) * stmt->field_count);
|
||||
}
|
||||
stmt->state = MYSQL_STMT_PREPARED;
|
||||
return(0);
|
||||
@@ -1815,6 +1818,7 @@ int stmt_read_execute_response(MYSQL_STMT *stmt)
|
||||
SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
|
||||
return(1);
|
||||
}
|
||||
memset(stmt->bind, 0, sizeof(MYSQL_BIND) * mysql->field_count);
|
||||
stmt->field_count= mysql->field_count;
|
||||
|
||||
for (i=0; i < stmt->field_count; i++)
|
||||
@@ -2380,6 +2384,7 @@ int STDCALL mariadb_stmt_execute_direct(MYSQL_STMT *stmt,
|
||||
SET_CLIENT_STMT_ERROR(stmt, CR_OUT_OF_MEMORY, SQLSTATE_UNKNOWN, 0);
|
||||
goto fail;
|
||||
}
|
||||
memset(stmt->bind, 0, sizeof(MYSQL_BIND) * stmt->field_count);
|
||||
}
|
||||
stmt->state = MYSQL_STMT_PREPARED;
|
||||
|
||||
|
Reference in New Issue
Block a user