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

sql: disallow explicit unique checks under read committed isolation #110879

Merged
merged 1 commit into from Sep 28, 2023

Conversation

michae2
Copy link
Collaborator

@michae2 michae2 commented Sep 19, 2023

(This is a follow-on PR after #107961.)

Because we do not yet support predicate locking, add a check to execbuilder that disallows any query using it (currently only unique checks under read committed isolation).

Informs: #110873

Release note (sql): We do not yet support explicit unique checks under Read Committed isolation. This means that some INSERT, UPDATE, and UPSERT statements against some REGIONAL BY ROW tables will fail under Read Committed isolation with the following error:

unimplemented: explicit unique checks are not yet supported under read committed isolation
SQLSTATE: 0A000

For more details about which REGIONAL BY ROW tables are affected, please see: https://go.crdb.dev/issue-v/110873/v23.2

@cockroach-teamcity
Copy link
Member

This change is Reviewable

----

statement ok
INSERT INTO city VALUES ('Vancouver', 'The Big Smoke', 'BC'), ('Salem', 'Cherry City', 'OR')
ON CONFLICT (name, state_or_province) DO NOTHING
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This INSERT ON CONFLICT DO NOTHING case is broken (and I suspect the corresponding UPSERT and INSERT ON CONFLICT DO UPDATE cases are also broken). Hold off on reviewing while I try to fix those.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this is fixed now (by using uniqueCheckHelper.init).

Because we do not yet support predicate locking, add a check to
execbuilder that disallows any query using it (currently only unique
checks under read committed isolation).

Informs: cockroachdb#110873

Release note (sql): We do not yet support explicit unique checks under
Read Committed isolation. This means that some `INSERT`, `UPDATE`, and
`UPSERT` statements against some `REGIONAL BY ROW` tables will fail
under Read Committed isolation with the following error:

```
unimplemented: explicit unique checks are not yet supported under read committed isolation
SQLSTATE: 0A000
```

For more details about which `REGIONAL BY ROW` tables are affected,
please see: https://go.crdb.dev/issue-v/110873/v23.2
Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 11 files at r1, 12 of 12 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @michae2, @msirek, and @nvanbenschoten)


pkg/sql/logictest/testdata/logic_test/hash_sharded_index_read_committed line 21 at r2 (raw file):


statement ok
CREATE UNIQUE INDEX ON sharded_unique (a) USING HASH

nit: You should be able to include this in the CREATE TABLE statement above.

Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 11 files at r1, 12 of 12 files at r2, all commit messages.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @michae2, @msirek, and @nvanbenschoten)

@michae2
Copy link
Collaborator Author

michae2 commented Sep 27, 2023

Thank you!

bors r=mgartner,DrewKimball

@craig
Copy link
Contributor

craig bot commented Sep 28, 2023

Build succeeded:

@craig craig bot merged commit 4cd8dcf into cockroachdb:master Sep 28, 2023
7 of 8 checks passed
@michae2 michae2 deleted the rc_unique_check_error branch September 28, 2023 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants