release-20.2: opt: build all partial index predicate expressions in TableMeta #58274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 2/2 commits from #57707. The backport #58272 relies on these changes.
/cc @cockroachdb/release
opt: build all partial index predicate expressions in TableMeta
Previously, partial index predicates were only built and added to
TableMeta.PartialIndexPredicates
if the scope of the scan inBuilder.buildScan
included all ordinary table columns. This behaviorprevented errors when building partial index predicate expressions for
foriegn key check scans. These scans do not include all columns, so when
building a predicate expression that referenced a table column not
included, optbuilder would err with "column does not exist".
This commit changes this behavior so that partial index predicates are
always built and added to
TableMeta.PartialIndexPredicates
. In orderto do this,
Builder.addPartialIndexPredicatesForTable
creates its owntable scope. It also constructs a new scan rather than relying on the
already-built scan. Constructing a scan is required for considering
logical properties while normalizing partial index predicates.
See discussion at #57622
for more context on this change.
Release note: None
optbuilder: reduce redundant building of arbiter filter expressions
Previously, the arbiter predicate provided in the
WHERE
clause of anINSERT ... ON CONFLICT
statement was rebuilt as amemo.FiltersExpr
repetitively while the optbuilder determined arbiter indexes. Now, the
expression is built only once, reducing work.
Release note: None