Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
None
-
all platforms
Description
The field structure contains an invalid (undefined) value for catalog, if the resultset was obtained via mysql_stmt_result_metadata call().
How to repeat:
static int test_stmt_fields(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);
|
}
|