You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Fix for CONC334:
Copy all members of MYSQL_FIELD from mysql->fields to stmt->fields.
This commit is contained in:
@@ -1854,6 +1854,12 @@ int stmt_read_execute_response(MYSQL_STMT *stmt)
|
||||
|
||||
for (i=0; i < stmt->field_count; i++)
|
||||
{
|
||||
memcpy(&stmt->fields[i], &mysql->fields[i], sizeof(MYSQL_FIELD));
|
||||
|
||||
/* since all pointers will be incorrect if another statement will
|
||||
be executed, so we need to allocate memory and copy the
|
||||
information */
|
||||
stmt->fields[i].extension= 0; /* not in use yet */
|
||||
if (mysql->fields[i].db)
|
||||
stmt->fields[i].db= ma_strdup_root(fields_ma_alloc_root, mysql->fields[i].db);
|
||||
if (mysql->fields[i].table)
|
||||
@@ -1866,7 +1872,8 @@ int stmt_read_execute_response(MYSQL_STMT *stmt)
|
||||
stmt->fields[i].org_name= ma_strdup_root(fields_ma_alloc_root, mysql->fields[i].org_name);
|
||||
if (mysql->fields[i].catalog)
|
||||
stmt->fields[i].catalog= ma_strdup_root(fields_ma_alloc_root, mysql->fields[i].catalog);
|
||||
stmt->fields[i].def= mysql->fields[i].def ? ma_strdup_root(fields_ma_alloc_root, mysql->fields[i].def) : NULL;
|
||||
if (mysql->fields[i].def)
|
||||
stmt->fields[i].def= ma_strdup_root(fields_ma_alloc_root, mysql->fields[i].def);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4651,7 +4651,42 @@ static int test_compress(MYSQL *mysql)
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int test_conc334(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||
MYSQL_RES *result;
|
||||
MYSQL_FIELD *field;
|
||||
int rc;
|
||||
|
||||
rc= mysql_stmt_prepare(stmt, SL("SHOW ENGINES"));
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
result= mysql_stmt_result_metadata(stmt);
|
||||
if (!result)
|
||||
{
|
||||
diag("Coudn't retrieve result set");
|
||||
mysql_stmt_close(stmt);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
mysql_field_seek(result, 0);
|
||||
|
||||
while ((field= mysql_fetch_field(result)))
|
||||
{
|
||||
FAIL_IF(field->name_length == 0, "Invalid name length (0)");
|
||||
FAIL_IF(field->table_length == 0, "Invalid name length (0)");
|
||||
}
|
||||
mysql_free_result(result);
|
||||
mysql_stmt_close(stmt);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
{"test_conc334", test_conc334, TEST_CONNECTION_NEW, 0, NULL, NULL},
|
||||
{"test_compress", test_compress, TEST_CONNECTION_NEW, CLIENT_COMPRESS, NULL, NULL},
|
||||
{"test_conc208", test_conc208, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
{"test_mdev14165", test_mdev14165, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
|
Reference in New Issue
Block a user