-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: the rows affected count is wrong for UPSERT #24928
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.
Description
Found while working on a test for the rows affected value on statements that have no result rows.
Hinted by a chat with @mberhault.
The expected behavior of UPSERT (and possibly other mutation statements) is that its rows affected count should reflect the number of rows actually modified. However, CockroachDB gets this wrong:
INSERT INTO kv VALUES(1,2);
INSERT INTO kv VALUES (1,2), (3,4) ON CONFLICT(k) DO NOTHING; -- returns 2 rows affected, even though just 1 row was upserted
This in turn means that the GRANT statement will bump the role membership table version on every invocation, even if nothing is changed (= excessive chattiness).
(So this is not a correctness bug)
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.