1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Add a few test cases for RETURNING together with UPDATE/DELETE LIMIT.

FossilOrigin-Name: 7611c77d6baa84086ff18cbd045127fd682c6d5c434af5404e34fbe631fedfe1
This commit is contained in:
drh
2021-02-01 21:26:09 +00:00
parent 7baf3d411b
commit d33d3a2ba7
3 changed files with 24 additions and 12 deletions

View File

@ -94,21 +94,31 @@ ifcapable {update_delete_limit} {
execsql {DELETE FROM t1 ORDER BY x LIMIT 5}
execsql {SELECT count(*) FROM t1}
} {15}
create_test_data 4
do_test wherelimit-1.3b {
# limit 5
execsql {DELETE FROM t1 RETURNING x, y, '|' ORDER BY x, y LIMIT 5}
} {1 1 | 1 2 | 1 3 | 1 4 | 2 1 |}
do_test wherelimit-1.3c {
execsql {SELECT count(*) FROM t1}
} {11}
do_test wherelimit-1.4 {
# limit 5, offset 2
execsql {DELETE FROM t1 ORDER BY x LIMIT 5 OFFSET 2}
execsql {DELETE FROM t1 RETURNING x, y, '|' ORDER BY x LIMIT 5 OFFSET 2}
} {2 4 | 3 1 | 3 2 | 3 3 | 3 4 |}
do_test wherelimit-1.4cnt {
execsql {SELECT count(*) FROM t1}
} {10}
} {6}
do_test wherelimit-1.5 {
# limit 5, offset -2
execsql {DELETE FROM t1 ORDER BY x LIMIT 5 OFFSET -2}
execsql {SELECT count(*) FROM t1}
} {5}
} {1}
do_test wherelimit-1.6 {
# limit -5 (no limit), offset 2
execsql {DELETE FROM t1 ORDER BY x LIMIT 2, -5}
execsql {SELECT count(*) FROM t1}
} {2}
} {1}
do_test wherelimit-1.7 {
# limit 5, offset -2 (no offset)
execsql {DELETE FROM t1 ORDER BY x LIMIT -2, 5}
@ -227,7 +237,9 @@ ifcapable {update_delete_limit} {
} {11}
create_test_data 6
do_test wherelimit-3.2 {
execsql {UPDATE t1 SET y=1 WHERE x=1 LIMIT 5}
execsql {UPDATE t1 SET y=1 WHERE x=1 RETURNING x, old.y, '|' LIMIT 5}
} {1 1 | 1 2 | 1 3 | 1 4 | 1 5 |}
do_test wherelimit-3.2cnt {
execsql {SELECT count(*) FROM t1 WHERE y=1}
} {10}
do_test wherelimit-3.3 {