-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: mutations in statement sources don't work properly with limits #20732
Copy link
Copy link
Closed
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Milestone
Description
root@:26257/test> create table a (a int);
CREATE TABLE
root@:26257/test> insert into a values(1),(2);
INSERT 2
root@:26257/test> select * from [delete from a returning a] limit 1;
+---+
| a |
+---+
| 1 |
+---+
(1 row)
root@:26257/test> select * from [delete from a returning a] limit 2;
+---+
| a |
+---+
| 1 |
| 2 |
+---+
(2 rows)
root@:26257/test> select * from a;
+---+
| a |
+---+
| 1 |
| 2 |
+---+
(2 rows)
As you can see, the inner delete never gets executed.
Without a limit, or with an offset, this seems to work properly:
root@:26257/test> select * from [delete from a returning a] offset 1;
+---+
| a |
+---+
| 2 |
+---+
(1 row)
root@:26257/test> select * from a;
+---+
| a |
+---+
+---+
(0 rows)
Same problem exists with insert:
root@:26257/test> select * from [insert into a values(1) returning a] limit 1;
+---+
| a |
+---+
| 1 |
+---+
(1 row)
root@:26257/test> select * from a;
+---+
| a |
+---+
+---+
(0 rows)
cc @knz
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.