Commit 47f43867 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5894 MySQL BUG#34750: Print database name in Unknown Table error message

parent 9418bd9c
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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
......@@ -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);
}
......
......@@ -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
{
......
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