-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: rename ScalarID to ScalarRank #71037
Conversation
The first commit is from #71035. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r1, 7 of 7 files at r2, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @RaduBerinde)
pkg/sql/opt/norm/select_funcs.go, line 278 at r2 (raw file):
// AreFiltersSorted determines whether the expressions in a FiltersExpr are // ordered by their expression IDs.
IDs -> ranks
Previously, every scalar expression (except lists and list items) had an ID that was said to be unique within the context of a memo. These IDs were originally added as a way to canonically order filters. Being named "IDs", their use later expanded to check for equality of two scalar expressions. Maintaining this uniqueness invariant is difficult in practice and has dangerous implications when it is violated, as seen in cockroachdb#71002. While two different scalar expressions with the same ID could certainly cause problems for sorting filters, using these IDs to check for scalar expression equality can be catastrophic. For example, a filter expression that shares an ID with another expression could be completely removed from the filter. Unfortunately, there's no obvious way to add test build assertions that scalar IDs are in fact unique, as explained in cockroachdb#71035. In order to lessen the blast radius of breaking this invariant, this commit renames "scalar ID" to "scalar rank". The comment for this attribute does not explicitly guarantee its uniqueness. This renaming should urge contributors to only use this value for ordering scalar expressions canonically, not for scalar expression equality. Instead, pointer equality should be used to check if two scalar expressions are the same. Release note: None
bac2889
to
eae5076
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @RaduBerinde and @rytaft)
pkg/sql/opt/norm/select_funcs.go, line 278 at r2 (raw file):
Previously, rytaft (Rebecca Taft) wrote…
IDs -> ranks
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @RaduBerinde)
TFTR! bors r+ |
Build succeeded: |
Previously, every scalar expression (except lists and list items) had an
ID that was said to be unique within the context of a memo. These IDs
were originally added as a way to canonically order filters. Being named
"IDs", their use later expanded to check for equality of two scalar
expressions.
Maintaining this uniqueness invariant is difficult in practice and has
dangerous implications when it is violated, as seen in #71002. While two
different scalar expressions with the same ID could certainly cause
problems for sorting filters, using these IDs to check for scalar
expression equality can be catastrophic. For example, a filter
expression that shares an ID with another expression could be completely
removed from the filter.
Unfortunately, there's no obvious way to add test build assertions that
scalar IDs are in fact unique, as explained in #71035. In order to
lessen the blast radius of breaking this invariant, this commit renames
"scalar ID" to "scalar rank". The comment for this attribute does not
explicitly guarantee its uniqueness. This renaming should urge
contributors to only use this value for ordering scalar expressions
canonically, not for scalar expression equality. Instead, pointer
equality should be used to check if two scalar expressions are the same.
Release note: None