summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2014-01-31 12:06:28 +0200
committerMichael Widenius <monty@askmonty.org>2014-01-31 12:06:28 +0200
commit43f6e118fef843dd02821da3a24089b679fd30a3 (patch)
treec852245ce9eb5dd5a8d2f8f3dde92b0bf7b111e6 /mysql-test
parent2410ecac602254a1fa4eaaa3812d782eaf7f7e32 (diff)
downloadmariadb-git-43f6e118fef843dd02821da3a24089b679fd30a3.tar.gz
Fixes for CREATE_OR_REPLACE
- MDEV-5587 Server crashes in Locked_tables_list::restore_lock on CREATE OR REPLACE .. SELECT under LOCK - MDEV-5586 Assertion `share->tdc.all_tables.is_empty() || remove_type != TDC_RT_REMOVE_ALL' fails in tdc_remove_table - MDEV-5588 Strange error on CREATE OR REPLACE table over an existing view mysql-test/r/create_or_replace.result: Added test cases mysql-test/r/lowercase_view.result: New error message mysql-test/r/merge.result: New error message mysql-test/r/multi_update.result: New error message mysql-test/r/subselect.result: New error message mysql-test/r/subselect_exists_to_in.result: New error message mysql-test/r/subselect_no_mat.result: New error message mysql-test/r/subselect_no_opts.result: New error message mysql-test/r/subselect_no_scache.result: New error message mysql-test/r/subselect_no_semijoin.result: New error message mysql-test/r/view.result: New error message mysql-test/suite/funcs_1/r/myisam_views-big.result: New error message mysql-test/t/create_or_replace.test: New tests mysql-test/t/view.test: New error message sql/share/errmsg-utf8.txt: Added new error message sql/sql_base.cc: Updated error message Do an automatic UNLOCK TABLES if we don't have any locked tables (safety fix) sql/sql_db.cc: Updated arguments sql/sql_load.cc: New error message sql/sql_parse.cc: Check that we are not using a table we are dropping and re-creating sql/sql_table.cc: Added parameter to mysql_rm_table_no_locks() to not automaticly do UNLOCK TABLES Added better error message if trying to drop a view with DROP TABLE Don't try to create something we select from sql/sql_table.h: Updated prototypes
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/create_or_replace.result48
-rw-r--r--mysql-test/r/lowercase_view.result30
-rw-r--r--mysql-test/r/merge.result72
-rw-r--r--mysql-test/r/multi_update.result6
-rw-r--r--mysql-test/r/subselect.result14
-rw-r--r--mysql-test/r/subselect_exists_to_in.result14
-rw-r--r--mysql-test/r/subselect_no_mat.result14
-rw-r--r--mysql-test/r/subselect_no_opts.result14
-rw-r--r--mysql-test/r/subselect_no_scache.result14
-rw-r--r--mysql-test/r/subselect_no_semijoin.result14
-rw-r--r--mysql-test/r/view.result32
-rw-r--r--mysql-test/suite/funcs_1/r/myisam_views-big.result2
-rw-r--r--mysql-test/t/create_or_replace.test47
-rw-r--r--mysql-test/t/view.test2
14 files changed, 197 insertions, 126 deletions
diff --git a/mysql-test/r/create_or_replace.result b/mysql-test/r/create_or_replace.result
index 42a3d1fe17c..e1586ff211c 100644
--- a/mysql-test/r/create_or_replace.result
+++ b/mysql-test/r/create_or_replace.result
@@ -1,4 +1,4 @@
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES(1),(2),(3);
#
@@ -97,13 +97,23 @@ CREATE TEMPORARY TABLE t1 AS SELECT a FROM t2;
CREATE TEMPORARY TABLE IF NOT EXISTS t1(a int, b int) SELECT 1,2 FROM t2;
Warnings:
Note 1050 Table 't1' already exists
-create or replace table t1 as select 1;
-show create table t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a int);
+CREATE OR REPLACE TABLE t1 AS SELECT 1;
+SHOW CREATE TABLE t1;
Table Create Table
-t1 CREATE TEMPORARY TABLE `t1` (
- `a` int(11) DEFAULT NULL
+t1 CREATE TABLE `t1` (
+ `1` int(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
+create table t1 (a int);
+create or replace table t1 as select * from t1;
+ERROR HY000: Table 't1' is specified twice, both as a target for 'CREATE' and as a separate source for data
+create or replace table t1 as select a from (select a from t1) as t3;
+ERROR HY000: Table 't1' is specified twice, both as a target for 'CREATE' and as a separate source for data
+create or replace table t1 as select a from t2 where t2.a in (select a from t1);
+ERROR HY000: Table 't1' is specified twice, both as a target for 'CREATE' and as a separate source for data
+drop table t1;
#
# Testing with normal tables
#
@@ -191,6 +201,15 @@ SELECT * FROM t1 as t1_read;
ERROR HY000: Table 't1_read' was not locked with LOCK TABLES
DROP TABLE t1;
UNLOCK TABLES;
+CREATE OR REPLACE TABLE t1 (a int);
+LOCK TABLE t1 WRITE;
+CREATE OR REPLACE TABLE t1 AS SELECT 1;
+SELECT * from t1;
+1
+1
+SELECT * from t2;
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+DROP TABLE t1;
#
# Test also with InnoDB (transactional engine)
#
@@ -253,6 +272,21 @@ t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+create or replace table t1 like t2;
+create or replace table t1 like t1;
+ERROR 42000: Not unique table/alias: 't1'
+drop table t1;
+CREATE TEMPORARY TABLE t1 like t2;
+CREATE OR REPLACE TABLE t1 like t1;
+ERROR 42000: Not unique table/alias: 't1'
+CREATE OR REPLACE TABLE t1 like t1;
+ERROR 42000: Not unique table/alias: 't1'
+drop table t1;
+CREATE TEMPORARY TABLE t1 like t2;
+CREATE OR REPLACE TEMPORARY TABLE t3 like t1;
+CREATE OR REPLACE TEMPORARY TABLE t3 like t3;
+ERROR 42000: Not unique table/alias: 't3'
+drop table t1,t3;
#
# Test with prepared statements
#
@@ -286,8 +320,8 @@ create table if not exists t1 (a int);
Warnings:
Note 1050 Table 't1' already exists
create or replace table t1 (a int);
-ERROR 42S02: Unknown table 'test.t1'
+ERROR 42S02: 'test.t1' is a view
drop table t1;
-ERROR 42S02: Unknown table 'test.t1'
+ERROR 42S02: 'test.t1' is a view
drop view t1;
DROP TABLE t2;
diff --git a/mysql-test/r/lowercase_view.result b/mysql-test/r/lowercase_view.result
index 33c87ec101c..f43c39c4fc1 100644
--- a/mysql-test/r/lowercase_view.result
+++ b/mysql-test/r/lowercase_view.result
@@ -20,13 +20,13 @@ ERROR HY000: The definition of table 'v1Aa' prevents operation UPDATE on table '
update v2Aa set col1 = (select max(col1) from t1Aa);
ERROR HY000: The definition of table 'v2Aa' prevents operation UPDATE on table 'v2Aa'.
update v2aA set col1 = (select max(col1) from v2Aa);
-ERROR HY000: You can't specify target table 'v2aA' for update in FROM clause
+ERROR HY000: Table 'v2aA' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update v2aA,t2Aa set v2Aa.col1 = (select max(col1) from v1aA) where v2aA.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v1aA' prevents operation UPDATE on table 'v2aA'.
update t1aA,t2Aa set t1Aa.col1 = (select max(col1) from v1Aa) where t1aA.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v1Aa' prevents operation UPDATE on table 't1aA'.
update v1aA,t2Aa set v1Aa.col1 = (select max(col1) from v1aA) where v1Aa.col1 = t2aA.col1;
-ERROR HY000: You can't specify target table 'v1aA' for update in FROM clause
+ERROR HY000: Table 'v1aA' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t2Aa,v2Aa set v2aA.col1 = (select max(col1) from v1aA) where v2Aa.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v1aA' prevents operation UPDATE on table 't2Aa'.
update t2Aa,t1Aa set t1aA.col1 = (select max(col1) from v1Aa) where t1Aa.col1 = t2aA.col1;
@@ -36,17 +36,17 @@ ERROR HY000: The definition of table 'v1aA' prevents operation UPDATE on table '
update v2aA,t2Aa set v2Aa.col1 = (select max(col1) from t1aA) where v2aA.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v2aA' prevents operation UPDATE on table 'v2aA'.
update t1Aa,t2Aa set t1aA.col1 = (select max(col1) from t1Aa) where t1aA.col1 = t2aA.col1;
-ERROR HY000: You can't specify target table 't1Aa' for update in FROM clause
+ERROR HY000: Table 't1Aa' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update v1aA,t2Aa set v1Aa.col1 = (select max(col1) from t1Aa) where v1aA.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v1aA' prevents operation UPDATE on table 'v1aA'.
update t2Aa,v2Aa set v2aA.col1 = (select max(col1) from t1aA) where v2Aa.col1 = t2aA.col1;
-ERROR HY000: You can't specify target table 't2Aa' for update in FROM clause
+ERROR HY000: Table 't2Aa' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t2Aa,t1Aa set t1aA.col1 = (select max(col1) from t1Aa) where t1aA.col1 = t2aA.col1;
-ERROR HY000: You can't specify target table 't2Aa' for update in FROM clause
+ERROR HY000: Table 't2Aa' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t2Aa,v1Aa set v1aA.col1 = (select max(col1) from t1Aa) where v1Aa.col1 = t2aA.col1;
-ERROR HY000: You can't specify target table 't2Aa' for update in FROM clause
+ERROR HY000: Table 't2Aa' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update v2aA,t2Aa set v2Aa.col1 = (select max(col1) from v2aA) where v2Aa.col1 = t2aA.col1;
-ERROR HY000: You can't specify target table 'v2aA' for update in FROM clause
+ERROR HY000: Table 'v2aA' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t1aA,t2Aa set t1Aa.col1 = (select max(col1) from v2aA) where t1aA.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v2aA' prevents operation UPDATE on table 't1aA'.
update v1aA,t2Aa set v1Aa.col1 = (select max(col1) from v2Aa) where v1aA.col1 = t2aA.col1;
@@ -64,27 +64,27 @@ ERROR HY000: The definition of table 'v3aA' prevents operation UPDATE on table '
update v3aA set v3Aa.col1 = (select max(col1) from v2aA);
ERROR HY000: The definition of table 'v2aA' prevents operation UPDATE on table 'v3aA'.
update v3aA set v3Aa.col1 = (select max(col1) from v3aA);
-ERROR HY000: You can't specify target table 'v3aA' for update in FROM clause
+ERROR HY000: Table 'v3aA' is specified twice, both as a target for 'UPDATE' and as a separate source for data
delete from v2Aa where col1 = (select max(col1) from v1Aa);
ERROR HY000: The definition of table 'v1Aa' prevents operation DELETE on table 'v2Aa'.
delete from v2aA where col1 = (select max(col1) from t1Aa);
ERROR HY000: The definition of table 'v2aA' prevents operation DELETE on table 'v2aA'.
delete from v2Aa where col1 = (select max(col1) from v2aA);
-ERROR HY000: You can't specify target table 'v2Aa' for update in FROM clause
+ERROR HY000: Table 'v2Aa' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete v2Aa from v2aA,t2Aa where (select max(col1) from v1aA) > 0 and v2Aa.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v1aA' prevents operation DELETE on table 'v2aA'.
delete t1aA from t1Aa,t2Aa where (select max(col1) from v1Aa) > 0 and t1aA.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v1Aa' prevents operation DELETE on table 't1Aa'.
delete v1aA from v1Aa,t2Aa where (select max(col1) from v1aA) > 0 and v1Aa.col1 = t2aA.col1;
-ERROR HY000: You can't specify target table 'v1Aa' for update in FROM clause
+ERROR HY000: Table 'v1Aa' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete v2aA from v2Aa,t2Aa where (select max(col1) from t1Aa) > 0 and v2aA.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v2Aa' prevents operation DELETE on table 'v2Aa'.
delete t1aA from t1Aa,t2Aa where (select max(col1) from t1aA) > 0 and t1Aa.col1 = t2aA.col1;
-ERROR HY000: You can't specify target table 't1Aa' for update in FROM clause
+ERROR HY000: Table 't1Aa' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete v1aA from v1Aa,t2Aa where (select max(col1) from t1aA) > 0 and v1aA.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v1Aa' prevents operation DELETE on table 'v1Aa'.
delete v2Aa from v2aA,t2Aa where (select max(col1) from v2Aa) > 0 and v2aA.col1 = t2aA.col1;
-ERROR HY000: You can't specify target table 'v2aA' for update in FROM clause
+ERROR HY000: Table 'v2aA' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete t1Aa from t1aA,t2Aa where (select max(col1) from v2Aa) > 0 and t1Aa.col1 = t2aA.col1;
ERROR HY000: The definition of table 'v2Aa' prevents operation DELETE on table 't1aA'.
delete v1Aa from v1aA,t2Aa where (select max(col1) from v2aA) > 0 and v1Aa.col1 = t2aA.col1;
@@ -98,15 +98,15 @@ ERROR HY000: The definition of table 'v1aA' prevents operation INSERT on table '
insert into v2Aa values ((select max(col1) from t1Aa));
ERROR HY000: The definition of table 'v2Aa' prevents operation INSERT on table 'v2Aa'.
insert into t1aA values ((select max(col1) from t1Aa));
-ERROR HY000: You can't specify target table 't1aA' for update in FROM clause
+ERROR HY000: Table 't1aA' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into v2aA values ((select max(col1) from t1aA));
ERROR HY000: The definition of table 'v2aA' prevents operation INSERT on table 'v2aA'.
insert into v2Aa values ((select max(col1) from v2aA));
-ERROR HY000: You can't specify target table 'v2Aa' for update in FROM clause
+ERROR HY000: Table 'v2Aa' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into t1Aa values ((select max(col1) from v2Aa));
ERROR HY000: The definition of table 'v2Aa' prevents operation INSERT on table 't1Aa'.
insert into v2aA values ((select max(col1) from v2Aa));
-ERROR HY000: You can't specify target table 'v2aA' for update in FROM clause
+ERROR HY000: Table 'v2aA' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into v3Aa (col1) values ((select max(col1) from v1Aa));
ERROR HY000: The definition of table 'v1Aa' prevents operation INSERT on table 'v3Aa'.
insert into v3aA (col1) values ((select max(col1) from t1aA));
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 0feb1cdce98..89aaf48219e 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -3657,85 +3657,85 @@ insert into tmp (b) values (1);
insert into t1 (a) values (1);
insert into t3 (b) values (1);
insert into m1 (a) values ((select max(a) from m1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from m2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from t1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from t2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from t3, m1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from t3, m2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from t3, t1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from t3, t2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from tmp, m1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from tmp, m2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from tmp, t1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from tmp, t2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into m1 (a) values ((select max(a) from v1));
ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'm1'.
insert into m1 (a) values ((select max(a) from tmp, v1));
ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'm1'.
update m1 set a = ((select max(a) from m1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from m2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from t1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from t2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from t3, m1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from t3, m2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from t3, t1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from t3, t2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from tmp, m1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from tmp, m2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from tmp, t1));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from tmp, t2));
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update m1 set a = ((select max(a) from v1));
ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'm1'.
update m1 set a = ((select max(a) from tmp, v1));
ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'm1'.
delete from m1 where a = (select max(a) from m1);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from m2);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from t1);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from t2);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from t3, m1);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from t3, m2);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from t3, t1);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from t3, t2);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from tmp, m1);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from tmp, m2);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from tmp, t1);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from tmp, t2);
-ERROR HY000: You can't specify target table 'm1' for update in FROM clause
+ERROR HY000: Table 'm1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from m1 where a = (select max(a) from v1);
ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'm1'.
delete from m1 where a = (select max(a) from tmp, v1);
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index f49998da5f4..ff0aa828636 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -439,9 +439,9 @@ drop table t1, t2, t3;
create table t1 (col1 int);
create table t2 (col1 int);
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
delete t1 from t1,t2 where t1.col1 < (select max(col1) from t1) and t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
drop table t1,t2;
create table t1 (
aclid bigint not null primary key,
@@ -457,7 +457,7 @@ drop table t1, t2;
create table t1(a int);
create table t2(a int);
delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
drop table t1, t2;
create table t1 ( c char(8) not null ) engine=innodb;
insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9');
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index fc98607e38a..effa77a5eb4 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -579,7 +579,7 @@ a b
1 11
2 12
update t1 set b= (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t1 set b= (select b from t2);
ERROR 21000: Subquery returns more than 1 row
update t1 set b= (select b from t2 where t1.a = t2.a);
@@ -602,7 +602,7 @@ select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
delete from t1 where b in (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete from t1 where b = (select b from t2 where t1.a = t2.a);
@@ -628,7 +628,7 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: You can't specify target table 't12' for update in FROM clause
+ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
@@ -647,7 +647,7 @@ create table t3 (b int);
insert into t2 values (1);
insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
@@ -697,7 +697,7 @@ insert into t3 values (1),(2);
select * from t1;
x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@@ -765,9 +765,9 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id
2
INSERT INTO t2 VALUES ((SELECT * FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t2 VALUES ((SELECT id FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
SELECT * FROM t2;
id
1
diff --git a/mysql-test/r/subselect_exists_to_in.result b/mysql-test/r/subselect_exists_to_in.result
index a70e6df3d00..bc9db36c8ce 100644
--- a/mysql-test/r/subselect_exists_to_in.result
+++ b/mysql-test/r/subselect_exists_to_in.result
@@ -583,7 +583,7 @@ a b
1 11
2 12
update t1 set b= (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t1 set b= (select b from t2);
ERROR 21000: Subquery returns more than 1 row
update t1 set b= (select b from t2 where t1.a = t2.a);
@@ -606,7 +606,7 @@ select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
delete from t1 where b in (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete from t1 where b = (select b from t2 where t1.a = t2.a);
@@ -632,7 +632,7 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: You can't specify target table 't12' for update in FROM clause
+ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
@@ -651,7 +651,7 @@ create table t3 (b int);
insert into t2 values (1);
insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
@@ -701,7 +701,7 @@ insert into t3 values (1),(2);
select * from t1;
x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@@ -769,9 +769,9 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id
2
INSERT INTO t2 VALUES ((SELECT * FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t2 VALUES ((SELECT id FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
SELECT * FROM t2;
id
1
diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result
index 16f67820e0e..975d90b8358 100644
--- a/mysql-test/r/subselect_no_mat.result
+++ b/mysql-test/r/subselect_no_mat.result
@@ -586,7 +586,7 @@ a b
1 11
2 12
update t1 set b= (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t1 set b= (select b from t2);
ERROR 21000: Subquery returns more than 1 row
update t1 set b= (select b from t2 where t1.a = t2.a);
@@ -609,7 +609,7 @@ select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
delete from t1 where b in (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete from t1 where b = (select b from t2 where t1.a = t2.a);
@@ -635,7 +635,7 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: You can't specify target table 't12' for update in FROM clause
+ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
@@ -654,7 +654,7 @@ create table t3 (b int);
insert into t2 values (1);
insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
@@ -704,7 +704,7 @@ insert into t3 values (1),(2);
select * from t1;
x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@@ -772,9 +772,9 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id
2
INSERT INTO t2 VALUES ((SELECT * FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t2 VALUES ((SELECT id FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
SELECT * FROM t2;
id
1
diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result
index bc2cc71b0fa..f9ea3c45ee3 100644
--- a/mysql-test/r/subselect_no_opts.result
+++ b/mysql-test/r/subselect_no_opts.result
@@ -582,7 +582,7 @@ a b
1 11
2 12
update t1 set b= (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t1 set b= (select b from t2);
ERROR 21000: Subquery returns more than 1 row
update t1 set b= (select b from t2 where t1.a = t2.a);
@@ -605,7 +605,7 @@ select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
delete from t1 where b in (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete from t1 where b = (select b from t2 where t1.a = t2.a);
@@ -631,7 +631,7 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: You can't specify target table 't12' for update in FROM clause
+ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
@@ -650,7 +650,7 @@ create table t3 (b int);
insert into t2 values (1);
insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
@@ -700,7 +700,7 @@ insert into t3 values (1),(2);
select * from t1;
x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@@ -768,9 +768,9 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id
2
INSERT INTO t2 VALUES ((SELECT * FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t2 VALUES ((SELECT id FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
SELECT * FROM t2;
id
1
diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result
index 40a63afb1c6..2bc182ac6e9 100644
--- a/mysql-test/r/subselect_no_scache.result
+++ b/mysql-test/r/subselect_no_scache.result
@@ -585,7 +585,7 @@ a b
1 11
2 12
update t1 set b= (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t1 set b= (select b from t2);
ERROR 21000: Subquery returns more than 1 row
update t1 set b= (select b from t2 where t1.a = t2.a);
@@ -608,7 +608,7 @@ select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
delete from t1 where b in (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete from t1 where b = (select b from t2 where t1.a = t2.a);
@@ -634,7 +634,7 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: You can't specify target table 't12' for update in FROM clause
+ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
@@ -653,7 +653,7 @@ create table t3 (b int);
insert into t2 values (1);
insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
@@ -703,7 +703,7 @@ insert into t3 values (1),(2);
select * from t1;
x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@@ -771,9 +771,9 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id
2
INSERT INTO t2 VALUES ((SELECT * FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t2 VALUES ((SELECT id FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
SELECT * FROM t2;
id
1
diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result
index 1fc2d98c0e8..a41c7636038 100644
--- a/mysql-test/r/subselect_no_semijoin.result
+++ b/mysql-test/r/subselect_no_semijoin.result
@@ -582,7 +582,7 @@ a b
1 11
2 12
update t1 set b= (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t1 set b= (select b from t2);
ERROR 21000: Subquery returns more than 1 row
update t1 set b= (select b from t2 where t1.a = t2.a);
@@ -605,7 +605,7 @@ select * from t1 where b = (select b from t2 where t1.a = t2.a);
a b
2 12
delete from t1 where b in (select b from t1);
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete from t1 where b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete from t1 where b = (select b from t2 where t1.a = t2.a);
@@ -631,7 +631,7 @@ a b
22 11
2 12
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
-ERROR HY000: You can't specify target table 't12' for update in FROM clause
+ERROR HY000: Table 't12' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
ERROR 21000: Subquery returns more than 1 row
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
@@ -650,7 +650,7 @@ create table t3 (b int);
insert into t2 values (1);
insert into t3 values (1),(2);
INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
ERROR 21000: Subquery returns more than 1 row
INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
@@ -700,7 +700,7 @@ insert into t3 values (1),(2);
select * from t1;
x y
replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
ERROR 21000: Subquery returns more than 1 row
replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
@@ -768,9 +768,9 @@ SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
id
2
INSERT INTO t2 VALUES ((SELECT * FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO t2 VALUES ((SELECT id FROM t2));
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'INSERT' and as a separate source for data
SELECT * FROM t2;
id
1
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index a926f975009..046c0056de3 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -205,7 +205,7 @@ ERROR 42S02: Unknown table 'v100'
drop view t1;
ERROR HY000: 'test.t1' is not VIEW
drop table v1;
-ERROR 42S02: Unknown table 'test.v1'
+ERROR 42S02: 'test.v1' is a view
drop view v1,v2;
drop table t1;
create table t1 (a int);
@@ -931,13 +931,13 @@ ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v2
update v2 set col1 = (select max(col1) from t1);
ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v2'.
update v2 set col1 = (select max(col1) from v2);
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: Table 'v2' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v2'.
update t1,t2 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't1'.
update v1,t2 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v1' for update in FROM clause
+ERROR HY000: Table 'v1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t2,v2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2'.
update t2,t1 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
@@ -947,17 +947,17 @@ ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 't2
update v2,t2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v2'.
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update v1,t2 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1;
ERROR HY000: The definition of table 'v1' prevents operation UPDATE on table 'v1'.
update t2,v2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t2,t1 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t2,v1 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't2' for update in FROM clause
+ERROR HY000: Table 't2' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update v2,t2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: Table 'v2' is specified twice, both as a target for 'UPDATE' and as a separate source for data
update t1,t2 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1;
ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 't1'.
update v1,t2 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1;
@@ -975,27 +975,27 @@ ERROR HY000: The definition of table 'v3' prevents operation UPDATE on table 'v3
update v3 set v3.col1 = (select max(col1) from v2);
ERROR HY000: The definition of table 'v2' prevents operation UPDATE on table 'v3'.
update v3 set v3.col1 = (select max(col1) from v3);
-ERROR HY000: You can't specify target table 'v3' for update in FROM clause
+ERROR HY000: Table 'v3' is specified twice, both as a target for 'UPDATE' and as a separate source for data
delete from v2 where col1 = (select max(col1) from v1);
ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v2'.
delete from v2 where col1 = (select max(col1) from t1);
ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v2'.
delete from v2 where col1 = (select max(col1) from v2);
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: Table 'v2' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1;
ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v2'.
delete t1 from t1,t2 where (select max(col1) from v1) > 0 and t1.col1 = t2.col1;
ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 't1'.
delete v1 from v1,t2 where (select max(col1) from v1) > 0 and v1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v1' for update in FROM clause
+ERROR HY000: Table 'v1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete v2 from v2,t2 where (select max(col1) from t1) > 0 and v2.col1 = t2.col1;
ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 'v2'.
delete t1 from t1,t2 where (select max(col1) from t1) > 0 and t1.col1 = t2.col1;
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete v1 from v1,t2 where (select max(col1) from t1) > 0 and v1.col1 = t2.col1;
ERROR HY000: The definition of table 'v1' prevents operation DELETE on table 'v1'.
delete v2 from v2,t2 where (select max(col1) from v2) > 0 and v2.col1 = t2.col1;
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: Table 'v2' is specified twice, both as a target for 'DELETE' and as a separate source for data
delete t1 from t1,t2 where (select max(col1) from v2) > 0 and t1.col1 = t2.col1;
ERROR HY000: The definition of table 'v2' prevents operation DELETE on table 't1'.
delete v1 from v1,t2 where (select max(col1) from v2) > 0 and v1.col1 = t2.col1;
@@ -1009,15 +1009,15 @@ ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v2
insert into v2 values ((select max(col1) from t1));
ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2'.
insert into t1 values ((select max(col1) from t1));
-ERROR HY000: You can't specify target table 't1' for update in FROM clause
+ERROR HY000: Table 't1' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into v2 values ((select max(col1) from t1));
ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 'v2'.
insert into v2 values ((select max(col1) from v2));
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: Table 'v2' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into t1 values ((select max(col1) from v2));
ERROR HY000: The definition of table 'v2' prevents operation INSERT on table 't1'.
insert into v2 values ((select max(col1) from v2));
-ERROR HY000: You can't specify target table 'v2' for update in FROM clause
+ERROR HY000: Table 'v2' is specified twice, both as a target for 'INSERT' and as a separate source for data
insert into v3 (col1) values ((select max(col1) from v1));
ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'v3'.
insert into v3 (col1) values ((select max(col1) from t1));
diff --git a/mysql-test/suite/funcs_1/r/myisam_views-big.result b/mysql-test/suite/funcs_1/r/myisam_views-big.result
index 39782f8d2c5..55704135530 100644
--- a/mysql-test/suite/funcs_1/r/myisam_views-big.result
+++ b/mysql-test/suite/funcs_1/r/myisam_views-big.result
@@ -8400,7 +8400,7 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT * FROM test.tb2 limit 2' at line 1
CREATE OR REPLACE TEMPORARY VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2 ;
-ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'TEMPORARY VIEW test.v1 AS
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'VIEW test.v1 AS
SELECT * FROM test.tb2 limit 2' at line 1
Drop view if exists test.v1 ;
Use test;
diff --git a/mysql-test/t/create_or_replace.test b/mysql-test/t/create_or_replace.test
index b776be23b08..7d6841ab9d2 100644
--- a/mysql-test/t/create_or_replace.test
+++ b/mysql-test/t/create_or_replace.test
@@ -4,7 +4,7 @@
--source include/have_innodb.inc
--disable_warnings
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
--enable_warnings
#
@@ -90,10 +90,21 @@ SHOW CREATE TABLE t1;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 AS SELECT a FROM t2;
CREATE TEMPORARY TABLE IF NOT EXISTS t1(a int, b int) SELECT 1,2 FROM t2;
-create or replace table t1 as select 1;
-show create table t1;
DROP TABLE t1;
+CREATE TABLE t1 (a int);
+CREATE OR REPLACE TABLE t1 AS SELECT 1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+create table t1 (a int);
+--error ER_UPDATE_TABLE_USED
+create or replace table t1 as select * from t1;
+--error ER_UPDATE_TABLE_USED
+create or replace table t1 as select a from (select a from t1) as t3;
+--error ER_UPDATE_TABLE_USED
+create or replace table t1 as select a from t2 where t2.a in (select a from t1);
+drop table t1;
--echo #
--echo # Testing with normal tables
@@ -156,6 +167,14 @@ SELECT * FROM t1 as t1_read;
DROP TABLE t1;
UNLOCK TABLES;
+CREATE OR REPLACE TABLE t1 (a int);
+LOCK TABLE t1 WRITE;
+CREATE OR REPLACE TABLE t1 AS SELECT 1;
+SELECT * from t1;
+--error ER_TABLE_NOT_LOCKED
+SELECT * from t2;
+DROP TABLE t1;
+
--echo #
--echo # Test also with InnoDB (transactional engine)
--echo #
@@ -201,6 +220,24 @@ unlock tables;
show create table t1;
drop table t1;
+create or replace table t1 like t2;
+--error ER_NONUNIQ_TABLE
+create or replace table t1 like t1;
+drop table t1;
+
+CREATE TEMPORARY TABLE t1 like t2;
+--error ER_NONUNIQ_TABLE
+CREATE OR REPLACE TABLE t1 like t1;
+--error ER_NONUNIQ_TABLE
+CREATE OR REPLACE TABLE t1 like t1;
+drop table t1;
+
+CREATE TEMPORARY TABLE t1 like t2;
+CREATE OR REPLACE TEMPORARY TABLE t3 like t1;
+--error ER_NONUNIQ_TABLE
+CREATE OR REPLACE TEMPORARY TABLE t3 like t3;
+drop table t1,t3;
+
--echo #
--echo # Test with prepared statements
--echo #
@@ -222,9 +259,9 @@ drop table t1;
create view t1 as select 1;
create table if not exists t1 (a int);
---error ER_BAD_TABLE_ERROR
+--error ER_IT_IS_A_VIEW
create or replace table t1 (a int);
---error ER_BAD_TABLE_ERROR
+--error ER_IT_IS_A_VIEW
drop table t1;
drop view t1;
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 5cb9d920c0c..ae8a8e11f79 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -141,7 +141,7 @@ drop view v100;
drop view t1;
# try to drop VIEW with DROP TABLE
--- error ER_BAD_TABLE_ERROR
+-- error ER_IT_IS_A_VIEW
drop table v1;
# try to drop table with DROP VIEW