Skip to content

Fix multiline expression index handling - #303

Draft
Pybsama wants to merge 1 commit into
stripe:mainfrom
Pybsama:codex/fix-multiline-expression-index
Draft

Fix multiline expression index handling#303
Pybsama wants to merge 1 commit into
stripe:mainfrom
Pybsama:codex/fix-multiline-expression-index

Conversation

@Pybsama

@Pybsama Pybsama commented Jul 30, 2026

Copy link
Copy Markdown

Description

pg_get_indexdef can preserve newlines inside expression index definitions. The existing anchored rewrite uses .*, which does not match newlines in Go, so converting a valid definition to CREATE INDEX CONCURRENTLY fails. The same conversion is also used while validating plans with concurrent index operations disabled.

This change enables dot-all matching only for the existing regex, preserving its anchors, case sensitivity, and exact CREATE [UNIQUE] INDEX prefix. It adds regression coverage for:

  • the direct statement conversion;
  • adding a multiline expression index through the default concurrent path;
  • validating a migration with an existing multiline expression index under WithNoConcurrentIndexOps().

Testing

  • GOTOOLCHAIN=go1.25.5 go test -race ./... -timeout 30m
  • focused conversion test, 100 repetitions
  • both PostgreSQL 17.10 acceptance scenarios, 10 repetitions
  • golangci-lint v2.7.0 run
  • go vet ./...
  • sqlfluff 3.3.0 lint
  • gofmt, go mod tidy -diff, and git diff --check

The commit is GitHub Verified.

Fixes #253

Allow CREATE INDEX rewrites to span newlines preserved by pg_get_indexdef, and cover both concurrent creation and non-concurrent plan validation.

Fixes stripe#253
@cla-assistant

cla-assistant Bot commented Jul 30, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Pybsama

Pybsama commented Aug 29, 2026

Copy link
Copy Markdown
Author

Revalidated this change against current main at 9ada4710c28718312557c84cca1be4b2557eed54. The one commit since the PR base only changes materialized-view handling; the PR applies without conflicts, and the exact current-main merge tree is 6e3c23613b66d86b32aae0f226f2a7fefadaab50.

Current-main validation:

  • restoring the old single-line regex makes all three regressions fail independently: direct conversion, default concurrent index creation, and WithNoConcurrentIndexOps() plan validation
  • restoring (?s) makes all three pass
  • Go 1.25.5: full go test -race ./... -timeout 30m passed; the acceptance package completed in 145.747s
  • focused conversion: 100/100 repetitions
  • both PostgreSQL 17.10 acceptance scenarios: 10/10 repetitions
  • golangci-lint 2.7.0 with Go 1.25.5: 0 issues; go vet ./... passed
  • sqlfluff 3.3.0: passed; gofmt, go mod tidy -diff, and git diff --check: clean
  • the multiline-string dry-run still names only the two unchanged baseline files (policy_cases_test.go and privilege_cases_test.go); neither new acceptance-test file is reported

The public head remains the original GitHub-verified commit because GitHub reports the PR as mergeable and the current-main change does not overlap the patch.

license/cla is still pending and the CLA assistant reports it as not signed. I am therefore keeping the PR in Draft until the contributor completes that personal legal step; no CLA action or recheck was performed here.

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.

[BUG] Failing to handle indexes with expressions in

1 participant