From a6066e230efadddbfad68434cc44379f3320fed6 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 31 Jul 2020 15:07:43 +0530 Subject: [PATCH 1/4] MDEV-22511 innodb.truncate_foreign failed in buildbot with wrong error code - Adding lock_wait_timeout value as 1 make sure that truncate table fails instead of making MDL timeout. --- mysql-test/suite/innodb/r/truncate_foreign.result | 1 + mysql-test/suite/innodb/t/truncate_foreign.test | 1 + 2 files changed, 2 insertions(+) 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'; From 5ec40fbb2704a0bf1369836d88a5def4721809c8 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 31 Jul 2020 16:45:35 +0530 Subject: [PATCH 2/4] MDEV-14711 Fix-up --- storage/innobase/btr/btr0cur.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index bacc05686e9..d433f9cadc8 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -470,7 +470,7 @@ btr_cur_optimistic_latch_leaves( /* release the left block */ btr_leaf_page_release( cursor->left_block, mode, mtr); - return false; + goto unpin_failed; } } else { cursor->left_block = NULL; From a8458a2345ea2497ada2f1bd01aeb9c34934dfc6 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 8 Jul 2020 16:26:34 +0200 Subject: [PATCH 3/4] MDEV-21201 No records produced in information_schema query, depending on projection In case of NATURAL JOIN / USING mark all field (one table can not be opened in any case so optimisation does not worth it). IMHO table should be checked for used fields and filled after prepare, when we will fave whole info about used fields but it is too big change for a bugfix. Which will be made later by Serg patch --- mysql-test/main/information_schema.result | 64 +++++++++++++++++++++++ mysql-test/main/information_schema.test | 62 ++++++++++++++++++++++ sql/sql_parse.cc | 2 + sql/sql_show.cc | 5 +- sql/table.h | 1 + 5 files changed, 133 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result index 62a563bf483..20b5985deb6 100644 --- a/mysql-test/main/information_schema.result +++ b/mysql-test/main/information_schema.result @@ -2201,3 +2201,67 @@ 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 +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 +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 +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 +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 +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 08eeef5aa90..d97aed0e0f2 100644 --- a/mysql-test/main/information_schema.test +++ b/mysql-test/main/information_schema.test @@ -1922,3 +1922,65 @@ 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 +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) +; +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) +; +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 +; +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 +; +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/sql/sql_parse.cc b/sql/sql_parse.cc index ac73b5e9cdf..6802816caaf 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -8904,6 +8904,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 3dbc7724928..c6e801b7976 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -8183,7 +8183,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); for (field_count=0; fields_info->field_name; fields_info++) { diff --git a/sql/table.h b/sql/table.h index a5821a712c6..3d289bf241a 100644 --- a/sql/table.h +++ b/sql/table.h @@ -2183,6 +2183,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 From 976abe64df0c662d36a86bfaac2e944a63064327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 1 Aug 2020 10:38:50 +0300 Subject: [PATCH 4/4] MDEV-21201: Add --sorted_result to the test, for 10.4 On MariaDB 10.4 (commit 4db4b773653eacba029631363ef1abdd5242b71a), the query results would not be sorted, which creates random result differences. Let us explicitly sort the results already in 10.3 in order to avoid future merge trouble. --- mysql-test/main/information_schema.test | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/main/information_schema.test b/mysql-test/main/information_schema.test index d97aed0e0f2..dbb0622baf3 100644 --- a/mysql-test/main/information_schema.test +++ b/mysql-test/main/information_schema.test @@ -1932,6 +1932,7 @@ SELECT SCHEMA_NAME from information_schema.schemata where schema_name=REPEAT('a' create table t (i int, constraint a check (i > 0)); --disable_warnings +--sorted_result select tc.TABLE_SCHEMA, tc.TABLE_NAME, @@ -1941,6 +1942,7 @@ 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, @@ -1950,6 +1952,7 @@ 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, @@ -1958,6 +1961,7 @@ select from information_schema.TABLE_CONSTRAINTS tc NATURAL join information_schema.CHECK_CONSTRAINTS cc ; +--sorted_result select tc.TABLE_SCHEMA, tc.TABLE_NAME, @@ -1966,6 +1970,7 @@ select from information_schema.CHECK_CONSTRAINTS cc NATURAL join information_schema.TABLE_CONSTRAINTS tc ; +--sorted_result select tc.TABLE_SCHEMA, tc.TABLE_NAME,