Commit 707d8653 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-25228 JSON_TABLE: Server crashes in Query_cache::unlink_table.

JSON_TABLE shojldn't be counted in the query_cache.
parent 7075955f
...@@ -2227,6 +2227,13 @@ SHOW STATUS LIKE 'Qcache_inserts'; ...@@ -2227,6 +2227,13 @@ SHOW STATUS LIKE 'Qcache_inserts';
Variable_name Value Variable_name Value
Qcache_inserts 0 Qcache_inserts 0
drop table t1; drop table t1;
#
# MDEV-25228 JSON_TABLE: Server crashes in Query_cache::unlink_table.
#
CREATE TABLE t (a INT);
SELECT * FROM t JOIN JSON_TABLE('{}' , '$' COLUMNS(b FOR ORDINALITY)) AS jt;
a b
DROP TABLE t;
restore defaults restore defaults
SET GLOBAL query_cache_type= default; SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size=@save_query_cache_size; SET GLOBAL query_cache_size=@save_query_cache_size;
...@@ -1818,6 +1818,13 @@ select * from t1, json_table(t1.a, '$' columns (f varchar(20) path '$.a')) as jt ...@@ -1818,6 +1818,13 @@ select * from t1, json_table(t1.a, '$' columns (f varchar(20) path '$.a')) as jt
SHOW STATUS LIKE 'Qcache_inserts'; SHOW STATUS LIKE 'Qcache_inserts';
drop table t1; drop table t1;
--echo #
--echo # MDEV-25228 JSON_TABLE: Server crashes in Query_cache::unlink_table.
--echo #
CREATE TABLE t (a INT);
SELECT * FROM t JOIN JSON_TABLE('{}' , '$' COLUMNS(b FOR ORDINALITY)) AS jt;
DROP TABLE t;
--echo restore defaults --echo restore defaults
SET GLOBAL query_cache_type= default; SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size=@save_query_cache_size; SET GLOBAL query_cache_size=@save_query_cache_size;
...@@ -4094,11 +4094,13 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used, ...@@ -4094,11 +4094,13 @@ Query_cache::process_and_count_tables(THD *thd, TABLE_LIST *tables_used,
*tables_type|= HA_CACHE_TBL_NONTRANSACT; *tables_type|= HA_CACHE_TBL_NONTRANSACT;
continue; continue;
} }
if (tables_used->derived) if (tables_used->derived || tables_used->table_function)
{ {
DBUG_PRINT("qcache", ("table: %s", tables_used->alias.str)); DBUG_PRINT("qcache", ("table: %s", tables_used->alias.str));
table_count--; table_count--;
DBUG_PRINT("qcache", ("derived table skipped")); DBUG_PRINT("qcache", (tables_used->table_function ?
"table function skipped" :
"derived table skipped"));
continue; continue;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment