Commit dfb41fdd authored by Monty's avatar Monty

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
parent 346d10a9
......@@ -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;
......
......@@ -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;
......
......@@ -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:
......
......@@ -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;
......
......@@ -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'
......
--source include/have_innodb.inc
call mtr.add_suppression("table or database name 'abc`def'");
# Initialise
......
This diff is collapsed.
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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";
......
......@@ -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))|
......
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',
......
......@@ -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`;
......
......@@ -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 */
--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
......@@ -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);
......
......@@ -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;
......
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;
......
......@@ -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');
......
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;
......
......@@ -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;
......
......@@ -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;
......
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'
......
This diff is collapsed.
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