sql: fix STORING clause position for hash sharded indexes in pg_indexes#161882
Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom Jan 27, 2026
Merged
Conversation
Member
Previously, when displaying hash sharded indexes with STORING columns in pg_indexes, the STORING clause appeared after the WITH (bucket_count=...) clause. This produced invalid SQL that could not be re-executed: CREATE INDEX idx ON tbl USING btree (c1, c2) USING HASH WITH (bucket_count=16) STORING (c3) The SQL grammar requires STORING to come before storage parameters. This commit fixes the output order so that STORING appears before WITH (bucket_count=...): CREATE INDEX idx ON tbl USING btree (c1, c2) USING HASH STORING (c3) WITH (bucket_count=16) This matches the grammar and allows the statement to be re-executed. This bug was introduced in cockroachdb#76112. Fixes cockroachdb#161516 Release note (bug fix): Fixed a bug where the index definition shown in pg_indexes for hash sharded indexes with STORING columns was not valid SQL. The STORING clause now appears in the correct position.
072168d to
2fa6991
Compare
fqazi
approved these changes
Jan 27, 2026
Collaborator
fqazi
left a comment
There was a problem hiding this comment.
@fqazi reviewed 4 files and all commit messages, and made 1 comment.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball and @eric-alton).
Contributor
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.
Previously, when displaying hash sharded indexes with STORING columns in pg_indexes, the STORING clause appeared after the WITH (bucket_count=...) clause. This produced invalid SQL that could not be re-executed:
The SQL grammar requires STORING to come before storage parameters.
This commit fixes the output order so that STORING appears before WITH (bucket_count=...):
This matches the grammar and allows the statement to be re-executed.
This bug was introduced in #76112.
Fixes #161516
Release note (bug fix): Fixed a bug where the index definition shown in pg_indexes for hash sharded indexes with STORING columns was not valid SQL. The STORING clause now appears in the correct position.