Skip to content

sql: the rows affected count is wrong for UPSERT #24928

@knz

Description

@knz

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)

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions