should be it
This commit is contained in:
91
external/duckdb/test/sql/delete/test_using_delete.test
vendored
Normal file
91
external/duckdb/test/sql/delete/test_using_delete.test
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
# name: test/sql/delete/test_using_delete.test
|
||||
# description: Test deletions with USING clause
|
||||
# group: [delete]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE a(i INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO a VALUES (1), (2), (3);
|
||||
|
||||
query I
|
||||
DELETE FROM a USING (values (1)) tbl(i) WHERE a.i=tbl.i;
|
||||
----
|
||||
1
|
||||
|
||||
query I
|
||||
SELECT * FROM a;
|
||||
----
|
||||
2
|
||||
3
|
||||
|
||||
# no condition?
|
||||
query I
|
||||
DELETE FROM a USING (values (1)) tbl(i);
|
||||
----
|
||||
2
|
||||
|
||||
query I
|
||||
SELECT * FROM a;
|
||||
----
|
||||
|
||||
statement ok
|
||||
INSERT INTO a VALUES (1), (2), (3);
|
||||
|
||||
query I
|
||||
SELECT * FROM a;
|
||||
----
|
||||
1
|
||||
2
|
||||
3
|
||||
|
||||
# multiple joins
|
||||
query I
|
||||
DELETE FROM a USING (values (1)) tbl(i), (values (1), (2)) tbl2(i) WHERE a.i=tbl.i AND a.i=tbl2.i;
|
||||
----
|
||||
1
|
||||
|
||||
query I
|
||||
SELECT * FROM a;
|
||||
----
|
||||
2
|
||||
3
|
||||
|
||||
# no matches
|
||||
query I
|
||||
DELETE FROM a USING (values (4)) tbl(i) WHERE a.i=tbl.i;
|
||||
----
|
||||
0
|
||||
|
||||
query I
|
||||
SELECT * FROM a;
|
||||
----
|
||||
2
|
||||
3
|
||||
|
||||
# self join
|
||||
query I
|
||||
DELETE FROM a USING a a2(i) WHERE a.i>a2.i;
|
||||
----
|
||||
1
|
||||
|
||||
query I
|
||||
SELECT * FROM a;
|
||||
----
|
||||
2
|
||||
|
||||
# binding errors
|
||||
# table does not exist
|
||||
statement error
|
||||
DELETE FROM a USING b WHERE a.i=b.i;
|
||||
----
|
||||
<REGEX>:.*Catalog Error.*does not exist.*
|
||||
|
||||
# column does not exist
|
||||
statement error
|
||||
DELETE FROM a USING a b WHERE a.i=b.j;
|
||||
----
|
||||
<REGEX>:.*Binder Error.*does not have a column.*
|
||||
Reference in New Issue
Block a user