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 bug conc-5:
field->catalog is undefined if result set was obtained from mysql_stmt_result_metadata()
This commit is contained in:
@@ -1369,6 +1369,7 @@ int STDCALL mysql_stmt_execute(MYSQL_STMT *stmt)
|
|||||||
stmt->fields[i].org_table= strdup_root(&stmt->mem_root, stmt->mysql->fields[i].org_table);
|
stmt->fields[i].org_table= strdup_root(&stmt->mem_root, stmt->mysql->fields[i].org_table);
|
||||||
stmt->fields[i].name= strdup_root(&stmt->mem_root, stmt->mysql->fields[i].name);
|
stmt->fields[i].name= strdup_root(&stmt->mem_root, stmt->mysql->fields[i].name);
|
||||||
stmt->fields[i].org_name= strdup_root(&stmt->mem_root, stmt->mysql->fields[i].org_name);
|
stmt->fields[i].org_name= strdup_root(&stmt->mem_root, stmt->mysql->fields[i].org_name);
|
||||||
|
stmt->fields[i].catalog= strdup_root(&stmt->mem_root, stmt->mysql->fields[i].catalog);
|
||||||
stmt->fields[i].def= stmt->mysql->fields[i].def ? strdup_root(&stmt->mem_root, stmt->mysql->fields[i].def) : NULL;
|
stmt->fields[i].def= stmt->mysql->fields[i].def ? strdup_root(&stmt->mem_root, stmt->mysql->fields[i].def) : NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3710,7 +3710,43 @@ static int test_bug53311(MYSQL *mysql)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_conc_5(MYSQL *mysql)
|
||||||
|
{
|
||||||
|
char *query= "SELECT a FROM t1";
|
||||||
|
MYSQL_RES *res;
|
||||||
|
MYSQL_STMT *stmt;
|
||||||
|
MYSQL_FIELD *fields;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)");
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
stmt= mysql_stmt_init(mysql);
|
||||||
|
FAIL_IF(!stmt, "couldn't allocate memory");
|
||||||
|
|
||||||
|
rc= mysql_stmt_prepare(stmt, query, strlen(query));
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
rc= mysql_stmt_execute(stmt);
|
||||||
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
res= mysql_stmt_result_metadata(stmt);
|
||||||
|
FAIL_IF(!res, "Can't obtain resultset");
|
||||||
|
|
||||||
|
fields= mysql_fetch_fields(res);
|
||||||
|
FAIL_IF(!fields, "Can't obtain fields");
|
||||||
|
|
||||||
|
FAIL_IF(strcmp("def", fields[0].catalog), "unexpected value for field->catalog");
|
||||||
|
|
||||||
|
mysql_free_result(res);
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
|
{"test_conc_5", test_conc_5, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
||||||
{"test_bug1115", test_bug1115, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
{"test_bug1115", test_bug1115, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
||||||
{"test_bug1180", test_bug1180, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
{"test_bug1180", test_bug1180, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
||||||
{"test_bug1644", test_bug1644, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
{"test_bug1644", test_bug1644, TEST_CONNECTION_DEFAULT, 0, NULL , NULL},
|
||||||
@@ -3768,8 +3804,8 @@ struct my_tests_st my_tests[] = {
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// if (argc > 1)
|
if (argc > 1)
|
||||||
// get_options(&argc, &argv);
|
get_options(argc, argv);
|
||||||
|
|
||||||
get_envvars();
|
get_envvars();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user