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

opt: lock operator is considered a mutation operator #141961

Open
DrewKimball opened this issue Feb 25, 2025 · 1 comment · May be fixed by #141964
Open

opt: lock operator is considered a mutation operator #141961

DrewKimball opened this issue Feb 25, 2025 · 1 comment · May be fixed by #141964
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team

Comments

@DrewKimball
Copy link
Collaborator

DrewKimball commented Feb 25, 2025

The optimizer currently returns true for IsMutationOp when called on a Lock operator. This results in some differences in behavior for serializable vs read committed, since read committed can plan a lock operator when serializable performs locking in the scan.
Serializable:

root@localhost:26257/defaultdb> SELECT * FROM (WITH foo AS (SELECT * FROM xy FOR UPDATE LIMIT 1) SELECT 1);
  ?column?
------------
         1
(1 row)

Read committed:

root@localhost:26257/defaultdb> BEGIN ISOLATION LEVEL READ COMMITTED;
BEGIN

Time: 0ms total (execution 1ms / network 0ms)

root@localhost:26257/defaultdb  OPEN> SELECT * FROM (WITH foo AS (SELECT * FROM xy FOR UPDATE LIMIT 1) SELECT 1);
ERROR: WITH clause containing a data-modifying statement must be at the top level
SQLSTATE: 0A000

Jira issue: CRDB-48092

@DrewKimball DrewKimball added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Feb 25, 2025
Copy link

blathers-crl bot commented Feb 25, 2025

Hi @DrewKimball, please add branch-* labels to identify which branch(es) this C-bug affects.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@github-project-automation github-project-automation bot moved this to Triage in SQL Queries Feb 25, 2025
@DrewKimball DrewKimball added the T-sql-queries SQL Queries Team label Feb 25, 2025
DrewKimball added a commit to DrewKimball/cockroach that referenced this issue Feb 25, 2025
This commit removes the `Mutation` tag from the optimizer lock operator.
As a result, errors that result from checking `opt.IsMutationOp` or
`planFlagContainsMutation` will no longer incorrectly occur for plans
that contain lock operators.

Fixes cockroachdb#141961

Release note: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team
Projects
Status: Triage
Development

Successfully merging a pull request may close this issue.

1 participant