-
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.
55702: sql: fix partial index and foreign key bugs r=mgartner a=mgartner #### opt: build partial index predicates only when all table columns are in scope This commit fixes a panic induced by trying to build partial index predicate expressions without all of a table's columns in-scope. Some scans, like scans built for foreign key checks, do not include all of a table's column in their scope. For such scans, optbuilder no longer attempts to build a partial index predicate because the predicate may reference a column that is not in scope. As a result of this change, `opt.TableMeta` may not have a predicate expression for all partial indexes. The `memo.PartialIndexPredicate` function which retrieves the predicate expressions has been updated to account for this case. Fixes #55672 Release justification: This is a critical bug fix for a new feature, partial indexes. Release note (bug fix): An INSERT into a table with a foreign key reference to a table with a partial index no longer causes an error. #### sql: disqualify partial unique indexes as foreign key reference indexes Release justification: This is a critical bug fix for a new feature, partial indexes. Release note (bug fix): Foreign keys can no longer reference columns that are only indexed by a partial unique index. A partial unique index does not guarantee uniqueness in the entire table, therefore the column indexed is not guaranteed to be a unique key. Co-authored-by: Marcus Gartner <marcus@cockroachlabs.com>
- Loading branch information
Showing
10 changed files
with
148 additions
and
22 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
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