Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primary key checks not honored when inserting multiple records at once #13348

Closed
amotl opened this issue Dec 6, 2022 · 2 comments
Closed

Primary key checks not honored when inserting multiple records at once #13348

amotl opened this issue Dec 6, 2022 · 2 comments
Labels
triage An issue that needs to be triaged by a maintainer

Comments

@amotl
Copy link
Member

amotl commented Dec 6, 2022

CrateDB version

5.1.1

CrateDB setup information

docker run -it --rm --publish=4200:4200 --publish=5432:5432 crate:5.1.1 -Cdiscovery.type=single-node -Ccluster.routing.allocation.disk.threshold_enabled=false

Steps to Reproduce

psql postgres://crate@localhost:5432/doc

Running this multiple times does not croak.

CREATE TABLE IF NOT EXISTS testdrive (id INT PRIMARY KEY, data TEXT);
INSERT INTO testdrive VALUES (0, 'zero'), (1, 'one');
INSERT INTO testdrive VALUES (0, 'zero'), (1, 'one');

Expected Result

Would have expected it to croak like this.

CREATE TABLE IF NOT EXISTS testdrive (id INT PRIMARY KEY, data TEXT);
INSERT INTO testdrive VALUES (0, 'zero');
INSERT INTO testdrive VALUES (0, 'zero');
ERROR:  A document with the same primary key exists already

Actual Result

doc=> INSERT INTO testdrive VALUES (0, 'zero'), (1, 'one');
INSERT 0 2
doc=> INSERT INTO testdrive VALUES (0, 'zero'), (1, 'one');
INSERT 0 0
@amotl amotl added the triage An issue that needs to be triaged by a maintainer label Dec 6, 2022
@mfussenegger
Copy link
Member

This is expected behavior, the rowcount on the second insert changed from 2 to 0 to indicate that the records weren't inserted.

Also relates to #12218

@amotl
Copy link
Member Author

amotl commented Dec 6, 2022

I see. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage An issue that needs to be triaged by a maintainer
Projects
None yet
Development

No branches or pull requests

2 participants