From 2967e4e1042a52bbad67009b6084282e53b4a708 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Feb 2008 13:55:46 +0300 Subject: [PATCH] Use an API instead of looking into stmt internals to fetch fields (Test for Bug#32265) tests/mysql_client_test.c: Use an API instead of looking into stmt internals to fetch fields. --- tests/mysql_client_test.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index d85a40f7393..23e37323fb3 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -16120,6 +16120,7 @@ static void test_bug32265() int rc; MYSQL_STMT *stmt; MYSQL_FIELD *field; + MYSQL_RES *metadata; DBUG_ENTER("test_bug32265"); myheader("test_bug32265"); @@ -16137,50 +16138,61 @@ static void test_bug32265() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - field= stmt->mysql->fields; + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); + DIE_UNLESS(field); DIE_UNLESS(strcmp(field->table, "t1") == 0); DIE_UNLESS(strcmp(field->org_table, "t1") == 0); DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); mysql_stmt_close(stmt); stmt= open_cursor("SELECT a '' FROM t1 ``"); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - field= stmt->mysql->fields; + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); DIE_UNLESS(strcmp(field->table, "") == 0); DIE_UNLESS(strcmp(field->org_table, "t1") == 0); DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); mysql_stmt_close(stmt); stmt= open_cursor("SELECT a '' FROM t1 ``"); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - field= stmt->mysql->fields; + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); DIE_UNLESS(strcmp(field->table, "") == 0); DIE_UNLESS(strcmp(field->org_table, "t1") == 0); DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); mysql_stmt_close(stmt); stmt= open_cursor("SELECT * FROM v1"); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - field= stmt->mysql->fields; + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); DIE_UNLESS(strcmp(field->table, "v1") == 0); DIE_UNLESS(strcmp(field->org_table, "t1") == 0); DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); mysql_stmt_close(stmt); stmt= open_cursor("SELECT * FROM v1 /* SIC */ GROUP BY 1"); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - field= stmt->mysql->fields; + metadata= mysql_stmt_result_metadata(stmt); + field= mysql_fetch_field(metadata); DIE_UNLESS(strcmp(field->table, "v1") == 0); DIE_UNLESS(strcmp(field->org_table, "t1") == 0); DIE_UNLESS(strcmp(field->db, "client_test_db") == 0); + mysql_free_result(metadata); mysql_stmt_close(stmt); rc= mysql_query(mysql, "DROP VIEW v1");