feat: add support for index storage parameters (reloptions)#478
Open
ayusssmaan wants to merge 4 commits into
Open
feat: add support for index storage parameters (reloptions)#478ayusssmaan wants to merge 4 commits into
ayusssmaan wants to merge 4 commits into
Conversation
Add support for index WITH (...) storage parameters such as fillfactor, deduplicate_items, gin_pending_list_limit, fastupdate. - ir.go: add StorageParameters []string field to Index struct - queries.sql.go: fetch pg_class.reloptions via COALESCE in index_base CTE - inspector.go: map reloptions array to StorageParameters on Index - table.go: order-insensitive StorageParameters comparison in indexesStructurallyEqual - index.go: emit WITH (...) clause in generateIndexSQLWithName after NULLS NOT DISTINCT and before WHERE
Greptile SummaryThis PR adds support for index storage parameters in schema inspection and diff output. The main changes are:
Confidence Score: 3/5This should be fixed before merging.
internal/plan/rewrite.go and ir/queries/queries.sql need follow-up. Important Files Changed
Reviews (1): Last reviewed commit: "test: add fixture for index reloptions s..." | Re-trigger Greptile |
- ir/queries/queries.sql: add COALESCE(i.reloptions, '{}') AS reloptions to
GetIndexesForSchema CTE and SELECT so the sqlc source matches the generated
queries.sql.go (fixes generated-code drift flagged by Greptile)
- internal/plan/rewrite.go: emit WITH (...) for storage parameters in the
online plan path's generateIndexSQL so CONCURRENTLY-built indexes also
include reloptions (fixes gap flagged by Greptile)
Generate expected output files for the add_index_with_reloptions fixture so TestPlanAndApply passes in CI.
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.
pgschema was silently ignoring storage parameters (
WITH (...)clauses) onindexes. This caused indexes created with options like
fillfactor=90ordeduplicate_items=offto appear as a diff on every run — pgschema wouldrepeatedly re-create them because the emitted
CREATE INDEXDDL omitted theWITHclause, so the live index never matched the model.What changed
ir/queries/queries.sql.go: querypg_class.reloptionsfor each indexir/ir.go: addStorageParameters []stringfield toIndexDefir/inspector.go: populateStorageParametersfrom query resultsinternal/diff/table.go: emitWITH (...)inCREATE INDEXDDL whenstorage parameters are present, preserving Postgres-returned order
Test
New fixture
testdata/diff/create_index/add_index_with_reloptions/covers:WITH (fillfactor=90)WITH (fillfactor=100, deduplicate_items=true)WHEREclauseAll pre-existing tests continue to pass.