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.

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