diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-03-20 00:44:35 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-03-20 00:44:35 +0100 |
commit | 47f438675b81848700822426b28281cd3158e83b (patch) | |
tree | 080959710d878545ce6780cbd050287e8ac74938 | |
parent | 9418bd9c2167ef6a75d7d1bfaaf5e2cf94d09bae (diff) | |
download | mariadb-git-47f438675b81848700822426b28281cd3158e83b.tar.gz |
MDEV-5894 MySQL BUG#34750: Print database name in Unknown Table error message
-rw-r--r-- | mysql-test/r/drop.result | 36 | ||||
-rw-r--r-- | mysql-test/r/trigger.result | 2 | ||||
-rw-r--r-- | mysql-test/r/view.result | 4 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/r/innodb_views.result | 14 | ||||
-rw-r--r-- | mysql-test/suite/funcs_1/r/memory_views.result | 14 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_drop_view.result | 4 | ||||
-rw-r--r-- | mysql-test/t/drop.test | 37 | ||||
-rw-r--r-- | sql/sql_base.cc | 11 | ||||
-rw-r--r-- | sql/sql_view.cc | 2 |
9 files changed, 102 insertions, 22 deletions
diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index a3b7be855eb..c23ffbe327b 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -173,3 +173,39 @@ DROP TABLE t1, t1; ERROR 42000: Not unique table/alias: 't1' UNLOCK TABLES; DROP TABLE t1; +# +# BUG#34750: Print database name in Unknown Table error message +# + +# Test error message when droping table/view +DROP TABLE table1; +ERROR 42S02: Unknown table 'test.table1' +DROP TABLE table1,table2; +ERROR 42S02: Unknown table 'test.table1,test.table2' +DROP VIEW view1,view2,view3,view4; +ERROR 42S02: Unknown table 'test.view1,test.view2,test.view3,test.view4' + +DROP TABLE IF EXISTS table1; +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' +DROP VIEW IF EXISTS view1,view2,view3,view4; +Warnings: +Note 1051 Unknown table 'test.view1' +Note 1051 Unknown table 'test.view2' +Note 1051 Unknown table 'test.view3' +Note 1051 Unknown table 'test.view4' + +# Test error message when trigger does not find table +CREATE TABLE table1(a int); +CREATE TABLE table2(b int); +CREATE TRIGGER trg1 AFTER INSERT ON table1 +FOR EACH ROW +INSERT INTO table2 SELECT t.notable.*; +INSERT INTO table1 VALUES (1); +ERROR 42S02: Unknown table 't.notable' +DROP TABLE table1,table2; +# End BUG#34750 diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index b3965bef008..8bf31766031 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -1944,7 +1944,7 @@ insert into table_25411_b select new.*; select * from table_25411_a; a insert into table_25411_a values (1); -ERROR 42S02: Unknown table 'new' +ERROR 42S02: Unknown table 'test.new' select * from table_25411_a; a 1 diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 7aadf6f75f1..3817df4f440 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -201,7 +201,7 @@ c d 2 5 3 10 drop view v100; -ERROR 42S02: Unknown table 'v100' +ERROR 42S02: Unknown table 'test.v100' drop view t1; ERROR HY000: 'test.t1' is not VIEW drop table v1; @@ -2872,7 +2872,7 @@ Tables_in_test t1 v1 DROP VIEW v2,v1; -ERROR 42S02: Unknown table 'v2' +ERROR 42S02: Unknown table 'test.v2' SHOW TABLES; Tables_in_test t1 diff --git a/mysql-test/suite/funcs_1/r/innodb_views.result b/mysql-test/suite/funcs_1/r/innodb_views.result index e6d98159b39..e7523922154 100644 --- a/mysql-test/suite/funcs_1/r/innodb_views.result +++ b/mysql-test/suite/funcs_1/r/innodb_views.result @@ -21307,7 +21307,7 @@ CREATE TABLE t1 ( f1 VARCHAR(1000) ) ENGINE = innodb ; CREATE VIEW v1 AS SELECT f1 FROM t1; DROP VIEW v1; DROP VIEW v1; -ERROR 42S02: Unknown table 'v1' +ERROR 42S02: Unknown table 'test.v1' CREATE VIEW v1 AS SELECT f1 FROM t1; DROP VIEW IF EXISTS v1; DROP VIEW IF EXISTS v1; @@ -21324,31 +21324,31 @@ CREATE VIEW v1_base AS SELECT * FROM t1; CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_top ; DROP VIEW v1_top; -ERROR 42S02: Unknown table 'v1_top' +ERROR 42S02: Unknown table 'test.v1_top' CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_base ; DROP VIEW v1_base; -ERROR 42S02: Unknown table 'v1_base' +ERROR 42S02: Unknown table 'test.v1_base' DROP VIEW v1_top; CREATE VIEW v1_base AS SELECT * FROM t1; CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_top CASCADE ; DROP VIEW v1_top; -ERROR 42S02: Unknown table 'v1_top' +ERROR 42S02: Unknown table 'test.v1_top' CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_base CASCADE ; DROP VIEW v1_base; -ERROR 42S02: Unknown table 'v1_base' +ERROR 42S02: Unknown table 'test.v1_base' DROP VIEW v1_top; CREATE VIEW v1_base AS SELECT * FROM t1; CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_top RESTRICT ; DROP VIEW v1_top; -ERROR 42S02: Unknown table 'v1_top' +ERROR 42S02: Unknown table 'test.v1_top' CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_base RESTRICT ; DROP VIEW v1_base; -ERROR 42S02: Unknown table 'v1_base' +ERROR 42S02: Unknown table 'test.v1_base' DROP VIEW v1_top; Testcase 3.3.1.69, 3.3.1.70, 3.3.1.A5 diff --git a/mysql-test/suite/funcs_1/r/memory_views.result b/mysql-test/suite/funcs_1/r/memory_views.result index 21990c2bd9d..9f8ec11a7d8 100644 --- a/mysql-test/suite/funcs_1/r/memory_views.result +++ b/mysql-test/suite/funcs_1/r/memory_views.result @@ -21309,7 +21309,7 @@ CREATE TABLE t1 ( f1 VARCHAR(1000) ) ENGINE = memory ; CREATE VIEW v1 AS SELECT f1 FROM t1; DROP VIEW v1; DROP VIEW v1; -ERROR 42S02: Unknown table 'v1' +ERROR 42S02: Unknown table 'test.v1' CREATE VIEW v1 AS SELECT f1 FROM t1; DROP VIEW IF EXISTS v1; DROP VIEW IF EXISTS v1; @@ -21326,31 +21326,31 @@ CREATE VIEW v1_base AS SELECT * FROM t1; CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_top ; DROP VIEW v1_top; -ERROR 42S02: Unknown table 'v1_top' +ERROR 42S02: Unknown table 'test.v1_top' CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_base ; DROP VIEW v1_base; -ERROR 42S02: Unknown table 'v1_base' +ERROR 42S02: Unknown table 'test.v1_base' DROP VIEW v1_top; CREATE VIEW v1_base AS SELECT * FROM t1; CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_top CASCADE ; DROP VIEW v1_top; -ERROR 42S02: Unknown table 'v1_top' +ERROR 42S02: Unknown table 'test.v1_top' CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_base CASCADE ; DROP VIEW v1_base; -ERROR 42S02: Unknown table 'v1_base' +ERROR 42S02: Unknown table 'test.v1_base' DROP VIEW v1_top; CREATE VIEW v1_base AS SELECT * FROM t1; CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_top RESTRICT ; DROP VIEW v1_top; -ERROR 42S02: Unknown table 'v1_top' +ERROR 42S02: Unknown table 'test.v1_top' CREATE VIEW v1_top AS SELECT * FROM v1_base; DROP VIEW v1_base RESTRICT ; DROP VIEW v1_base; -ERROR 42S02: Unknown table 'v1_base' +ERROR 42S02: Unknown table 'test.v1_base' DROP VIEW v1_top; Testcase 3.3.1.69, 3.3.1.70, 3.3.1.A5 diff --git a/mysql-test/suite/rpl/r/rpl_drop_view.result b/mysql-test/suite/rpl/r/rpl_drop_view.result index 0688ce42bc2..70a87816e4b 100644 --- a/mysql-test/suite/rpl/r/rpl_drop_view.result +++ b/mysql-test/suite/rpl/r/rpl_drop_view.result @@ -9,9 +9,9 @@ create view v1 as select * from t1; create view v2 as select * from t2; create view v3 as select * from t3; drop view not_exist_view; -ERROR 42S02: Unknown table 'not_exist_view' +ERROR 42S02: Unknown table 'test.not_exist_view' drop view v1, not_exist_view; -ERROR 42S02: Unknown table 'not_exist_view' +ERROR 42S02: Unknown table 'test.not_exist_view' select * from v1; ERROR 42S02: Table 'test.v1' doesn't exist drop view v2, v3; diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index 2cd87b1d980..d9784bc819a 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -276,3 +276,40 @@ DROP TABLE t1, t1; UNLOCK TABLES; DROP TABLE t1; + +--echo # +--echo # BUG#34750: Print database name in Unknown Table error message +--echo # + +--echo +--echo # Test error message when droping table/view + +--error ER_BAD_TABLE_ERROR +DROP TABLE table1; +--error ER_BAD_TABLE_ERROR +DROP TABLE table1,table2; +--error ER_BAD_TABLE_ERROR +DROP VIEW view1,view2,view3,view4; +--echo +DROP TABLE IF EXISTS table1; +DROP TABLE IF EXISTS table1,table2; +DROP VIEW IF EXISTS view1,view2,view3,view4; + +--echo +--echo # Test error message when trigger does not find table + +CREATE TABLE table1(a int); +CREATE TABLE table2(b int); + +# Database name is only available (for printing) if specified in +# the trigger definition +CREATE TRIGGER trg1 AFTER INSERT ON table1 +FOR EACH ROW + INSERT INTO table2 SELECT t.notable.*; + +--error ER_BAD_TABLE_ERROR +INSERT INTO table1 VALUES (1); + +DROP TABLE table1,table2; + +--echo # End BUG#34750 diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6c6cda6f3f2..9c82806a461 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -8322,9 +8322,16 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, meaningful message than ER_BAD_TABLE_ERROR. */ if (!table_name) - my_message(ER_NO_TABLES_USED, ER(ER_NO_TABLES_USED), MYF(0)); + my_error(ER_NO_TABLES_USED, MYF(0)); + else if (!db_name && !thd->db) + my_error(ER_NO_DB_ERROR, MYF(0)); else - my_error(ER_BAD_TABLE_ERROR, MYF(0), table_name); + { + char name[FN_REFLEN]; + my_snprintf(name, sizeof(name), "%s.%s", + db_name ? db_name : thd->db, table_name); + my_error(ER_BAD_TABLE_ERROR, MYF(0), name); + } DBUG_RETURN(TRUE); } diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 4ca165a6d19..a18193c6eb6 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1652,7 +1652,7 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode) { if (non_existant_views.length()) non_existant_views.append(','); - non_existant_views.append(String(view->table_name,system_charset_info)); + non_existant_views.append(name); } else { |