Skip to content

PostgreSQL: Parse index expressions in ON CONFLICT targets - #3085

Draft
icefery wants to merge 1 commit into
apache:mainfrom
icefery:postgres/conflict-index-target
Draft

icefery wants to merge 1 commit into
apache:mainfrom
icefery:postgres/conflict-index-target

Conversation

@icefery

@icefery icefery commented Dec 1, 2026

Copy link
Copy Markdown

Dialects: PostgreSQL, Generic

INSERT INTO t SELECT a, b FROM src ON CONFLICT (a, COALESCE(b, '')) DO NOTHING fails because the target parser only accepts identifiers. Use IndexColumn and the existing index column parser so the target can contain expressions, collations, and operator class names. The target's WHERE predicate remains separate from the DO UPDATE condition. Other dialects keep their current parsing behavior.

PostgreSQL INSERT syntax · Index inference grammar

27 focused tests passed with all features, including SQLite regressions. Rustfmt and Clippy on the library and affected test targets passed. The round-trip fuzzer completed 512 instrumented runs.

AI assistance was used for the implementation, tests, and draft.

Reuse the CREATE INDEX column parser for PostgreSQL and Generic conflict inference.
Preserve the index predicate and the update condition as distinct expressions.
@icefery
icefery marked this pull request as draft December 1, 2026 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant