Skip to content

Fix #1249: Correct REINDEX INDEX syntax to use single index instead of concatenating all - #1283

Merged
mrigger merged 1 commit into
sqlancer:mainfrom
guptapratykshh:fix-1249-reindex-syntax
Apr 5, 2026
Merged

mrigger merged 1 commit into
sqlancer:mainfrom
guptapratykshh:fix-1249-reindex-syntax

Conversation

@guptapratykshh

Copy link
Copy Markdown
Contributor

Fix #1249

This PR fixes an issue where PostgresReindexGenerator was incorrectly concatenating all index names without delimiters, generating invalid SQL like REINDEX INDEX i1i2i3. PostgreSQL only supports one index per REINDEX INDEX statement, so the fix now randomly selects a single index using Randomly.fromList(indexes).getIndexName() instead of joining all indexes together.

@guptapratykshh

Copy link
Copy Markdown
Contributor Author

ping @robins

@mrigger mrigger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for merging this late. We can also remove an expected error that actually shadowed this issue, it seems. I'll create a separate PR for that.

@mrigger
mrigger merged commit 89a48dd into sqlancer:main Apr 5, 2026
mrigger added a commit that referenced this pull request Apr 5, 2026
…exGenerator

Following the REINDEX syntax fix in PR #1283 (89a48dd), the "does not
exist" expected error is no longer needed. It was only masking the
previous bug where multiple index names were concatenated without
delimiters (e.g., REINDEX INDEX i0i1i2), causing PostgreSQL to report
that the concatenated name does not exist. With the fix now selecting a
single valid index, this error cannot legitimately occur since
getIndexes() only returns indexes that exist in the schema.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Postgres Bug Fix - Incorrect Syntax for REINDEX

2 participants