MDEV-11975: SQLCOM_PREPARE of EXPLAIN & ANALYZE statement do not return correct metadata info

Added metadate info after prepare EXPLAIN/ANALYZE.
This commit is contained in:
Oleksandr Byelkin 2018-04-18 19:34:12 +02:00
parent 0544d7c457
commit b4ee699a89
6 changed files with 499 additions and 12 deletions

View file

@ -122,5 +122,127 @@ EOF
mysql_stmt_next_result(): 0; field_count: 0 mysql_stmt_next_result(): 0; field_count: 0
# ------------------------------------ # ------------------------------------
# cat MYSQL_TMP_DIR/test_explain_meta.out.log
# ------------------------------------
SELECT number of fields: 1
EXPALIN number of fields: 10
- 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
- 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
- 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
- 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
EXPALIN JSON number of fields: 1
- 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
ANALYZE number of fields: 13
- 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
- 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
- 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
- 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
ANALYZE JSON number of fields: 1
- 0: name: 'ANALYZE'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
EXPALIN INSERT number of fields: 10
- 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
- 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
- 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
- 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
EXPALIN JSON INSERT number of fields: 1
- 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
ANALYZE INSERT number of fields: 13
- 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
- 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
- 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
- 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
ANALYZE JSON INSERT number of fields: 1
- 0: name: 'ANALYZE'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
EXPALIN UPDATE number of fields: 10
- 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
- 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
- 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
- 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
EXPALIN JSON UPDATE number of fields: 1
- 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
ANALYZE UPDATE number of fields: 13
- 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
- 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
- 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
- 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
ANALYZE JSON UPDATE number of fields: 1
- 0: name: 'ANALYZE'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
EXPALIN DELETE number of fields: 10
- 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
- 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
- 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
- 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- 9: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
EXPALIN JSON DELETE number of fields: 1
- 0: name: 'EXPLAIN'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
ANALYZE DELETE number of fields: 13
- 0: name: 'id'/''; table: ''/''; db: ''; catalog: 'def'; length: 3; max_length: 0; type: 8; decimals: 0
- 1: name: 'select_type'/''; table: ''/''; db: ''; catalog: 'def'; length: 57; max_length: 0; type: 253; decimals: 39
- 2: name: 'table'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 3: name: 'type'/''; table: ''/''; db: ''; catalog: 'def'; length: 30; max_length: 0; type: 253; decimals: 39
- 4: name: 'possible_keys'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 5: name: 'key'/''; table: ''/''; db: ''; catalog: 'def'; length: 192; max_length: 0; type: 253; decimals: 39
- 6: name: 'key_len'/''; table: ''/''; db: ''; catalog: 'def'; length: 12288; max_length: 0; type: 253; decimals: 39
- 7: name: 'ref'/''; table: ''/''; db: ''; catalog: 'def'; length: 6144; max_length: 0; type: 253; decimals: 39
- 8: name: 'rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 10; max_length: 0; type: 8; decimals: 0
- 9: name: 'r_rows'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 10
- 10: name: 'filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 11: name: 'r_filtered'/''; table: ''/''; db: ''; catalog: 'def'; length: 4; max_length: 0; type: 5; decimals: 2
- 12: name: 'Extra'/''; table: ''/''; db: ''; catalog: 'def'; length: 765; max_length: 0; type: 253; decimals: 39
ANALYZE JSON DELETE number of fields: 1
- 0: name: 'ANALYZE'/''; table: ''/''; db: ''; catalog: 'def'; length: 234; max_length: 0; type: 253; decimals: 39
# ------------------------------------
SET @@global.general_log= @old_general_log; SET @@global.general_log= @old_general_log;
SET @@global.slow_query_log= @old_slow_query_log; SET @@global.slow_query_log= @old_slow_query_log;

View file

@ -29,5 +29,12 @@ echo ok;
--echo # ------------------------------------ --echo # ------------------------------------
--echo --echo
--echo
--echo # cat MYSQL_TMP_DIR/test_explain_meta.out.log
--echo # ------------------------------------
--cat_file $MYSQL_TMP_DIR/test_explain_meta.out.log
--echo # ------------------------------------
--echo
SET @@global.general_log= @old_general_log; SET @@global.general_log= @old_general_log;
SET @@global.slow_query_log= @old_slow_query_log; SET @@global.slow_query_log= @old_slow_query_log;

View file

@ -2659,18 +2659,31 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, size_t key_length)
} }
int THD::send_explain_fields(select_result *result, uint8 explain_flags, bool is_analyze) void THD::prepare_explain_fields(select_result *result,
List<Item> *field_list,
uint8 explain_flags,
bool is_analyze)
{
if (lex->explain_json)
make_explain_json_field_list(*field_list, is_analyze);
else
make_explain_field_list(*field_list, explain_flags, is_analyze);
result->prepare(*field_list, NULL);
}
int THD::send_explain_fields(select_result *result,
uint8 explain_flags,
bool is_analyze)
{ {
List<Item> field_list; List<Item> field_list;
if (lex->explain_json) int rc;
make_explain_json_field_list(field_list, is_analyze); prepare_explain_fields(result, &field_list, explain_flags, is_analyze);
else rc= result->send_result_set_metadata(field_list,
make_explain_field_list(field_list, explain_flags, is_analyze); Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF);
result->prepare(field_list, NULL); return(rc);
return (result->send_result_set_metadata(field_list,
Protocol::SEND_NUM_ROWS |
Protocol::SEND_EOF));
} }

View file

@ -3738,6 +3738,8 @@ public:
void add_changed_table(TABLE *table); void add_changed_table(TABLE *table);
void add_changed_table(const char *key, size_t key_length); void add_changed_table(const char *key, size_t key_length);
CHANGED_TABLE_LIST * changed_table_dup(const char *key, size_t key_length); CHANGED_TABLE_LIST * changed_table_dup(const char *key, size_t key_length);
void prepare_explain_fields(select_result *result, List<Item> *field_list,
uint8 explain_flags, bool is_analyze);
int send_explain_fields(select_result *result, uint8 explain_flags, int send_explain_fields(select_result *result, uint8 explain_flags,
bool is_analyze); bool is_analyze);
void make_explain_field_list(List<Item> &field_list, uint8 explain_flags, void make_explain_field_list(List<Item> &field_list, uint8 explain_flags,

View file

@ -2500,8 +2500,28 @@ static bool check_prepared_statement(Prepared_statement *stmt)
break; break;
} }
if (res == 0) if (res == 0)
DBUG_RETURN(stmt->is_sql_prepare() ? {
FALSE : (send_prep_stmt(stmt, 0) || thd->protocol->flush())); if (!stmt->is_sql_prepare())
{
if (lex->describe || lex->analyze_stmt)
{
if (!lex->result &&
!(lex->result= new (stmt->mem_root) select_send(thd)))
DBUG_RETURN(TRUE);
List<Item> field_list;
thd->prepare_explain_fields(lex->result, &field_list,
lex->describe, lex->analyze_stmt);
res= send_prep_stmt(stmt, lex->result->field_count(field_list)) ||
lex->result->send_result_set_metadata(field_list,
Protocol::SEND_EOF);
}
else
res= send_prep_stmt(stmt, 0);
if (!res)
thd->protocol->flush();
}
DBUG_RETURN(FALSE);
}
error: error:
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }

View file

@ -1056,6 +1056,7 @@ static void test_wl4435_2()
rc= mysql_query(mysql, "DROP PROCEDURE p1"); rc= mysql_query(mysql, "DROP PROCEDURE p1");
myquery(rc); myquery(rc);
} }
mct_close_log();
} }
@ -20291,6 +20292,327 @@ static void test_bulk_autoinc()
#endif #endif
static void print_metadata(MYSQL_RES *rs_metadata, int num_fields)
{
MYSQL_FIELD *fields= mysql_fetch_fields(rs_metadata);
for (int i = 0; i < num_fields; ++i)
{
mct_log(" - %d: name: '%s'/'%s'; table: '%s'/'%s'; "
"db: '%s'; catalog: '%s'; length: %d; max_length: %d; "
"type: %d; decimals: %d\n",
(int) i,
(const char *) fields[i].name,
(const char *) fields[i].org_name,
(const char *) fields[i].table,
(const char *) fields[i].org_table,
(const char *) fields[i].db,
(const char *) fields[i].catalog,
(int) fields[i].length,
(int) fields[i].max_length,
(int) fields[i].type,
(int) fields[i].decimals);
}
}
static void test_explain_meta()
{
MYSQL_STMT *stmt;
int num_fields;
char query[MAX_TEST_QUERY_LENGTH];
MYSQL_RES *rs_metadata;
int rc;
myheader("test_explain_meta");
mct_start_logging("test_explain_meta");
strmov(query, "SELECT 1");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("SELECT number of fields: %d\n", (int) num_fields);
if (num_fields != 1)
{
mct_close_log();
DIE("num_fields != 1");
}
mysql_stmt_close(stmt);
strmov(query, "EXPLAIN SELECT 1");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("EXPALIN number of fields: %d\n", (int) num_fields);
if (num_fields != 10)
{
mct_close_log();
DIE("num_fields != 10");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "EXPLAIN format=json SELECT 1");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("EXPALIN JSON number of fields: %d\n", (int) num_fields);
if (num_fields != 1)
{
mct_close_log();
DIE("num_fields != 1");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "ANALYZE SELECT 1");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("ANALYZE number of fields: %d\n", (int) num_fields);
if (num_fields != 13)
{
mct_close_log();
DIE("num_fields != 13");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "ANALYZE format=json SELECT 1");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("ANALYZE JSON number of fields: %d\n", (int) num_fields);
if (num_fields != 1)
{
mct_close_log();
DIE("num_fields != 1");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
myquery(rc);
strmov(query, "EXPLAIN INSERT INTO t1 values (1)");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("EXPALIN INSERT number of fields: %d\n", (int) num_fields);
if (num_fields != 10)
{
mct_close_log();
DIE("num_fields != 10");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "EXPLAIN format=json INSERT INTO t1 values(1)");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("EXPALIN JSON INSERT number of fields: %d\n", (int) num_fields);
if (num_fields != 1)
{
mct_close_log();
DIE("num_fields != 1");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "ANALYZE INSERT INTO t1 values(1)");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("ANALYZE INSERT number of fields: %d\n", (int) num_fields);
if (num_fields != 13)
{
mct_close_log();
DIE("num_fields != 13");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "ANALYZE format=json INSERT INTO t1 values(1)");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("ANALYZE JSON INSERT number of fields: %d\n", (int) num_fields);
if (num_fields != 1)
{
mct_close_log();
DIE("num_fields != 1");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "EXPLAIN UPDATE t1 set a=2");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("EXPALIN UPDATE number of fields: %d\n", (int) num_fields);
if (num_fields != 10)
{
mct_close_log();
DIE("num_fields != 10");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "EXPLAIN format=json UPDATE t1 set a=2");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("EXPALIN JSON UPDATE number of fields: %d\n", (int) num_fields);
if (num_fields != 1)
{
mct_close_log();
DIE("num_fields != 1");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "ANALYZE UPDATE t1 set a=2");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("ANALYZE UPDATE number of fields: %d\n", (int) num_fields);
if (num_fields != 13)
{
mct_close_log();
DIE("num_fields != 13");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "ANALYZE format=json UPDATE t1 set a=2");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("ANALYZE JSON UPDATE number of fields: %d\n", (int) num_fields);
if (num_fields != 1)
{
mct_close_log();
DIE("num_fields != 1");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "EXPLAIN DELETE FROM t1");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("EXPALIN DELETE number of fields: %d\n", (int) num_fields);
if (num_fields != 10)
{
mct_close_log();
DIE("num_fields != 10");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "EXPLAIN format=json DELETE FROM t1");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("EXPALIN JSON DELETE number of fields: %d\n", (int) num_fields);
if (num_fields != 1)
{
mct_close_log();
DIE("num_fields != 1");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "ANALYZE DELETE FROM t1");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("ANALYZE DELETE number of fields: %d\n", (int) num_fields);
if (num_fields != 13)
{
mct_close_log();
DIE("num_fields != 13");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
strmov(query, "ANALYZE format=json DELETE FROM t1");
stmt= mysql_simple_prepare(mysql, query);
check_stmt(stmt);
rs_metadata= mysql_stmt_result_metadata(stmt);
num_fields= mysql_stmt_field_count(stmt);
mct_log("ANALYZE JSON DELETE number of fields: %d\n", (int) num_fields);
if (num_fields != 1)
{
mct_close_log();
DIE("num_fields != 1");
}
print_metadata(rs_metadata, num_fields);
mysql_stmt_close(stmt);
rc= mysql_query(mysql, "DROP TABLE t1");
myquery(rc);
mct_close_log();
}
static struct my_tests_st my_tests[]= { static struct my_tests_st my_tests[]= {
{ "disable_query_logs", disable_query_logs }, { "disable_query_logs", disable_query_logs },
{ "test_view_sp_list_fields", test_view_sp_list_fields }, { "test_view_sp_list_fields", test_view_sp_list_fields },
@ -20578,6 +20900,7 @@ static struct my_tests_st my_tests[]= {
{ "test_proxy_header", test_proxy_header}, { "test_proxy_header", test_proxy_header},
{ "test_bulk_autoinc", test_bulk_autoinc}, { "test_bulk_autoinc", test_bulk_autoinc},
#endif #endif
{ "test_explain_meta", test_explain_meta },
{ 0, 0 } { 0, 0 }
}; };