forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opt: fix FK cascading updates to child tables with partial indexes
This commit fixes several bugs that are present when using foreign key cascading updates and partial indexes. Previously, the optimizer was not synthesizing partial index DEL columns for FK cascading updates. As a result, a partial index on a child table could become inconsistent with the rows in the primary index, ultimately resulting in incorrect query results. The optbuilder has been refactored to project these columns and to reduce the complexity of doing so. As a result, partial index PUT and DEL columns are now projected in the same expression, rather than the DEL columns being projected as far down in the expression tree as possible. Additionally, the execution engine was unable to handle extraneous columns that can be added as input to FK cascading updates. These extraneous columns would be incorrectly interpreted as synthesized partial index columns. This commit works around this issue by passing a set of partial indexes that columns have been synthesized for from the optimizer to the execution engine. The longer term fix is to not produce these columns (see issue cockroachdb#57097). Fixes cockroachdb#57085 Fixes cockroachdb#57084 Release justification: This is a critical bug fix to a new feature, partial indexes. Release note (bug fix): Previously, updating parent table of a foreign key relationship with cascading updates could cause errors or inconsistencies in partial indexes for child tables with partial indexes. The inconsistency of partial indexes could result in incorrect query results. This has been fixed.
- Loading branch information
Showing
14 changed files
with
387 additions
and
310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.