Skip to content

Multi-record UPSERT inserts duplicate values in PRIMARY KEY, resulting in inconsistent results #44466

@mrigger

Description

@mrigger

Consider the following testcase:

CREATE TABLE t0(c0 INT PRIMARY KEY, c1 BOOL, c2 INT UNIQUE);
INSERT INTO t0(c0) VALUES (0);
UPSERT INTO t0(c2, c0) VALUES (0, 0), (1, 0);
SELECT * FROM t0; -- {0 | NULL | 1}

A single row is fetched, while the following query fetches two records with a duplicate value for c0:

SELECT c0 FROM t0; -- {0, 0}

I found this issue in CockroachDB based on commit 1917a12003daad100b491e2b0195d7df5909e63f.

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