sql/opt: split out row-level locking properties struct#79679
sql/opt: split out row-level locking properties struct#79679craig[bot] merged 1 commit intocockroachdb:masterfrom
Conversation
rytaft
left a comment
There was a problem hiding this comment.
I think it's correct to call row-level locking a "physical property", but I could be wrong about that.
Hmm I see where you're coming from, but as defined currently, I don't think Locking quite meets the definition we use for physical property. For reference:
Lines 132 to 157 in c097a16
cockroach/pkg/sql/opt/props/physical/required.go
Lines 21 to 64 in 687beb1
cockroach/pkg/sql/opt/props/physical/provided.go
Lines 19 to 50 in 687beb1
If we want Locking to be a physical property, it should be added to physical.Provided and/or physical.Required, and set similarly to the other physical properties. I'm not sure this is the right approach.
Also, unlike the other physical properties which may apply to any expression, Locking currently seems pretty specific to scans. If we aren't using it for other expressions, I think it might be better to define it in memo, the same place we define the ScanPrivate.
Out of curiosity, though, could Locking also apply to other expressions that touch tables, namely zigzag join, lookup join, and index join?
Reviewed 36 of 36 files at r1, all commit messages.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)
pkg/sql/opt/props/physical/locking.go, line 16 at r1 (raw file):
// Locking represents the row-level locking properties of a relational operator. // Each relational operator clauses consist of two different row-level locking
nit: Each ... clauses consist -> Each ... clause consists
5061051 to
7c0ce63
Compare
|
Thanks for taking a look Becca!
I don't want Locking to be a physical property unless it meets the definition, but it doesn't sound like it does. I looked into moving the struct to
Yep! That's what we're adding in #60719, which is the PR that motivated this change. |
mgartner
left a comment
There was a problem hiding this comment.
Reviewed 10 of 36 files at r1, 27 of 27 files at r2, all commit messages.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)
pkg/sql/opt/ops/relational.opt, line 76 at r2 (raw file):
# locking will be performed while scanning the table. Stronger locking modes # are used by SELECT .. FOR [KEY] UPDATE/SHARE statements and by the initial # row retrieval of DELETE and UPDATE statements.
nit: briefly mention locking wait policy in the comment
|
pkg/sql/opt/memo/interner_test.go, line 469 at r2 (raw file):
Can you make these fields unnamed so that the test won't compile if a new field is added? For example: |
7c0ce63 to
6ea0a76
Compare
nvb
left a comment
There was a problem hiding this comment.
TFTR!
Reviewable status:
complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner and @rytaft)
pkg/sql/opt/ops/relational.opt, line 76 at r2 (raw file):
Previously, mgartner (Marcus Gartner) wrote…
nit: briefly mention locking wait policy in the comment
Done.
pkg/sql/opt/memo/interner_test.go, line 469 at r2 (raw file):
Previously, mgartner (Marcus Gartner) wrote…
Can you make these fields unnamed so that the test won't compile if a new field is added? For example:
opt.Locking{tree.ForUpdate, tree.LockWairError}.
Done.
pkg/sql/opt/props/physical/locking.go, line 16 at r1 (raw file):
Previously, rytaft (Rebecca Taft) wrote…
nit: Each ... clauses consist -> Each ... clause consists
Done.
This commit separates an unresolved row-level locking target from a new row-level locking properties struct. The former is used to represent a row-level locking clause that is then "resolved" to specific relational operators. Once attached to a specific operator, the locking mode no longer needs to include a target, so it makes sense to represent as a separate struct. This addresses Radu's comment from cockroachdb#60719.
6ea0a76 to
2115a44
Compare
|
I don't understand. We already use this pattern in the same file: cockroach/pkg/sql/opt/memo/interner_test.go Line 422 in 996f52c |
This appears to be because the It doesn't seem like there's much we can do to fight this, so I'll go ahead and merge, but I'm happy to revisit if you think we should try to do something else to avoid the lint error. bors r=mgartner |
|
Build succeeded: |
|
Ahh, thanks for getting to the bottom of it. 👍 Maybe we can allow unkeyed fields in test files. I’ll try to see if that’s possible. |
This commit separates an unresolved row-level locking target from a new row-level physical property struct. The former is used to represent a row-level locking clause that is then "resolved" to specific relational operators. Once attached to a specific operator, the locking mode no longer needs to include a target, so it makes sense to represent it as a separate struct.
This addresses @RaduBerinde's comment from #60719.
I think it's correct to call row-level locking a "physical property", but I could be wrong about that.