diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result index 60ea49f25ab..fcc437f8c60 100644 --- a/mysql-test/main/information_schema.result +++ b/mysql-test/main/information_schema.result @@ -2218,3 +2218,72 @@ SCHEMA_NAME # # End of 10.1 tests # +# +# MDEV-21201:No records produced in information_schema query, +# depending on projection +# +create table t (i int, constraint a check (i > 0)); +select +tc.TABLE_SCHEMA, +tc.TABLE_NAME, +cc.CONSTRAINT_NAME, +cc.CHECK_CLAUSE +from information_schema.TABLE_CONSTRAINTS tc +join information_schema.CHECK_CONSTRAINTS cc +using (CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, TABLE_NAME, CONSTRAINT_NAME) +; +TABLE_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE +mysql global_priv Priv json_valid(`Priv`) +test t a `i` > 0 +select +tc.TABLE_SCHEMA, +tc.TABLE_NAME, +cc.CONSTRAINT_NAME, +cc.CHECK_CLAUSE +from information_schema.CHECK_CONSTRAINTS cc +join information_schema.TABLE_CONSTRAINTS tc +using (CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, TABLE_NAME, CONSTRAINT_NAME) +; +TABLE_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE +mysql global_priv Priv json_valid(`Priv`) +test t a `i` > 0 +select +tc.TABLE_SCHEMA, +tc.TABLE_NAME, +cc.CONSTRAINT_NAME, +cc.CHECK_CLAUSE +from information_schema.TABLE_CONSTRAINTS tc +NATURAL join information_schema.CHECK_CONSTRAINTS cc +; +TABLE_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE +mysql global_priv Priv json_valid(`Priv`) +test t a `i` > 0 +select +tc.TABLE_SCHEMA, +tc.TABLE_NAME, +cc.CONSTRAINT_NAME, +cc.CHECK_CLAUSE +from information_schema.CHECK_CONSTRAINTS cc +NATURAL join information_schema.TABLE_CONSTRAINTS tc +; +TABLE_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE +mysql global_priv Priv json_valid(`Priv`) +test t a `i` > 0 +select +tc.TABLE_SCHEMA, +tc.TABLE_NAME, +cc.CONSTRAINT_NAME, +cc.CHECK_CLAUSE, +tc.CONSTRAINT_CATALOG, +tc.CONSTRAINT_SCHEMA +from information_schema.TABLE_CONSTRAINTS tc +join information_schema.CHECK_CONSTRAINTS cc +using (CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, TABLE_NAME, CONSTRAINT_NAME) +; +TABLE_SCHEMA TABLE_NAME CONSTRAINT_NAME CHECK_CLAUSE CONSTRAINT_CATALOG CONSTRAINT_SCHEMA +mysql global_priv Priv json_valid(`Priv`) def mysql +test t a `i` > 0 def test +drop table t; +# +# End of 10.3 tests +# diff --git a/mysql-test/main/information_schema.test b/mysql-test/main/information_schema.test index 1df0d3f635f..a3231d94349 100644 --- a/mysql-test/main/information_schema.test +++ b/mysql-test/main/information_schema.test @@ -1920,3 +1920,70 @@ SELECT SCHEMA_NAME from information_schema.schemata where schema_name=REPEAT('a' --echo # --echo # End of 10.1 tests --echo # + + +--echo # +--echo # MDEV-21201:No records produced in information_schema query, +--echo # depending on projection +--echo # + +create table t (i int, constraint a check (i > 0)); + +--disable_warnings +--sorted_result +select + tc.TABLE_SCHEMA, + tc.TABLE_NAME, + cc.CONSTRAINT_NAME, + cc.CHECK_CLAUSE +from information_schema.TABLE_CONSTRAINTS tc + join information_schema.CHECK_CONSTRAINTS cc + using (CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, TABLE_NAME, CONSTRAINT_NAME) +; +--sorted_result +select + tc.TABLE_SCHEMA, + tc.TABLE_NAME, + cc.CONSTRAINT_NAME, + cc.CHECK_CLAUSE +from information_schema.CHECK_CONSTRAINTS cc + join information_schema.TABLE_CONSTRAINTS tc + using (CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, TABLE_NAME, CONSTRAINT_NAME) +; +--sorted_result +select + tc.TABLE_SCHEMA, + tc.TABLE_NAME, + cc.CONSTRAINT_NAME, + cc.CHECK_CLAUSE +from information_schema.TABLE_CONSTRAINTS tc + NATURAL join information_schema.CHECK_CONSTRAINTS cc +; +--sorted_result +select + tc.TABLE_SCHEMA, + tc.TABLE_NAME, + cc.CONSTRAINT_NAME, + cc.CHECK_CLAUSE +from information_schema.CHECK_CONSTRAINTS cc + NATURAL join information_schema.TABLE_CONSTRAINTS tc +; +--sorted_result +select + tc.TABLE_SCHEMA, + tc.TABLE_NAME, + cc.CONSTRAINT_NAME, + cc.CHECK_CLAUSE, + tc.CONSTRAINT_CATALOG, + tc.CONSTRAINT_SCHEMA +from information_schema.TABLE_CONSTRAINTS tc + join information_schema.CHECK_CONSTRAINTS cc + using (CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, TABLE_NAME, CONSTRAINT_NAME) +; +--enable_warnings + +drop table t; + +--echo # +--echo # End of 10.3 tests +--echo # diff --git a/mysql-test/suite/innodb/r/truncate_foreign.result b/mysql-test/suite/innodb/r/truncate_foreign.result index bcf5b16aa83..fc09b74d62f 100644 --- a/mysql-test/suite/innodb/r/truncate_foreign.result +++ b/mysql-test/suite/innodb/r/truncate_foreign.result @@ -29,6 +29,7 @@ SET DEBUG_SYNC='foreign_constraint_check_for_update SIGNAL fk WAIT_FOR go'; DELETE FROM parent; connection default; SET DEBUG_SYNC='now WAIT_FOR fk'; +SET lock_wait_timeout=1; TRUNCATE TABLE child; ERROR HY000: Lock wait timeout exceeded; try restarting transaction SET DEBUG_SYNC='now SIGNAL go'; diff --git a/mysql-test/suite/innodb/t/truncate_foreign.test b/mysql-test/suite/innodb/t/truncate_foreign.test index 2c00c0641e9..d9d647e69f0 100644 --- a/mysql-test/suite/innodb/t/truncate_foreign.test +++ b/mysql-test/suite/innodb/t/truncate_foreign.test @@ -37,6 +37,7 @@ send DELETE FROM parent; connection default; SET DEBUG_SYNC='now WAIT_FOR fk'; +SET lock_wait_timeout=1; --error ER_LOCK_WAIT_TIMEOUT TRUNCATE TABLE child; SET DEBUG_SYNC='now SIGNAL go'; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6862610537a..51109f128d0 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -9088,6 +9088,8 @@ void add_join_natural(TABLE_LIST *a, TABLE_LIST *b, List *using_fields, SELECT_LEX *lex) { b->natural_join= a; + a->part_of_natural_join= TRUE; + b->part_of_natural_join= TRUE; lex->prev_join_using= using_fields; } diff --git a/sql/sql_show.cc b/sql/sql_show.cc index f72aa23a381..77ebc58bc02 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -8126,7 +8126,10 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) else all_items= thd->free_list; - mark_all_fields_used_in_query(thd, fields_info, &bitmap, all_items); + if (table_list->part_of_natural_join) + bitmap_set_all(&bitmap); + else + mark_all_fields_used_in_query(thd, fields_info, &bitmap, all_items); TMP_TABLE_PARAM *tmp_table_param = new (thd->mem_root) TMP_TABLE_PARAM; tmp_table_param->init(); diff --git a/sql/table.h b/sql/table.h index 6f3620de83f..7ce6db5b193 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2237,6 +2237,7 @@ struct TABLE_LIST parsing 'this' is a NATURAL/USING join iff (natural_join != NULL). */ TABLE_LIST *natural_join; + bool part_of_natural_join; /* True if 'this' represents a nested join that is a NATURAL JOIN. For one of the operands of 'this', the member 'natural_join' points