Commit 9584c675 authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-12874 UPDATE statements with the same source and target

update engine tests
parent 61b2618d
...@@ -15,8 +15,6 @@ ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOM ...@@ -15,8 +15,6 @@ ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOM
SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2); SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2);
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2); UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2);
UPDATE t1 SET c1 = (SELECT MAX(c1) FROM t1);
ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t1 (c1 INT, c2 VARCHAR(100),c3 FLOAT); CREATE TABLE t1 (c1 INT, c2 VARCHAR(100),c3 FLOAT);
...@@ -34,8 +32,6 @@ ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOM ...@@ -34,8 +32,6 @@ ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOM
SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2); SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2);
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2); UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2);
UPDATE t1 SET c1 = (SELECT MAX(c1) FROM t1);
ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t1 (c1 INT, c2 BINARY(100),c3 FLOAT); CREATE TABLE t1 (c1 INT, c2 BINARY(100),c3 FLOAT);
...@@ -53,8 +49,6 @@ ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOM ...@@ -53,8 +49,6 @@ ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOM
SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2); SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2);
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2); UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2);
UPDATE t1 SET c1 = (SELECT MAX(c1) FROM t1);
ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t1 (c1 INT, c2 VARBINARY(100),c3 FLOAT); CREATE TABLE t1 (c1 INT, c2 VARBINARY(100),c3 FLOAT);
...@@ -72,7 +66,5 @@ ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOM ...@@ -72,7 +66,5 @@ ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOM
SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2); SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2);
ERROR 21000: Subquery returns more than 1 row ERROR 21000: Subquery returns more than 1 row
UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2); UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2);
UPDATE t1 SET c1 = (SELECT MAX(c1) FROM t1);
ERROR HY000: Table 't1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
...@@ -19,8 +19,6 @@ SELECT (SELECT c1, c2 FROM t2) FROM t1; ...@@ -19,8 +19,6 @@ SELECT (SELECT c1, c2 FROM t2) FROM t1;
--error 1242 --error 1242
SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2); SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2);
UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2); UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2);
--error 1093
UPDATE t1 SET c1 = (SELECT MAX(c1) FROM t1);
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t1 (c1 INT, c2 VARCHAR(100),c3 FLOAT); CREATE TABLE t1 (c1 INT, c2 VARCHAR(100),c3 FLOAT);
...@@ -38,8 +36,6 @@ SELECT (SELECT c1, c2 FROM t2) FROM t1; ...@@ -38,8 +36,6 @@ SELECT (SELECT c1, c2 FROM t2) FROM t1;
--error 1242 --error 1242
SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2); SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2);
UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2); UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2);
--error 1093
UPDATE t1 SET c1 = (SELECT MAX(c1) FROM t1);
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t1 (c1 INT, c2 BINARY(100),c3 FLOAT); CREATE TABLE t1 (c1 INT, c2 BINARY(100),c3 FLOAT);
...@@ -57,8 +53,6 @@ SELECT (SELECT c1, c2 FROM t2) FROM t1; ...@@ -57,8 +53,6 @@ SELECT (SELECT c1, c2 FROM t2) FROM t1;
--error 1242 --error 1242
SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2); SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2);
UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2); UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2);
--error 1093
UPDATE t1 SET c1 = (SELECT MAX(c1) FROM t1);
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
CREATE TABLE t1 (c1 INT, c2 VARBINARY(100),c3 FLOAT); CREATE TABLE t1 (c1 INT, c2 VARBINARY(100),c3 FLOAT);
...@@ -76,8 +70,6 @@ SELECT (SELECT c1, c2 FROM t2) FROM t1; ...@@ -76,8 +70,6 @@ SELECT (SELECT c1, c2 FROM t2) FROM t1;
--error 1242 --error 1242
SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2); SELECT * FROM t1 WHERE c1 = (SELECT c1 FROM t2);
UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2); UPDATE t1 SET c2 = (SELECT MAX(c1) FROM t2);
--error 1093
UPDATE t1 SET c1 = (SELECT MAX(c1) FROM t1);
DROP TABLE t1; DROP TABLE t1;
DROP TABLE t2; DROP TABLE t2;
...@@ -980,7 +980,6 @@ drop table mt1, mt2, mt3; ...@@ -980,7 +980,6 @@ drop table mt1, mt2, mt3;
create table mt1 (col1 int); create table mt1 (col1 int);
create table mt2 (col1 int); create table mt2 (col1 int);
update mt1,mt2 set mt1.col1 = (select max(col1) from mt1) where mt1.col1 = mt2.col1; update mt1,mt2 set mt1.col1 = (select max(col1) from mt1) where mt1.col1 = mt2.col1;
ERROR HY000: Table 'mt1' is specified twice, both as a target for 'UPDATE' and as a separate source for data
delete mt1 from mt1,mt2 where mt1.col1 < (select max(col1) from mt1) and mt1.col1 = mt2.col1; delete mt1 from mt1,mt2 where mt1.col1 < (select max(col1) from mt1) and mt1.col1 = mt2.col1;
ERROR HY000: Table 'mt1' is specified twice, both as a target for 'DELETE' and as a separate source for data ERROR HY000: Table 'mt1' is specified twice, both as a target for 'DELETE' and as a separate source for data
drop table mt1,mt2; drop table mt1,mt2;
......
...@@ -495,7 +495,6 @@ drop table mt1, mt2, mt3; ...@@ -495,7 +495,6 @@ drop table mt1, mt2, mt3;
# multi* unique updating table check # multi* unique updating table check
create table mt1 (col1 int); create table mt1 (col1 int);
create table mt2 (col1 int); create table mt2 (col1 int);
-- error ER_UPDATE_TABLE_USED
update mt1,mt2 set mt1.col1 = (select max(col1) from mt1) where mt1.col1 = mt2.col1; update mt1,mt2 set mt1.col1 = (select max(col1) from mt1) where mt1.col1 = mt2.col1;
-- error ER_UPDATE_TABLE_USED -- error ER_UPDATE_TABLE_USED
delete mt1 from mt1,mt2 where mt1.col1 < (select max(col1) from mt1) and mt1.col1 = mt2.col1; delete mt1 from mt1,mt2 where mt1.col1 < (select max(col1) from mt1) and mt1.col1 = mt2.col1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment