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
This commit is contained in:
parent
2410ecac60
commit
43f6e118fe
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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');
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -2140,13 +2140,9 @@ ER_INSERT_INFO
|
||||
spa "Registros: %ld Duplicados: %ld Peligros: %ld"
|
||||
swe "Rader: %ld Dubletter: %ld Varningar: %ld"
|
||||
ukr "Записів: %ld Дублікатів: %ld Застережень: %ld"
|
||||
ER_UPDATE_TABLE_USED
|
||||
eng "You can't specify target table '%-.192s' for update in FROM clause"
|
||||
ger "Die Verwendung der zu aktualisierenden Zieltabelle '%-.192s' ist in der FROM-Klausel nicht zulässig."
|
||||
jpn "FROM句にある表 '%-.192s' はUPDATEの対象にできません。"
|
||||
rus "Не допускается указание таблицы '%-.192s' в списке таблиц FROM для внесения в нее изменений"
|
||||
swe "INSERT-table '%-.192s' får inte finnas i FROM tabell-listan"
|
||||
ukr "Таблиця '%-.192s' що змінюється не дозволена у переліку таблиць FROM"
|
||||
ER_UPDATE_TABLE_USED
|
||||
eng "Table '%-.192s' is specified twice, both as a target for '%s' and as a separate source for data"
|
||||
swe "Table '%-.192s' är använd två gånger. Både för '%s' och för att hämta data"
|
||||
ER_NO_SUCH_THREAD
|
||||
cze "Neznámá identifikace threadu: %lu"
|
||||
dan "Ukendt tråd id: %lu"
|
||||
@ -7089,3 +7085,5 @@ ER_CHANGE_SLAVE_PARALLEL_THREADS_ACTIVE
|
||||
eng "Cannot change @@slave_parallel_threads while another change is in progress"
|
||||
ER_PRIOR_COMMIT_FAILED
|
||||
eng "Commit failed due to failure of an earlier commit on which this one depends"
|
||||
ER_IT_IS_A_VIEW 42S02
|
||||
eng "'%-.192s' is a view"
|
||||
|
@ -1483,7 +1483,7 @@ void update_non_unique_table_error(TABLE_LIST *update,
|
||||
return;
|
||||
}
|
||||
}
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), update->alias);
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), update->alias, operation);
|
||||
}
|
||||
|
||||
|
||||
@ -2839,6 +2839,10 @@ unlink_all_closed_tables(THD *thd, MYSQL_LOCK *lock, size_t reopen_count)
|
||||
m_locked_tables_count--;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no tables left, do an automatic UNLOCK TABLES */
|
||||
if (thd->lock && thd->lock->table_count == 0)
|
||||
unlock_locked_tables(thd);
|
||||
}
|
||||
|
||||
|
||||
|
@ -829,7 +829,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
|
||||
thd->push_internal_handler(&err_handler);
|
||||
if (!thd->killed &&
|
||||
!(tables &&
|
||||
mysql_rm_table_no_locks(thd, tables, true, false, true, true)))
|
||||
mysql_rm_table_no_locks(thd, tables, true, false, true, true, false)))
|
||||
{
|
||||
/*
|
||||
We temporarily disable the binary log while dropping the objects
|
||||
|
@ -258,7 +258,8 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
||||
*/
|
||||
if (unique_table(thd, table_list, table_list->next_global, 0))
|
||||
{
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name);
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->table_name,
|
||||
"LOAD DATA");
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
|
||||
|
@ -2957,8 +2957,24 @@ case SQLCOM_PREPARE:
|
||||
/* Got error or warning. Set res to 1 if error */
|
||||
if (!(res= thd->is_error()))
|
||||
my_ok(thd); // CREATE ... IF NOT EXISTS
|
||||
goto end_with_restore_list;
|
||||
}
|
||||
|
||||
/* Ensure we don't try to create something from which we select from */
|
||||
if ((create_info.options & HA_LEX_CREATE_REPLACE) &&
|
||||
!create_info.tmp_table())
|
||||
{
|
||||
TABLE_LIST *duplicate;
|
||||
if ((duplicate= unique_table(thd, lex->query_tables,
|
||||
lex->query_tables->next_global,
|
||||
0)))
|
||||
{
|
||||
update_non_unique_table_error(lex->query_tables, "CREATE",
|
||||
duplicate);
|
||||
res= TRUE;
|
||||
goto end_with_restore_list;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
Remove target table from main select and name resolution
|
||||
|
@ -2103,7 +2103,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
|
||||
/* mark for close and remove all cached entries */
|
||||
thd->push_internal_handler(&err_handler);
|
||||
error= mysql_rm_table_no_locks(thd, tables, if_exists, drop_temporary,
|
||||
false, false);
|
||||
false, false, false);
|
||||
thd->pop_internal_handler();
|
||||
|
||||
if (error)
|
||||
@ -2168,6 +2168,8 @@ static uint32 comment_length(THD *thd, uint32 comment_pos,
|
||||
@param drop_view Allow to delete VIEW .frm
|
||||
@param dont_log_query Don't write query to log files. This will also not
|
||||
generate warnings if the handler files doesn't exists
|
||||
@param dont_free_locks Don't do automatic UNLOCK TABLE if no more locked
|
||||
tables
|
||||
|
||||
@retval 0 ok
|
||||
@retval 1 Error
|
||||
@ -2190,7 +2192,8 @@ static uint32 comment_length(THD *thd, uint32 comment_pos,
|
||||
|
||||
int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
bool drop_temporary, bool drop_view,
|
||||
bool dont_log_query)
|
||||
bool dont_log_query,
|
||||
bool dont_free_locks)
|
||||
{
|
||||
TABLE_LIST *table;
|
||||
char path[FN_REFLEN + 1], wrong_tables_buff[160], *alias= NULL;
|
||||
@ -2204,6 +2207,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
bool trans_tmp_table_deleted= 0, non_trans_tmp_table_deleted= 0;
|
||||
bool non_tmp_table_deleted= 0;
|
||||
bool is_drop_tmp_if_exists_added= 0;
|
||||
bool one_table= tables->next_local == 0;
|
||||
bool was_view= 0;
|
||||
String built_query;
|
||||
String built_trans_tmp_query, built_non_trans_tmp_query;
|
||||
DBUG_ENTER("mysql_rm_table_no_locks");
|
||||
@ -2413,7 +2418,7 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
DEBUG_SYNC(thd, "rm_table_no_locks_before_delete_table");
|
||||
error= 0;
|
||||
if ((drop_temporary || !ha_table_exists(thd, db, alias, &table_type) ||
|
||||
(!drop_view && table_type == view_pseudo_hton)))
|
||||
(!drop_view && (was_view= (table_type == view_pseudo_hton)))))
|
||||
{
|
||||
/*
|
||||
One of the following cases happened:
|
||||
@ -2544,7 +2549,10 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
err:
|
||||
if (wrong_tables.length())
|
||||
{
|
||||
if (!foreign_key_error)
|
||||
if (one_table && was_view)
|
||||
my_printf_error(ER_IT_IS_A_VIEW, ER(ER_IT_IS_A_VIEW), MYF(0),
|
||||
wrong_tables.c_ptr_safe());
|
||||
else if (!foreign_key_error)
|
||||
my_printf_error(ER_BAD_TABLE_ERROR, ER(ER_BAD_TABLE_ERROR), MYF(0),
|
||||
wrong_tables.c_ptr_safe());
|
||||
else
|
||||
@ -2610,7 +2618,8 @@ err:
|
||||
*/
|
||||
if (thd->locked_tables_mode)
|
||||
{
|
||||
if (thd->lock && thd->lock->table_count == 0 && non_temp_tables_count > 0)
|
||||
if (thd->lock && thd->lock->table_count == 0 &&
|
||||
non_temp_tables_count > 0 && !dont_free_locks)
|
||||
{
|
||||
thd->locked_tables_list.unlock_locked_tables(thd);
|
||||
goto end;
|
||||
@ -4608,8 +4617,8 @@ int create_table_impl(THD *thd,
|
||||
call to open_and_lock_tables() when we are using LOCK TABLES.
|
||||
*/
|
||||
(void) trans_rollback_stmt(thd);
|
||||
/* Remove normal table without logging */
|
||||
if (mysql_rm_table_no_locks(thd, &table_list, 0, 0, 0, 1))
|
||||
/* Remove normal table without logging. Keep tables locked */
|
||||
if (mysql_rm_table_no_locks(thd, &table_list, 0, 0, 0, 1, 1))
|
||||
goto err;
|
||||
/*
|
||||
The test of query_tables is to ensure we have any tables in the
|
||||
@ -4618,6 +4627,11 @@ int create_table_impl(THD *thd,
|
||||
if (thd->lex->query_tables &&
|
||||
restart_trans_for_tables(thd, thd->lex->query_tables->next_global))
|
||||
goto err;
|
||||
/*
|
||||
We have to log this query, even if it failed later to ensure the
|
||||
drop is done.
|
||||
*/
|
||||
thd->variables.option_bits|= OPTION_KEEP_LOG;
|
||||
}
|
||||
else if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
|
||||
goto warn;
|
||||
@ -5084,6 +5098,18 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
||||
res= thd->is_error();
|
||||
goto err;
|
||||
}
|
||||
/* Ensure we don't try to create something from which we select from */
|
||||
if ((create_info->options & HA_LEX_CREATE_REPLACE) &&
|
||||
!create_info->tmp_table())
|
||||
{
|
||||
TABLE_LIST *duplicate;
|
||||
if ((duplicate= unique_table(thd, table, src_table, 0)))
|
||||
{
|
||||
update_non_unique_table_error(src_table, "CREATE", duplicate);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
src_table->table->use_all_columns();
|
||||
|
||||
DEBUG_SYNC(thd, "create_table_like_after_open");
|
||||
|
@ -238,7 +238,7 @@ bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
|
||||
my_bool drop_temporary);
|
||||
int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
|
||||
bool drop_temporary, bool drop_view,
|
||||
bool log_query);
|
||||
bool log_query, bool dont_free_locks);
|
||||
bool quick_rm_table(THD *thd, handlerton *base, const char *db,
|
||||
const char *table_name, uint flags);
|
||||
void close_cached_table(THD *thd, TABLE *table);
|
||||
|
Loading…
x
Reference in New Issue
Block a user