mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-33988 DELETE single table to support table aliases
Gain MySQL compatibility by allowing table aliases in a single table statement. This now supports the syntax of: DELETE [delete_opts] FROM tbl_name [[AS] tbl_alias] [PARTITION (partition_name [, partition_name] ...)] .... The delete.test is from MySQL commit 1a72b69778a9791be44525501960b08856833b8d / Change-Id: Iac3a2b5ed993f65b7f91acdfd60013c2344db5c0. Co-Author: Gleb Shchepa <gleb.shchepa@oracle.com> (for delete.test) Reviewed by Igor Babaev (igor@mariadb.com)
This commit is contained in:
@ -259,13 +259,13 @@ a INT
|
||||
);
|
||||
INSERT INTO db2.t1 (a) SELECT * FROM t2;
|
||||
DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
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 'alias USING t1, t2 alias WHERE t1.a = alias.a' at line 1
|
||||
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 'USING t1, t2 alias WHERE t1.a = alias.a' at line 1
|
||||
DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
|
||||
ERROR 42S02: Unknown table 't2' in MULTI DELETE
|
||||
DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
|
||||
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 'alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a' at line 1
|
||||
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 'USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a' at line 1
|
||||
DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
|
||||
DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
|
||||
ERROR 42S02: Unknown table 'alias' in MULTI DELETE
|
||||
@ -273,7 +273,7 @@ DELETE FROM t1 USING t1 WHERE a = 1;
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
DELETE FROM t1 alias USING t1 alias WHERE a = 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 'alias USING t1 alias WHERE a = 2' at line 1
|
||||
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 'USING t1 alias WHERE a = 2' at line 1
|
||||
SELECT * FROM t1;
|
||||
a
|
||||
DROP TABLE t1, t2;
|
||||
@ -611,3 +611,28 @@ c1 c2 c3
|
||||
2 2 5
|
||||
drop table t1;
|
||||
End of 11.1 tests
|
||||
#
|
||||
# MDEV-33988 DELETE to support table aliases
|
||||
#
|
||||
CREATE TABLE t1 (c1 INT);
|
||||
INSERT INTO t1 VALUES (1), (2);
|
||||
SELECT * FROM t1;
|
||||
c1
|
||||
1
|
||||
2
|
||||
DELETE FROM t1 AS a1 WHERE a1.c1 = 2;
|
||||
SELECT * FROM t1;
|
||||
c1
|
||||
1
|
||||
CREATE TABLE t2 (c2 INT);
|
||||
INSERT INTO t2 VALUES (1), (2);
|
||||
SELECT * FROM t2;
|
||||
c2
|
||||
1
|
||||
2
|
||||
DELETE FROM t2 a2 WHERE NOT EXISTS (SELECT * FROM t1 WHERE t1.c1 = a2.c2);
|
||||
SELECT * FROM t2;
|
||||
c2
|
||||
1
|
||||
DROP TABLE t1, t2;
|
||||
End of 11.6 tests
|
||||
|
Reference in New Issue
Block a user