You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
Copy file name to clipboardExpand all lines: mysql-test/main/delete.result
+28-3Lines changed: 28 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -259,21 +259,21 @@ a INT
259
259
);
260
260
INSERT INTO db2.t1 (a) SELECT * FROM t2;
261
261
DELETE FROM t1 alias USING t1, t2 alias WHERE t1.a = alias.a;
262
-
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
262
+
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
263
263
DELETE FROM alias USING t1, t2 alias WHERE t1.a = alias.a;
264
264
DELETE FROM t1, alias USING t1, t2 alias WHERE t1.a = alias.a;
265
265
DELETE FROM t1, t2 USING t1, t2 alias WHERE t1.a = alias.a;
266
266
ERROR 42S02: Unknown table 't2' in MULTI DELETE
267
267
DELETE FROM db1.t1 alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
268
-
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
268
+
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
269
269
DELETE FROM alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
270
270
DELETE FROM db2.alias USING db1.t1, db2.t1 alias WHERE db1.t1.a = alias.a;
271
271
ERROR 42S02: Unknown table 'alias' in MULTI DELETE
272
272
DELETE FROM t1 USING t1 WHERE a = 1;
273
273
SELECT * FROM t1;
274
274
a
275
275
DELETE FROM t1 alias USING t1 alias WHERE a = 2;
276
-
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
276
+
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
277
277
SELECT * FROM t1;
278
278
a
279
279
DROP TABLE t1, t2;
@@ -611,3 +611,28 @@ c1 c2 c3
611
611
2 2 5
612
612
drop table t1;
613
613
End of 11.1 tests
614
+
#
615
+
# MDEV-33988 DELETE to support table aliases
616
+
#
617
+
CREATE TABLE t1 (c1 INT);
618
+
INSERT INTO t1 VALUES (1), (2);
619
+
SELECT * FROM t1;
620
+
c1
621
+
1
622
+
2
623
+
DELETE FROM t1 AS a1 WHERE a1.c1 = 2;
624
+
SELECT * FROM t1;
625
+
c1
626
+
1
627
+
CREATE TABLE t2 (c2 INT);
628
+
INSERT INTO t2 VALUES (1), (2);
629
+
SELECT * FROM t2;
630
+
c2
631
+
1
632
+
2
633
+
DELETE FROM t2 a2 WHERE NOT EXISTS (SELECT * FROM t1 WHERE t1.c1 = a2.c2);
Copy file name to clipboardExpand all lines: mysql-test/main/trigger-compat.result
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ FLUSH TABLE t2;
69
69
# has broken triggers. The parse error refers to the first broken
70
70
# trigger.
71
71
CREATE TRIGGER tr16 AFTER UPDATE ON t1 FOR EACH ROW INSERT INTO t1 VALUES (1);
72
-
ERROR 42000: Trigger 'tr13' has an error in its body: '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 'a USING t1 a' at line 1'
72
+
ERROR 42000: Trigger 'tr13' has an error in its body: '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 a' at line 1'
73
73
CREATE TRIGGER tr22 BEFORE INSERT ON t2 FOR EACH ROW DELETE FROM non_existing_table;
74
74
ERROR 42000: Unknown trigger has an error in its body: '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 'Not allowed syntax here, and trigger name cant be extracted either.' at line 1'
75
75
SHOW TRIGGERS;
@@ -80,20 +80,20 @@ tr15 UPDATE t1 CREATE DEFINER=`root`@`localhost` TRIGGER tr15 BEFORE UPDATE ON t
80
80
tr13 DELETE t1 CREATE DEFINER=`root`@`localhost` TRIGGER tr13 BEFORE DELETE ON t1 FOR EACH ROW DELETE FROM t1 a USING t1 a BEFORE # latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci
81
81
tr14 DELETE t1 DELETE FROM non_existing_table AFTER # root@localhost latin1 latin1_swedish_ci utf8mb4_uca1400_ai_ci
82
82
INSERT INTO t1 VALUES (1);
83
-
ERROR 42000: Trigger 'tr13' has an error in its body: '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 'a USING t1 a' at line 1'
83
+
ERROR 42000: Trigger 'tr13' has an error in its body: '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 a' at line 1'
84
84
INSERT INTO t2 VALUES (1);
85
85
ERROR 42000: Unknown trigger has an error in its body: '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 'Not allowed syntax here, and trigger name cant be extracted either.' at line 1'
86
86
DELETE FROM t1;
87
-
ERROR 42000: Trigger 'tr13' has an error in its body: '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 'a USING t1 a' at line 1'
87
+
ERROR 42000: Trigger 'tr13' has an error in its body: '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 a' at line 1'
88
88
UPDATE t1 SET a = 1 WHERE a = 1;
89
-
ERROR 42000: Trigger 'tr13' has an error in its body: '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 'a USING t1 a' at line 1'
89
+
ERROR 42000: Trigger 'tr13' has an error in its body: '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 a' at line 1'
90
90
SELECT * FROM t1;
91
91
a
92
92
1
93
93
2
94
94
3
95
95
RENAME TABLE t1 TO t1_2;
96
-
ERROR 42000: Trigger 'tr13' has an error in its body: '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 'a USING t1 a' at line 1'
96
+
ERROR 42000: Trigger 'tr13' has an error in its body: '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 a' at line 1'
0 commit comments