-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
57100: opt: fix FK cascades to child tables with partial indexes r=mgartner a=mgartner Previously, the optimizer was not synthesizing partial index DEL columns for FK cascading updates and deletes. As a result, a cascading `UPDATE` could corrupt a child table's partial index, ultimately resulting in incorrect query results. A cascading `DELETE` would not corrupt partial indexes, but unnecessary `DEL` operations would be issued on the partial index. The optbuilder has been refactored so that these columns are correctly projected. There are now three functions for projecting PUT columns, DEL columns, and both PUT and DEL columns, each ensuring that the input scopes are non-nil. These three functions are called from principal functions in the optbuilder where CHECK constraint columns are also projected, like `mutationBuilder.buildUpdate`. In theory this should make it harder in the future to omit these necessary projections. 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 slicing the source values with an upper bound in `updateNode.processSourceRow`. The longer term fix is to not produce these columns (see issue #57097). Fixes #57085 Fixes #57084 Release justification: This is a critical bug fix to a new feature, partial indexes. Release note (bug fix): A bug has been fixed that caused errors or corrupted partial indexes of child tables in foreign key relationships with cascading `UPDATE`s and `DELETE`s. The corrupt partial indexes could result in incorrect query results. Any partial indexes on child tables of foreign key relationships with `ON DELETE CASCADE` or `ON UPDATE CASCADE` actions may be corrupt and should be dropped and re-created. This bug was introduce in version 20.2. 57323: authors: add Paul Kernfeld to authors r=kernfeld-cockroach a=kernfeld-cockroach Release note: None 57324: authors: add ricky to authors r=rickystewart a=rickystewart Release note: None Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: Paul Kernfeld <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
- Loading branch information
Showing
19 changed files
with
1,206 additions
and
329 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -240,6 +240,7 @@ Owen Qian <[email protected]> <[email protected]> | |
Panos Mamatsis <[email protected]> | ||
Paul Banks <[email protected]> | ||
Paul Bardea <[email protected]> <[email protected]> <@cockroachlabs.com> | ||
Paul Kernfeld <[email protected]> | ||
Paul Logston <[email protected]> <[email protected]> | ||
Peng Gao <[email protected]> | ||
Pete Vilter <[email protected]> <[email protected]> | ||
|
@@ -260,6 +261,7 @@ Rich Loveland <[email protected]> <[email protected]> Richard Love | |
Richard Artoul <[email protected]> | ||
Richard Cai <[email protected]> richardjcai <[email protected]> | ||
Richard Wu <[email protected]> <@cockroachlabs.com> | ||
Ricky Stewart <[email protected]> <[email protected]> | ||
Ridwan Sharif <[email protected]> <[email protected]> | ||
Rohan Yadav <[email protected]> <[email protected]> rohany <[email protected]> | ||
Roland Crosby <[email protected]> | ||
|
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.