From dfb41fddf69ccbca89fd322901f2809bc3bcc0e9 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 5 Jun 2020 18:55:11 +0300 Subject: [PATCH] Make error messages from DROP TABLE and DROP TABLE IF EXISTS consistent - IF EXISTS ends with a list of all not existing object, instead of a separate note for every not existing object - Produce a "Note" for all wrongly dropped objects (like trying to do DROP SEQUENCE for a normal table) - Do not write existing tables that could not be dropped to binlog Other things: MDEV-22820 Bogus "Unknown table" warnings produced upon attempt to drop parent table referenced by FK This was caused by an older version of this commit patch and later fixed --- mysql-test/main/alter_table.result | 3 +- mysql-test/main/create.result | 3 +- mysql-test/main/create_drop_view.result | 2 +- mysql-test/main/create_or_replace.result | 3 +- mysql-test/main/drop.result | 3 +- mysql-test/main/drop.test | 2 + mysql-test/main/drop_combinations.result | 264 ++++++++++++------ mysql-test/main/drop_combinations.test | 65 ++++- mysql-test/main/join_outer_innodb.result | 4 +- mysql-test/main/profiling.result | 3 +- mysql-test/main/ps.result | 12 +- mysql-test/main/sp.result | 4 +- mysql-test/main/stack-crash.result | 3 +- mysql-test/main/subselect_innodb.result | 3 +- .../binlog/r/binlog_drop_if_exists.result | 44 +++ .../suite/binlog/t/binlog_drop_if_exists.test | 32 +++ mysql-test/suite/csv/csv.result | 4 +- mysql-test/suite/innodb/r/innodb.result | 3 +- mysql-test/suite/maria/lock.result | 3 +- .../suite/maria/maria-partitioning.result | 3 +- mysql-test/suite/maria/max_length.result | 3 +- mysql-test/suite/sql_sequence/create.result | 13 +- mysql-test/suite/sql_sequence/create.test | 2 +- mysql-test/suite/sql_sequence/default.result | 4 +- sql/sql_table.cc | 161 ++++++----- 25 files changed, 431 insertions(+), 215 deletions(-) diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index 6572e5c9238..3a2f72b0988 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -272,8 +272,7 @@ ERROR 42000: Incorrect table name '' drop table t1; drop table if exists t1, t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' create table t1 ( a varchar(10) not null primary key ) engine=myisam; create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1); flush tables; diff --git a/mysql-test/main/create.result b/mysql-test/main/create.result index d22d55669ac..f863070c646 100644 --- a/mysql-test/main/create.result +++ b/mysql-test/main/create.result @@ -29,8 +29,7 @@ create table t2 select auto+1 from t1; ERROR 42S02: Table 'test.t1' doesn't exist drop table if exists t1,t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' create table t1 (b char(0) not null, index(b)); ERROR 42000: The storage engine MyISAM can't index column `b` create table t1 (a int not null,b text) engine=heap; diff --git a/mysql-test/main/create_drop_view.result b/mysql-test/main/create_drop_view.result index 7cfa818ccbf..a62639545e1 100644 --- a/mysql-test/main/create_drop_view.result +++ b/mysql-test/main/create_drop_view.result @@ -54,7 +54,7 @@ id 40 DROP TABLE IF EXISTS v1; Warnings: -Note 1051 Unknown table 'test.v1' +Note 1965 'test.v1' is a view DROP VIEW IF EXISTS v1; DROP VIEW IF EXISTS v1; Warnings: diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result index 485091e5810..1eaf87d190d 100644 --- a/mysql-test/main/create_or_replace.result +++ b/mysql-test/main/create_or_replace.result @@ -255,8 +255,7 @@ drop table t1,t3,t4; create database mysqltest2; drop table if exists test.t1,mysqltest2.t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'mysqltest2.t2' +Note 1051 Unknown table 'test.t1,mysqltest2.t2' create table test.t1 (i int) engine=myisam; create table mysqltest2.t2 like test.t1; lock table test.t1 write, mysqltest2.t2 write; diff --git a/mysql-test/main/drop.result b/mysql-test/main/drop.result index 9200efead38..4755965cbb2 100644 --- a/mysql-test/main/drop.result +++ b/mysql-test/main/drop.result @@ -205,8 +205,7 @@ Warnings: Note 1051 Unknown table 'test.table1' DROP TABLE IF EXISTS table1,table2; Warnings: -Note 1051 Unknown table 'test.table1' -Note 1051 Unknown table 'test.table2' +Note 1051 Unknown table 'test.table1,test.table2' DROP VIEW IF EXISTS view1,view2,view3,view4; Warnings: Note 4092 Unknown VIEW: 'test.view1,test.view2,test.view3,test.view4' diff --git a/mysql-test/main/drop.test b/mysql-test/main/drop.test index 923ec676d18..2a2d2715185 100644 --- a/mysql-test/main/drop.test +++ b/mysql-test/main/drop.test @@ -1,3 +1,5 @@ +--source include/have_innodb.inc + call mtr.add_suppression("table or database name 'abc`def'"); # Initialise diff --git a/mysql-test/main/drop_combinations.result b/mysql-test/main/drop_combinations.result index 079a312d70a..eb6d70e0704 100644 --- a/mysql-test/main/drop_combinations.result +++ b/mysql-test/main/drop_combinations.result @@ -8,6 +8,9 @@ Tables_in_test # drop table t1,t2,t3; ERROR 42S02: Unknown table 'test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t3' show tables; Tables_in_test s1 @@ -17,6 +20,9 @@ v2 # Generating test tables drop table t1,t3,t2; ERROR 42S02: Unknown table 'test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t3' show tables; Tables_in_test s1 @@ -26,6 +32,9 @@ v2 # Generating test tables drop table t1,t4,t2,t3; ERROR 42S02: Unknown table 'test.t4,test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t4,test.t3' show tables; Tables_in_test s1 @@ -40,7 +49,11 @@ v1 v2 # Generating test tables drop table t1,v1,v2,t2; -ERROR 42S02: Unknown table 'test.v1,test.v2' +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 1965 'test.v2' is a view show tables; Tables_in_test s1 @@ -49,7 +62,11 @@ v1 v2 # Generating test tables drop table v1,s1,s2,v2,t2; -ERROR 42S02: Unknown table 'test.v1,test.v2' +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 1965 'test.v2' is a view show tables; Tables_in_test t1 @@ -57,16 +74,29 @@ v1 v2 # Generating test tables drop table t1,s1,v1,t3,t4; -ERROR 42S02: Unknown table 'test.v1,test.t3,test.t4' +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory") +Error 1965 'test.v1' is a view +Error 1051 Unknown table 'test.t3,test.t4' drop table s2,v2,t2,t1; -ERROR 42S02: Unknown table 'test.v2,test.t1' +ERROR 42S02: 'test.v2' is a view +show warnings; +Level Code Message +Error 1965 'test.v2' is a view +Error 1051 Unknown table 'test.t1' show tables; Tables_in_test v1 v2 # Generating test tables drop table s1,v1,s2,v2; -ERROR 42S02: Unknown table 'test.v1,test.v2' +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 1965 'test.v2' is a view show tables; Tables_in_test t1 @@ -99,8 +129,7 @@ v2 # Generating test tables drop table if exists t1,t4,t2,t3; Warnings: -Note 1051 Unknown table 'test.t4' -Note 1051 Unknown table 'test.t3' +Note 1051 Unknown table 'test.t4,test.t3' show tables; Tables_in_test s1 @@ -116,8 +145,8 @@ v2 # Generating test tables drop table if exists t1,v1,v2,t2; Warnings: -Note 1051 Unknown table 'test.v1' -Note 1051 Unknown table 'test.v2' +Note 1965 'test.v1' is a view +Note 1965 'test.v2' is a view show tables; Tables_in_test s1 @@ -127,8 +156,8 @@ v2 # Generating test tables drop table if exists v1,s1,s2,v2,t2; Warnings: -Note 1051 Unknown table 'test.v1' -Note 1051 Unknown table 'test.v2' +Note 1965 'test.v1' is a view +Note 1965 'test.v2' is a view show tables; Tables_in_test t1 @@ -138,12 +167,12 @@ v2 drop table if exists t1,s1,v1,t3,t4; Warnings: Warning 1017 Can't find file: './test/t1.MYI' (errno: 2 "No such file or directory") -Note 1051 Unknown table 'test.v1' -Note 1051 Unknown table 'test.t3' -Note 1051 Unknown table 'test.t4' +Note 1965 'test.v1' is a view +Note 1965 'test.t3' is a view +Note 1965 'test.t4' is a view drop table if exists s2,v2,t2,t1; Warnings: -Note 1051 Unknown table 'test.v2' +Note 1965 'test.v2' is a view Note 1051 Unknown table 'test.t1' show tables; Tables_in_test @@ -152,8 +181,8 @@ v2 # Generating test tables drop table if exists s1,v1,s2,v2; Warnings: -Note 1051 Unknown table 'test.v1' -Note 1051 Unknown table 'test.v2' +Note 1965 'test.v1' is a view +Note 1965 'test.v2' is a view show tables; Tables_in_test t1 @@ -171,29 +200,53 @@ drop temporary sequence if exists ss1,ss2; drop view if exists v1,v2; drop temporary table t1,t2,t3; ERROR 42S02: Unknown table 'test.t1,test.t2,test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t1,test.t2,test.t3' # Generating test tables drop temporary table t1,t3,t2; ERROR 42S02: Unknown table 'test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t3' # Generating test tables drop temporary table t1,t4,t2,t3; ERROR 42S02: Unknown table 'test.t4,test.t3' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.t4,test.t3' # Generating test tables drop temporary table t1,s1,s2,t2; # Generating test tables drop temporary table t1,v1,v2,t2; ERROR 42S02: Unknown table 'test.v1,test.v2' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v1,test.v2' # Generating test tables drop temporary table v1,s1,s2,v2,t2; ERROR 42S02: Unknown table 'test.v1,test.v2' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v1,test.v2' # Generating test tables drop temporary table t1,s1,v1,t3,t4; ERROR 42S02: Unknown table 'test.v1,test.t3,test.t4' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v1,test.t3,test.t4' # Generating test tables drop temporary table s2,v2,t2,t1; ERROR 42S02: Unknown table 'test.v2' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v2' # Generating test tables drop temporary table s1,v1,s2,v2; ERROR 42S02: Unknown table 'test.v1,test.v2' +show warnings; +Level Code Message +Error 1051 Unknown table 'test.v1,test.v2' # Generating test tables # # DROP TEMPORARY TABLE with if exists @@ -208,35 +261,28 @@ Note 1051 Unknown table 'test.t3' # Generating test tables drop temporary table if exists t1,t4,t2,t3; Warnings: -Note 1051 Unknown table 'test.t4' -Note 1051 Unknown table 'test.t3' +Note 1051 Unknown table 'test.t4,test.t3' # Generating test tables drop temporary table if exists t1,s1,s2,t2; # Generating test tables drop temporary table if exists t1,v1,v2,t2; Warnings: -Note 1051 Unknown table 'test.v1' -Note 1051 Unknown table 'test.v2' +Note 1051 Unknown table 'test.v1,test.v2' # Generating test tables drop temporary table if exists v1,s1,s2,v2,t2; Warnings: -Note 1051 Unknown table 'test.v1' -Note 1051 Unknown table 'test.v2' +Note 1051 Unknown table 'test.v1,test.v2' # Generating test tables drop temporary table if exists t1,s1,v1,t3,t4; Warnings: -Note 1051 Unknown table 'test.v1' -Note 1051 Unknown table 'test.t3' -Note 1051 Unknown table 'test.t4' +Note 1051 Unknown table 'test.v1,test.t3,test.t4' drop temporary table if exists s2,v2,t2,t1; Warnings: -Note 1051 Unknown table 'test.v2' -Note 1051 Unknown table 'test.t1' +Note 1051 Unknown table 'test.v2,test.t1' # Generating test tables drop temporary table if exists s1,v1,s2,v2; Warnings: -Note 1051 Unknown table 'test.v1' -Note 1051 Unknown table 'test.v2' +Note 1051 Unknown table 'test.v1,test.v2' # Generating test tables drop temporary table t1,t2; drop temporary sequence s1,s2; @@ -248,6 +294,9 @@ Tables_in_test # drop sequence s1,s2,s3; ERROR 42S02: Unknown SEQUENCE: 'test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s3' show tables; Tables_in_test t1 @@ -257,6 +306,9 @@ v2 # Generating test tables drop sequence s1,s3,s2; ERROR 42S02: Unknown SEQUENCE: 'test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s3' show tables; Tables_in_test t1 @@ -266,6 +318,9 @@ v2 # Generating test tables drop sequence s1,s4,s2,s3; ERROR 42S02: Unknown SEQUENCE: 'test.s4,test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s4,test.s3' show tables; Tables_in_test t1 @@ -273,8 +328,13 @@ t2 v1 v2 # Generating test tables -drop sequence s1,t1,t2,s2; -ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.t2' +drop sequence s1,t1,t2,s2,s3,s4; +ERROR 42S02: 'test.t1' is not a SEQUENCE +show warnings; +Level Code Message +Error 4090 'test.t1' is not a SEQUENCE +Error 4090 'test.t2' is not a SEQUENCE +Error 4091 Unknown SEQUENCE: 'test.s3,test.s4' show tables; Tables_in_test t1 @@ -283,7 +343,11 @@ v1 v2 # Generating test tables drop sequence s1,v1,v2,s2; -ERROR 42S02: Unknown SEQUENCE: 'test.v1,test.v2' +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 1965 'test.v2' is a view show tables; Tables_in_test t1 @@ -292,7 +356,22 @@ v1 v2 # Generating test tables drop sequence v1,t1,t2,v2,s2; -ERROR 42S02: Unknown SEQUENCE: 'test.v1,test.t1,test.t2,test.v2' +ERROR 42S02: 'test.v1' is a view +show warnings; +Level Code Message +Error 1965 'test.v1' is a view +Error 4090 'test.t1' is not a SEQUENCE +Error 4090 'test.t2' is not a SEQUENCE +Error 1965 'test.v2' is a view +drop sequence t1,v1,t2,v2,s2; +ERROR 42S02: 'test.t1' is not a SEQUENCE +show warnings; +Level Code Message +Error 4090 'test.t1' is not a SEQUENCE +Error 1965 'test.v1' is a view +Error 4090 'test.t2' is not a SEQUENCE +Error 1965 'test.v2' is a view +Error 4091 Unknown SEQUENCE: 'test.s2' show tables; Tables_in_test s1 @@ -302,9 +381,20 @@ v1 v2 # Generating test tables drop sequence s1,t1,v1,t3,s4; -ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.v1,test.t3,test.s4' +ERROR 42S02: 'test.t1' is not a SEQUENCE +show warnings; +Level Code Message +Warning 1017 Can't find file: './test/s1.MYI' (errno: 2 "No such file or directory") +Error 4090 'test.t1' is not a SEQUENCE +Error 1965 'test.v1' is a view +Error 4091 Unknown SEQUENCE: 'test.t3,test.s4' drop sequence t2,v2,s2,s1; -ERROR 42S02: Unknown SEQUENCE: 'test.t2,test.v2,test.s1' +ERROR 42S02: 'test.t2' is not a SEQUENCE +show warnings; +Level Code Message +Error 4090 'test.t2' is not a SEQUENCE +Error 1965 'test.v2' is a view +Error 4091 Unknown SEQUENCE: 'test.s1' show tables; Tables_in_test t1 @@ -313,7 +403,13 @@ v1 v2 # Generating test tables drop sequence t1,v1,t2,v2; -ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.v1,test.t2,test.v2' +ERROR 42S02: 'test.t1' is not a SEQUENCE +show warnings; +Level Code Message +Error 4090 'test.t1' is not a SEQUENCE +Error 1965 'test.v1' is a view +Error 4090 'test.t2' is not a SEQUENCE +Error 1965 'test.v2' is a view show tables; Tables_in_test s1 @@ -348,8 +444,7 @@ v2 # Generating test tables drop sequence if exists s1,s4,s2,s3; Warnings: -Note 4091 Unknown SEQUENCE: 'test.s4' -Note 4091 Unknown SEQUENCE: 'test.s3' +Note 4091 Unknown SEQUENCE: 'test.s4,test.s3' show tables; Tables_in_test t1 @@ -359,8 +454,8 @@ v2 # Generating test tables drop sequence if exists s1,t1,t2,s2; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t1' -Note 4091 Unknown SEQUENCE: 'test.t2' +Note 4090 'test.t1' is not a SEQUENCE +Note 4090 'test.t2' is not a SEQUENCE show tables; Tables_in_test t1 @@ -370,8 +465,8 @@ v2 # Generating test tables drop sequence if exists s1,v1,v2,s2; Warnings: -Note 4091 Unknown SEQUENCE: 'test.v1' -Note 4091 Unknown SEQUENCE: 'test.v2' +Note 1965 'test.v1' is a view +Note 1965 'test.v2' is a view show tables; Tables_in_test t1 @@ -381,10 +476,10 @@ v2 # Generating test tables drop sequence if exists v1,t1,t2,v2,s2; Warnings: -Note 4091 Unknown SEQUENCE: 'test.v1' -Note 4091 Unknown SEQUENCE: 'test.t1' -Note 4091 Unknown SEQUENCE: 'test.t2' -Note 4091 Unknown SEQUENCE: 'test.v2' +Note 1965 'test.v1' is a view +Note 4090 'test.t1' is not a SEQUENCE +Note 4090 'test.t2' is not a SEQUENCE +Note 1965 'test.v2' is a view show tables; Tables_in_test s1 @@ -396,14 +491,14 @@ v2 drop sequence if exists s1,t1,v1,t3,s4; Warnings: Warning 1017 Can't find file: './test/s1.MYI' (errno: 2 "No such file or directory") -Note 4091 Unknown SEQUENCE: 'test.t1' -Note 4091 Unknown SEQUENCE: 'test.v1' -Note 4091 Unknown SEQUENCE: 'test.t3' -Note 4091 Unknown SEQUENCE: 'test.s4' +Note 4090 'test.t1' is not a SEQUENCE +Note 1965 'test.v1' is a view +Note 1965 'test.t3' is a view +Note 1965 'test.s4' is a view drop sequence if exists t2,v2,s2,s1; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t2' -Note 4091 Unknown SEQUENCE: 'test.v2' +Note 4090 'test.t2' is not a SEQUENCE +Note 1965 'test.v2' is a view Note 4091 Unknown SEQUENCE: 'test.s1' show tables; Tables_in_test @@ -414,10 +509,10 @@ v2 # Generating test tables drop sequence if exists t1,v1,t2,v2; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t1' -Note 4091 Unknown SEQUENCE: 'test.v1' -Note 4091 Unknown SEQUENCE: 'test.t2' -Note 4091 Unknown SEQUENCE: 'test.v2' +Note 4090 'test.t1' is not a SEQUENCE +Note 1965 'test.v1' is a view +Note 4090 'test.t2' is not a SEQUENCE +Note 1965 'test.v2' is a view show tables; Tables_in_test s1 @@ -438,29 +533,56 @@ drop view if exists v1,v2; # Generating test tables drop temporary sequence s1,s2,s3; ERROR 42S02: Unknown SEQUENCE: 'test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s3' # Generating test tables drop temporary sequence s1,s3,s2; ERROR 42S02: Unknown SEQUENCE: 'test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s3' # Generating test tables drop temporary sequence s1,s4,s2,s3; ERROR 42S02: Unknown SEQUENCE: 'test.s4,test.s3' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.s4,test.s3' # Generating test tables drop temporary sequence s1,t1,t2,s2; ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.t2' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.t1,test.t2' # Generating test tables drop temporary sequence s1,v1,v2,s2; ERROR 42S02: Unknown SEQUENCE: 'test.v1,test.v2' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.v1,test.v2' # Generating test tables drop temporary sequence v1,t1,t2,v2,s2; ERROR 42S02: Unknown SEQUENCE: 'test.v1,test.t1,test.t2,test.v2' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.v1,test.t1,test.t2,test.v2' # Generating test tables drop temporary sequence s1,t1,v1,t3,s4; ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.v1,test.t3,test.s4' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.t1,test.v1,test.t3,test.s4' drop temporary sequence t2,v2,s2,s1; ERROR 42S02: Unknown SEQUENCE: 'test.t2,test.v2,test.s1' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.t2,test.v2,test.s1' # Generating test tables drop temporary sequence t1,v1,t2,v2; ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.v1,test.t2,test.v2' +show warnings; +Level Code Message +Error 4091 Unknown SEQUENCE: 'test.t1,test.v1,test.t2,test.v2' # Generating test tables # # DROP TEMPORARY SEQUENCE with if exists @@ -475,44 +597,30 @@ Note 4091 Unknown SEQUENCE: 'test.s3' # Generating test tables drop temporary sequence if exists s1,s4,s2,s3; Warnings: -Note 4091 Unknown SEQUENCE: 'test.s4' -Note 4091 Unknown SEQUENCE: 'test.s3' +Note 4091 Unknown SEQUENCE: 'test.s4,test.s3' # Generating test tables drop temporary sequence if exists s1,t1,t2,s2; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t1' -Note 4091 Unknown SEQUENCE: 'test.t2' +Note 4091 Unknown SEQUENCE: 'test.t1,test.t2' # Generating test tables drop temporary sequence if exists s1,v1,v2,s2; Warnings: -Note 4091 Unknown SEQUENCE: 'test.v1' -Note 4091 Unknown SEQUENCE: 'test.v2' +Note 4091 Unknown SEQUENCE: 'test.v1,test.v2' # Generating test tables drop temporary sequence if exists v1,t1,t2,v2,s2; Warnings: -Note 4091 Unknown SEQUENCE: 'test.v1' -Note 4091 Unknown SEQUENCE: 'test.t1' -Note 4091 Unknown SEQUENCE: 'test.t2' -Note 4091 Unknown SEQUENCE: 'test.v2' +Note 4091 Unknown SEQUENCE: 'test.v1,test.t1,test.t2,test.v2' # Generating test tables drop temporary sequence if exists s1,t1,v1,t3,s4; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t1' -Note 4091 Unknown SEQUENCE: 'test.v1' -Note 4091 Unknown SEQUENCE: 'test.t3' -Note 4091 Unknown SEQUENCE: 'test.s4' +Note 4091 Unknown SEQUENCE: 'test.t1,test.v1,test.t3,test.s4' drop temporary sequence if exists t2,v2,s2,s1; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t2' -Note 4091 Unknown SEQUENCE: 'test.v2' -Note 4091 Unknown SEQUENCE: 'test.s1' +Note 4091 Unknown SEQUENCE: 'test.t2,test.v2,test.s1' # Generating test tables drop temporary sequence if exists t1,v1,t2,v2; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t1' -Note 4091 Unknown SEQUENCE: 'test.v1' -Note 4091 Unknown SEQUENCE: 'test.t2' -Note 4091 Unknown SEQUENCE: 'test.v2' +Note 4091 Unknown SEQUENCE: 'test.t1,test.v1,test.t2,test.v2' # Generating test tables drop temporary table t1,t2; drop temporary sequence s1,s2; diff --git a/mysql-test/main/drop_combinations.test b/mysql-test/main/drop_combinations.test index 1c3971b9520..0d58b13ddd3 100644 --- a/mysql-test/main/drop_combinations.test +++ b/mysql-test/main/drop_combinations.test @@ -16,29 +16,37 @@ let $create_option=; --error ER_BAD_TABLE_ERROR drop table t1,t2,t3; +show warnings; --source drop_combinations.inc --error ER_BAD_TABLE_ERROR drop table t1,t3,t2; +show warnings; --source drop_combinations.inc --error ER_BAD_TABLE_ERROR drop table t1,t4,t2,t3; +show warnings; --source drop_combinations.inc drop table t1,s1,s2,t2; --source drop_combinations.inc ---error ER_BAD_TABLE_ERROR +--error ER_IT_IS_A_VIEW drop table t1,v1,v2,t2; +show warnings; --source drop_combinations.inc ---error ER_BAD_TABLE_ERROR +--error ER_IT_IS_A_VIEW drop table v1,s1,s2,v2,t2; +show warnings; --source drop_combinations.inc --remove_file $DATADIR/test/t1.MYD ---error ER_BAD_TABLE_ERROR +--error ER_IT_IS_A_VIEW drop table t1,s1,v1,t3,t4; ---error ER_BAD_TABLE_ERROR +show warnings; +--error ER_IT_IS_A_VIEW drop table s2,v2,t2,t1; +show warnings; --source drop_combinations.inc ---error ER_BAD_TABLE_ERROR +--error ER_IT_IS_A_VIEW drop table s1,v1,s2,v2; +show warnings; --source drop_combinations.inc --echo # @@ -58,6 +66,7 @@ drop table if exists t1,v1,v2,t2; drop table if exists v1,s1,s2,v2,t2; --source drop_combinations.inc --remove_file $DATADIR/test/t1.MYD +--replace_result \\ / drop table if exists t1,s1,v1,t3,t4; drop table if exists s2,v2,t2,t1; --source drop_combinations.inc @@ -79,29 +88,37 @@ let $create_option=temporary; --error ER_BAD_TABLE_ERROR drop temporary table t1,t2,t3; +show warnings; --source drop_combinations.inc --error ER_BAD_TABLE_ERROR drop temporary table t1,t3,t2; +show warnings; --source drop_combinations.inc --error ER_BAD_TABLE_ERROR drop temporary table t1,t4,t2,t3; +show warnings; --source drop_combinations.inc drop temporary table t1,s1,s2,t2; --source drop_combinations.inc --error ER_BAD_TABLE_ERROR drop temporary table t1,v1,v2,t2; +show warnings; --source drop_combinations.inc --error ER_BAD_TABLE_ERROR drop temporary table v1,s1,s2,v2,t2; +show warnings; --source drop_combinations.inc --error ER_BAD_TABLE_ERROR drop temporary table t1,s1,v1,t3,t4; +show warnings; --source drop_combinations.inc --error ER_BAD_TABLE_ERROR drop temporary table s2,v2,t2,t1; +show warnings; --source drop_combinations.inc --error ER_BAD_TABLE_ERROR drop temporary table s1,v1,s2,v2; +show warnings; --source drop_combinations.inc --echo # @@ -137,30 +154,43 @@ drop temporary sequence s1,s2; --error ER_UNKNOWN_SEQUENCES drop sequence s1,s2,s3; +show warnings; --source drop_combinations.inc --error ER_UNKNOWN_SEQUENCES drop sequence s1,s3,s2; +show warnings; --source drop_combinations.inc --error ER_UNKNOWN_SEQUENCES drop sequence s1,s4,s2,s3; +show warnings; --source drop_combinations.inc ---error ER_UNKNOWN_SEQUENCES -drop sequence s1,t1,t2,s2; +--error ER_NOT_SEQUENCE2 +drop sequence s1,t1,t2,s2,s3,s4; +show warnings; --source drop_combinations.inc ---error ER_UNKNOWN_SEQUENCES +--error ER_IT_IS_A_VIEW drop sequence s1,v1,v2,s2; +show warnings; --source drop_combinations.inc ---error ER_UNKNOWN_SEQUENCES +--error ER_IT_IS_A_VIEW drop sequence v1,t1,t2,v2,s2; +show warnings; +--error ER_NOT_SEQUENCE2 +drop sequence t1,v1,t2,v2,s2; +show warnings; --source drop_combinations.inc --remove_file $DATADIR/test/s1.MYD ---error ER_UNKNOWN_SEQUENCES +--replace_result \\ / +--error ER_NOT_SEQUENCE2 drop sequence s1,t1,v1,t3,s4; ---error ER_UNKNOWN_SEQUENCES +show warnings; +--error ER_NOT_SEQUENCE2 drop sequence t2,v2,s2,s1; +show warnings; --source drop_combinations.inc ---error ER_UNKNOWN_SEQUENCES +--error ER_NOT_SEQUENCE2 drop sequence t1,v1,t2,v2; +show warnings; --source drop_combinations.inc --echo # @@ -180,6 +210,7 @@ drop sequence if exists s1,v1,v2,s2; drop sequence if exists v1,t1,t2,v2,s2; --source drop_combinations.inc --remove_file $DATADIR/test/s1.MYD +--replace_result \\ / drop sequence if exists s1,t1,v1,t3,s4; drop sequence if exists t2,v2,s2,s1; --source drop_combinations.inc @@ -202,29 +233,38 @@ let $create_option=temporary; --error ER_UNKNOWN_SEQUENCES drop temporary sequence s1,s2,s3; +show warnings; --source drop_combinations.inc --error ER_UNKNOWN_SEQUENCES drop temporary sequence s1,s3,s2; +show warnings; --source drop_combinations.inc --error ER_UNKNOWN_SEQUENCES drop temporary sequence s1,s4,s2,s3; +show warnings; --source drop_combinations.inc --error ER_UNKNOWN_SEQUENCES drop temporary sequence s1,t1,t2,s2; +show warnings; --source drop_combinations.inc --error ER_UNKNOWN_SEQUENCES drop temporary sequence s1,v1,v2,s2; +show warnings; --source drop_combinations.inc --error ER_UNKNOWN_SEQUENCES drop temporary sequence v1,t1,t2,v2,s2; +show warnings; --source drop_combinations.inc --error ER_UNKNOWN_SEQUENCES drop temporary sequence s1,t1,v1,t3,s4; +show warnings; --error ER_UNKNOWN_SEQUENCES drop temporary sequence t2,v2,s2,s1; +show warnings; --source drop_combinations.inc --error ER_UNKNOWN_SEQUENCES drop temporary sequence t1,v1,t2,v2; +show warnings; --source drop_combinations.inc --echo # @@ -279,6 +319,7 @@ drop view v1,s1,s2,v2; show warnings; --source drop_combinations.inc --remove_file $DATADIR/test/t1.MYD +--replace_result \\ / --error ER_UNKNOWN_VIEW drop view s1,t1,t2,s2,v2; show warnings; diff --git a/mysql-test/main/join_outer_innodb.result b/mysql-test/main/join_outer_innodb.result index 5bfcf7f20e1..0b34a399d77 100644 --- a/mysql-test/main/join_outer_innodb.result +++ b/mysql-test/main/join_outer_innodb.result @@ -481,9 +481,7 @@ drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16; # drop table if exists t1,t2,t3; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' -Note 1051 Unknown table 'test.t3' +Note 1051 Unknown table 'test.t1,test.t2,test.t3' create table t2(a int,unique key (a)) engine=innodb; create table t3(b int) engine=innodb; create table t1(c int,b int)engine=innodb; diff --git a/mysql-test/main/profiling.result b/mysql-test/main/profiling.result index 6590d89bc89..f1403c3ec2f 100644 --- a/mysql-test/main/profiling.result +++ b/mysql-test/main/profiling.result @@ -123,8 +123,7 @@ select query_id, count(*), sum(duration) from information_schema.profiling group select CPU_user, CPU_system, Context_voluntary, Context_involuntary, Block_ops_in, Block_ops_out, Messages_sent, Messages_received, Page_faults_major, Page_faults_minor, Swaps, Source_function, Source_file, Source_line from information_schema.profiling; drop table if exists t1, t2, t3; Warnings: -Note 1051 Unknown table 'test.t2' -Note 1051 Unknown table 'test.t3' +Note 1051 Unknown table 'test.t2,test.t3' create table t1 (id int ); create table t2 (id int not null); create table t3 (id int not null primary key); diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index f1972b6b40e..d97720c2d41 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -2856,12 +2856,10 @@ Level Code Message Note 1051 Unknown table 'test.t2' drop table if exists t1, t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' call proc_1(); Level Code Message -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' drop procedure proc_1; create function func_1() returns int begin show warnings; return 1; end| ERROR 0A000: Not allowed to return a result set from a function @@ -2880,12 +2878,10 @@ Level Code Message Note 1051 Unknown table 'test.t2' drop table if exists t1, t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' execute abc; Level Code Message -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' deallocate prepare abc; set @my_password="password"; set @my_data="clear text to encode"; diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 376f44e3b01..dd7e12949f4 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -3220,9 +3220,7 @@ Warnings: Note 4092 Unknown VIEW: 'test.tv' DROP TABLE IF EXISTS tt1,tt2,tt3| Warnings: -Note 1051 Unknown table 'test.tt1' -Note 1051 Unknown table 'test.tt2' -Note 1051 Unknown table 'test.tt3' +Note 1051 Unknown table 'test.tt1,test.tt2,test.tt3' CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))| CREATE TABLE tt2 (a2 int, data2 varchar(10))| CREATE TABLE tt3 (a3 int, data3 varchar(10))| diff --git a/mysql-test/main/stack-crash.result b/mysql-test/main/stack-crash.result index 62870db79f3..8c0001e748a 100644 --- a/mysql-test/main/stack-crash.result +++ b/mysql-test/main/stack-crash.result @@ -1,7 +1,6 @@ drop table if exists t1,t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' CREATE TABLE t1 ( `sspo_id` int(11) NOT NULL AUTO_INCREMENT, `sspo_uid` int(11) NOT NULL DEFAULT '0', diff --git a/mysql-test/main/subselect_innodb.result b/mysql-test/main/subselect_innodb.result index 4cf28638484..4d3d958c8c5 100644 --- a/mysql-test/main/subselect_innodb.result +++ b/mysql-test/main/subselect_innodb.result @@ -435,8 +435,7 @@ drop table t1; # drop table if exists `t1`,`t2`; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' create table `t1`(`a` char(1) character set utf8)engine=innodb; create table `t2`(`b` char(1) character set utf8)engine=memory; select distinct (select 1 from `t2` where `a`) `d2` from `t1`; diff --git a/mysql-test/suite/binlog/r/binlog_drop_if_exists.result b/mysql-test/suite/binlog/r/binlog_drop_if_exists.result index 937662a7a49..c918de9a907 100644 --- a/mysql-test/suite/binlog/r/binlog_drop_if_exists.result +++ b/mysql-test/suite/binlog/r/binlog_drop_if_exists.result @@ -164,3 +164,47 @@ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; CREATE TABLE t1(id int) master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS /* */ `t1` /* generated by server */ +# +# MDEV-22820 Bogus "Unknown table" warnings produced upon attempt to +# drop parent table referenced by FK +# +create table t1 (a int, key(a)) engine=InnoDB; +create table t2 (b int, foreign key(b) references t1(a)) engine=InnoDB; +drop table if exists t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +drop table if exists t1,t0; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +show warnings; +Level Code Message +Error 1451 Cannot delete or update a parent row: a foreign key constraint fails +Note 1051 Unknown table 'test.t0' +drop table t2,t1; +create table t3 (a int) engine=aria; +drop table t10,t20; +ERROR 42S02: Unknown table 'test.t10,test.t20' +drop table t10,t20,t3; +ERROR 42S02: Unknown table 'test.t10,test.t20' +drop table if exists t10,t20; +Warnings: +Note 1051 Unknown table 'test.t10,test.t20' +drop table if exists t10,t20,t3; +Warnings: +Note 1051 Unknown table 'test.t10,test.t20,test.t3' +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t1 (a int, key(a)) engine=InnoDB +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t2 (b int, foreign key(b) references t1(a)) engine=InnoDB +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t0` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t2`,`t1` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; create table t3 (a int) engine=aria +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t10`,`t20`,`t3` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t10`,`t20` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `t10`,`t20`,`t3` /* generated by server */ diff --git a/mysql-test/suite/binlog/t/binlog_drop_if_exists.test b/mysql-test/suite/binlog/t/binlog_drop_if_exists.test index 26910432428..b565104ce3a 100644 --- a/mysql-test/suite/binlog/t/binlog_drop_if_exists.test +++ b/mysql-test/suite/binlog/t/binlog_drop_if_exists.test @@ -1,3 +1,5 @@ +--source include/have_innodb.inc + # BUG#13684: # SP: DROP PROCEDURE|FUNCTION IF EXISTS not binlogged if routine # does not exist @@ -128,3 +130,33 @@ DROP TABLE IF EXISTS /* */ t1; --source include/show_binlog_events.inc +--echo # +--echo # MDEV-22820 Bogus "Unknown table" warnings produced upon attempt to +--echo # drop parent table referenced by FK +--echo # + +let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1); + +create table t1 (a int, key(a)) engine=InnoDB; +create table t2 (b int, foreign key(b) references t1(a)) engine=InnoDB; +--error ER_ROW_IS_REFERENCED_2 +drop table if exists t1; +--error ER_ROW_IS_REFERENCED_2 +drop table if exists t1,t0; +show warnings; +drop table t2,t1; + +create table t3 (a int) engine=aria; + +# This is not logged +--error ER_BAD_TABLE_ERROR +drop table t10,t20; +# This is logged +--error ER_BAD_TABLE_ERROR +drop table t10,t20,t3; + +# These are both logged +drop table if exists t10,t20; +drop table if exists t10,t20,t3; + +--source include/show_binlog_events.inc diff --git a/mysql-test/suite/csv/csv.result b/mysql-test/suite/csv/csv.result index 220b84b222e..de5025be0ea 100644 --- a/mysql-test/suite/csv/csv.result +++ b/mysql-test/suite/csv/csv.result @@ -4928,9 +4928,7 @@ period 9410 drop table if exists t1,t2,t3,t4; Warnings: -Note 1051 Unknown table 'test.t2' -Note 1051 Unknown table 'test.t3' -Note 1051 Unknown table 'test.t4' +Note 1051 Unknown table 'test.t2,test.t3,test.t4' DROP TABLE IF EXISTS bug13894; CREATE TABLE bug13894 ( val integer not null ) ENGINE = CSV; INSERT INTO bug13894 VALUES (5); diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index 76dedbf2495..1cd62911e81 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -3130,8 +3130,7 @@ SET TX_ISOLATION='read-committed'; SET AUTOCOMMIT=0; DROP TABLE IF EXISTS t1, t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' CREATE TABLE t1 ( a int ) ENGINE=InnoDB; CREATE TABLE t2 LIKE t1; SELECT * FROM t2; diff --git a/mysql-test/suite/maria/lock.result b/mysql-test/suite/maria/lock.result index de24b987524..9c7c7bedbb2 100644 --- a/mysql-test/suite/maria/lock.result +++ b/mysql-test/suite/maria/lock.result @@ -1,7 +1,6 @@ drop table if exists t1,t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' CREATE TABLE t1 (i INT) ENGINE=Aria; CREATE TABLE t2 (i INT) ENGINE=Aria; LOCK TABLE t1 WRITE, t2 WRITE; diff --git a/mysql-test/suite/maria/maria-partitioning.result b/mysql-test/suite/maria/maria-partitioning.result index 1ef54bde3c8..35b7da489fa 100644 --- a/mysql-test/suite/maria/maria-partitioning.result +++ b/mysql-test/suite/maria/maria-partitioning.result @@ -2,8 +2,7 @@ set global default_storage_engine=aria; set session default_storage_engine=aria; DROP TABLE if exists t1,t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' create table t2(a blob) engine=aria; create table t1(a int primary key) engine=aria; insert into t2 values ('foo'),('bar'); diff --git a/mysql-test/suite/maria/max_length.result b/mysql-test/suite/maria/max_length.result index 1508ac25cb3..4403ce5d0d2 100644 --- a/mysql-test/suite/maria/max_length.result +++ b/mysql-test/suite/maria/max_length.result @@ -1,7 +1,6 @@ drop table if exists t1,t2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' create table t1 (id int(10) unsigned not null auto_increment primary key, v varchar(2000), b blob) row_format=page max_rows=2 engine=aria; create table t2 (id int(10) unsigned not null auto_increment primary key, v varchar(2000), b blob, key(v)) row_format=page max_rows=20000000 engine=aria; show create table t1; diff --git a/mysql-test/suite/sql_sequence/create.result b/mysql-test/suite/sql_sequence/create.result index 14464c60e99..6f70f335d88 100644 --- a/mysql-test/suite/sql_sequence/create.result +++ b/mysql-test/suite/sql_sequence/create.result @@ -165,7 +165,7 @@ drop sequence t1; ERROR 42S02: 'test.t1' is not a SEQUENCE drop sequence if exists t1; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t1' +Note 4090 'test.t1' is not a SEQUENCE create sequence t1 start with 10 maxvalue=9; ERROR HY000: Sequence 'test.t1' values are conflicting create sequence t1 minvalue= 100 maxvalue=10; @@ -421,12 +421,11 @@ CREATE SEQUENCE s1; drop sequence s1; drop sequence if exists t1,t2,t3,t4; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t3' +Note 4090 'test.t3' is not a SEQUENCE Note 4091 Unknown SEQUENCE: 'test.t4' drop table if exists t1,t2,t3; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.t2' +Note 1051 Unknown table 'test.t1,test.t2' CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); CREATE SEQUENCE s1; @@ -441,15 +440,15 @@ CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); CREATE SEQUENCE s1; drop sequence t1,t2,s1,s2; -ERROR 42S02: Unknown SEQUENCE: 'test.t1,test.t2,test.s2' +ERROR 42S02: 'test.t1' is not a SEQUENCE drop table if exists t1,t2; CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); CREATE SEQUENCE s1; drop sequence if exists t1,t2,s1,s2; Warnings: -Note 4091 Unknown SEQUENCE: 'test.t1' -Note 4091 Unknown SEQUENCE: 'test.t2' +Note 4090 'test.t1' is not a SEQUENCE +Note 4090 'test.t2' is not a SEQUENCE Note 4091 Unknown SEQUENCE: 'test.s2' drop table if exists t1,t2; CREATE TEMPORARY SEQUENCE s1; diff --git a/mysql-test/suite/sql_sequence/create.test b/mysql-test/suite/sql_sequence/create.test index 2c41fb3658b..61430740560 100644 --- a/mysql-test/suite/sql_sequence/create.test +++ b/mysql-test/suite/sql_sequence/create.test @@ -342,7 +342,7 @@ drop table if exists t1,t2,s1,s2; CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); CREATE SEQUENCE s1; ---error ER_UNKNOWN_SEQUENCES +--error ER_NOT_SEQUENCE2 drop sequence t1,t2,s1,s2; drop table if exists t1,t2; diff --git a/mysql-test/suite/sql_sequence/default.result b/mysql-test/suite/sql_sequence/default.result index 37d536d9020..14abc656423 100644 --- a/mysql-test/suite/sql_sequence/default.result +++ b/mysql-test/suite/sql_sequence/default.result @@ -1,8 +1,6 @@ drop table if exists t1,s1,s2; Warnings: -Note 1051 Unknown table 'test.t1' -Note 1051 Unknown table 'test.s1' -Note 1051 Unknown table 'test.s2' +Note 1051 Unknown table 'test.t1,test.s1,test.s2' drop view if exists v1; Warnings: Note 4092 Unknown VIEW: 'test.v1' diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2569665fc59..ff28939f8c4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2236,11 +2236,11 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, bool dont_free_locks) { TABLE_LIST *table; - char path[FN_REFLEN + 1], wrong_tables_buff[160]; + char path[FN_REFLEN + 1], unknown_tables_buff[160]; LEX_CSTRING alias= null_clex_str; - String wrong_tables(wrong_tables_buff, sizeof(wrong_tables_buff)-1, + String unknown_tables(unknown_tables_buff, sizeof(unknown_tables_buff)-1, system_charset_info); - uint path_length= 0, errors= 0; + uint not_found_errors= 0; int error= 0; int non_temp_tables_count= 0; bool non_tmp_error= 0; @@ -2253,7 +2253,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, String built_trans_tmp_query, built_non_trans_tmp_query; DBUG_ENTER("mysql_rm_table_no_locks"); - wrong_tables.length(0); + unknown_tables.length(0); /* Prepares the drop statements that will be written into the binary log as follows: @@ -2310,9 +2310,11 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, bool is_trans= 0, frm_was_deleted= 0, temporary_table_was_dropped= 0; bool table_creation_was_logged= 0, trigger_drop_executed= 0; bool local_non_tmp_error= 0, frm_exists= 0, wrong_drop_sequence= 0; - bool drop_table_not_done= 0; + bool table_dropped= 0; LEX_CSTRING db= table->db; handlerton *table_type= 0; + size_t path_length= 0; + char *path_end= 0; error= 0; DBUG_PRINT("table", ("table_l: '%s'.'%s' table: %p s: %p", @@ -2410,6 +2412,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, /* remove .frm file and engine files */ path_length= build_table_filename(path, sizeof(path) - 1, db.str, alias.str, reg_ext, 0); + path_end= path + path_length - reg_ext_length; } DEBUG_SYNC(thd, "rm_table_no_locks_before_delete_table"); @@ -2435,15 +2438,11 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, was_table|= wrong_drop_sequence; local_non_tmp_error= 1; error= -1; - if ((!frm_exists && !table_type) || // no .frm - if_exists) + if ((!frm_exists && !table_type)) // no .frm error= ENOENT; } else { - char *end; - int frm_delete_error= 0; - #ifdef WITH_WSREP if (WSREP(thd) && !wsrep_should_replicate_ddl(thd, table_type->db_type)) @@ -2487,7 +2486,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, MDL_EXCLUSIVE)); // Remove extension for delete - *(end= path + path_length - reg_ext_length)= '\0'; + *path_end= '\0'; if (table_type && table_type != view_pseudo_hton && table_type->flags & HTON_TABLE_MAY_NOT_EXIST_ON_SLAVE) @@ -2497,9 +2496,11 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, error= ha_delete_table(thd, table_type, path, &db, &table->table_name, !dont_log_query); - if (error < 0) // Table didn't exists - error= 0; - if (error) + if (!error) + table_dropped= 1; + else if (error < 0) + error= 0; // Table didn't exists + else if (error) { if (thd->is_killed()) { @@ -2507,15 +2508,20 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, goto err; } } + /* This may be set by the storage engine in handler::delete_table() */ + if (thd->replication_flags & OPTION_IF_EXISTS) + log_if_exists= 1; /* Delete the .frm file if we managed to delete the table from the engine or the table didn't exists in the engine */ - if (likely(!error) || non_existing_table_error(error)) + strmov(path_end, reg_ext); + if ((likely(!error) || non_existing_table_error(error)) && + !access(path, F_OK)) { + int frm_delete_error= 0; /* Delete the table definition file */ - strmov(end,reg_ext); if (table_type && table_type != view_pseudo_hton && (table_type->discover_table || error)) { @@ -2526,7 +2532,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, */ if (mysql_file_delete(key_file_frm, path, MYF(MY_WME | MY_IGNORE_ENOENT))) - error= my_errno; + frm_delete_error= my_errno; } else if (unlikely(mysql_file_delete(key_file_frm, path, !error ? MYF(MY_WME) : @@ -2535,25 +2541,19 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, frm_delete_error= my_errno; DBUG_ASSERT(frm_delete_error); } - } - frm_was_deleted= 1; - if (thd->replication_flags & OPTION_IF_EXISTS) - log_if_exists= 1; + frm_was_deleted= 1; // We tried to delete .frm - if (frm_delete_error) - { - /* - Remember error if unexpected error from dropping the .frm file - or we got an error from ha_delete_table() - */ - if (frm_delete_error != ENOENT) + if (frm_delete_error) + { + /* Remember unexpected error from dropping the .frm file */ error= frm_delete_error; - else if (if_exists && ! error) - thd->clear_error(); + } + else + { + error= 0; // We succeeded to delete the frm + table_dropped= 1; + } } - if (likely(!error) || !frm_delete_error) - non_tmp_table_deleted= TRUE; - if (likely(!error) || non_existing_table_error(error)) { trigger_drop_executed= 1; @@ -2580,17 +2580,16 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, table_type != view_pseudo_hton && !trigger_drop_executed && !wrong_drop_sequence) { - char *end; int ferror= 0; /* Remove extension for delete */ - *(end = path + path_length - reg_ext_length) = '\0'; + *path_end= '\0'; ferror= ha_delete_table_force(thd, path, &db, &table->table_name); if (!ferror) { /* Table existed and was deleted */ - non_tmp_table_deleted= TRUE; local_non_tmp_error= 0; + table_dropped= 1; error= 0; } if (ferror <= 0) @@ -2600,7 +2599,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, /* Delete the table definition file */ if (!frm_was_deleted) { - strmov(end, reg_ext); + strmov(path_end, reg_ext); if (mysql_file_delete(key_file_frm, path, MYF(MY_WME | MY_IGNORE_ENOENT))) ferror= my_errno; @@ -2615,50 +2614,67 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, error= ferror; } - /* - Don't give an error if we are using IF EXISTS for a table that - didn't exists - */ - - if (if_exists && non_existing_table_error(error)) + if (error) { char buff[FN_REFLEN]; - int err= (drop_sequence ? ER_UNKNOWN_SEQUENCES : - ER_BAD_TABLE_ERROR); String tbl_name(buff, sizeof(buff), system_charset_info); + uint is_note= (if_exists && (was_view || wrong_drop_sequence) ? + ME_NOTE : 0); + tbl_name.length(0); tbl_name.append(&db); tbl_name.append('.'); tbl_name.append(&table->table_name); - push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, - err, ER_THD(thd, err), - tbl_name.c_ptr_safe()); + + if (!non_existing_table_error(error) || is_note) + { + /* + Error from engine already given. Here we only have to take + care about errors for trying to drop view or sequence + */ + if (was_view) + my_error(ER_IT_IS_A_VIEW, MYF(is_note), tbl_name.c_ptr_safe()); + else if (wrong_drop_sequence) + my_error(ER_NOT_SEQUENCE2, MYF(is_note), tbl_name.c_ptr_safe()); + if (is_note) + error= ENOENT; + } + else + { + not_found_errors++; + if (unknown_tables.append(tbl_name) || unknown_tables.append(',')) + { + error= 1; + goto err; + } + } + } + + /* + Don't give an error if we are using IF EXISTS for a table that + didn't exists + */ + if (if_exists && non_existing_table_error(error)) + { error= 0; local_non_tmp_error= 0; - drop_table_not_done= 1; } + non_tmp_error|= local_non_tmp_error; - if (error) - { - if (wrong_tables.length()) - wrong_tables.append(','); - wrong_tables.append(&db); - wrong_tables.append('.'); - wrong_tables.append(&table->table_name); - errors++; - } - else if (!drop_table_not_done) + if (!error && table_dropped) { PSI_CALL_drop_table_share(temporary_table_was_dropped, table->db.str, (uint)table->db.length, - table->table_name.str, (uint)table->table_name.length); + table->table_name.str, + (uint)table->table_name.length); mysql_audit_drop_table(thd, table); } - if (!dont_log_query && !drop_temporary) + if (!dont_log_query && !drop_temporary && + (!error || table_dropped || non_existing_table_error(error))) { - non_tmp_table_deleted= (if_exists ? TRUE : non_tmp_table_deleted); + non_tmp_table_deleted|= (if_exists || table_dropped); /* Don't write the database name if it is the current one (or if thd->db is NULL). @@ -2678,20 +2694,16 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists, DEBUG_SYNC(thd, "rm_table_no_locks_before_binlog"); thd->thread_specific_used= TRUE; error= 0; + err: - if (wrong_tables.length()) + if (unknown_tables.length() > 1) { - DBUG_ASSERT(errors); - if (errors == 1 && was_view) - my_error(ER_IT_IS_A_VIEW, MYF(0), wrong_tables.c_ptr_safe()); - else if (errors == 1 && drop_sequence && was_table) - my_error(ER_NOT_SEQUENCE2, MYF(0), wrong_tables.c_ptr_safe()); - else if (errors > 1 || !thd->is_error()) - my_error((drop_sequence ? ER_UNKNOWN_SEQUENCES : - ER_BAD_TABLE_ERROR), - MYF(0), wrong_tables.c_ptr_safe()); - error= 1; + uint is_note= if_exists ? ME_NOTE : 0; + unknown_tables.chop(); + my_error((drop_sequence ? ER_UNKNOWN_SEQUENCES : ER_BAD_TABLE_ERROR), + MYF(is_note), unknown_tables.c_ptr_safe()); } + error= thd->is_error(); /* We are always logging drop of temporary tables. @@ -5143,7 +5155,8 @@ int create_table_impl(THD *thd, const LEX_CSTRING &orig_db, If a table exists, it must have been pre-opened. Try looking for one in-use in THD::all_temp_tables list of TABLE_SHAREs. */ - TABLE *tmp_table= thd->find_temporary_table(db.str, table_name.str); + TABLE *tmp_table= thd->find_temporary_table(db.str, table_name.str, + THD::TMP_TABLE_ANY); if (tmp_table) {