release-26.1: scbuild: fix CREATE INDEX on PARTITION ALL BY tables with explicit PK columns#164754
Merged
rafiss merged 1 commit intocockroachdb:release-26.1from Mar 6, 2026
Conversation
… columns Previously, when creating an index on a table with PARTITION ALL BY, the declarative schema changer's `maybeAddPartitionDescriptorForIndex` looked for columns marked as `Implicit` on the source index to determine partition columns. This failed when partition columns were explicitly part of the primary key, since those columns aren't marked as implicit. This caused CREATE INDEX to fail during PostCommitNonRevertiblePhase with "table has PARTITION ALL BY defined, but index does not have matching PARTITION BY". To address this, the code now uses `NumColumns` from the source index's `IndexPartitioning` element to get the first N key columns regardless of whether they're marked implicit. The partitioning descriptor is cloned from the source index and `NumImplicitColumns` is updated after column prepending to reflect the actual number of implicitly added columns. This also includes a minor fix to show the column name for stored columns in the crdb_internal.index_columns table, which we use for testing this change. Release note (bug fix): Fixed a bug where CREATE INDEX on a table with PARTITION ALL BY would fail if the partition columns were explicitly included in the primary key definition.
|
Thanks for opening a backport. Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate. |
Member
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 1/1 commits from #161083 on behalf of @rafiss.
Previously, when creating an index on a table with PARTITION ALL BY, the declarative schema changer's
maybeAddPartitionDescriptorForIndexlooked for columns marked asImpliciton the source index to determine partition columns. This failed when partition columns were explicitly part of the primary key, since those columns aren't marked as implicit. This caused CREATE INDEX to fail during PostCommitNonRevertiblePhase with "table has PARTITION ALL BY defined, but index does not have matching PARTITION BY".To address this, the code now uses
NumColumnsfrom the source index'sIndexPartitioningelement to get the first N key columns regardless of whether they're marked implicit. The partitioning descriptor is cloned from the source index andNumImplicitColumnsis updated after column prepending to reflect the actual number of implicitly added columns.Epic: None
resolves https://github.com/cockroachlabs/support/issues/3521
Release note (bug fix): Fixed a bug where CREATE INDEX on a table with PARTITION ALL BY would fail if the partition columns were explicitly included in the primary key definition.
Release justification: bug fix