Skip to content

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

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
michae2:rc_unique_check_error
Sep 28, 2023
Merged

sql: disallow explicit unique checks under read committed isolation#110879
craig[bot] merged 1 commit intocockroachdb:masterfrom
michae2:rc_unique_check_error

Conversation

@michae2
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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).

@michae2 michae2 force-pushed the rc_unique_check_error branch from 5b6e349 to 11ee263 Compare September 27, 2023 00:07
@michae2 michae2 requested review from msirek and nvb September 27, 2023 04:09
@michae2 michae2 marked this pull request as ready for review September 27, 2023 04:12
@michae2 michae2 requested a review from a team as a code owner September 27, 2023 04:12
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
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
Collaborator Author

michae2 commented Sep 27, 2023

Thank you!

bors r=mgartner,DrewKimball

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Sep 28, 2023

Build succeeded:

@craig craig bot merged commit 4cd8dcf into cockroachdb:master Sep 28, 2023
@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.

4 participants