Skip to content

Name an unnamed CREATE INDEX the way PostgreSQL does - #168

Merged
LucaCappelletti94 merged 2 commits into
mainfrom
upstream/unnamed-create-index
Oct 28, 2026
Merged

LucaCappelletti94 merged 2 commits into
mainfrom
upstream/unnamed-create-index

Conversation

@LucaCappelletti94

Copy link
Copy Markdown
Collaborator

PostgreSQL accepts an index written without a name, such as CREATE INDEX ON t (s), and names it itself. pg2sqlite copied the missing name into its output, so SQLite saw CREATE INDEX ON t(s) and refused it as a syntax error, and a later DROP INDEX t_s_idx written against the server's name failed before translation because the catalog held the index without one.

Each unnamed index now gets the name PostgreSQL 17 gives it, asked of sql-traits against the catalog as it stands just before the statement, so counters, clashes with other relations and names freed by an earlier DROP INDEX come out as on the server. The name is written into the statement before anything else reads it, which also lets an unnamed NULLS NOT DISTINCT index name its companion where it used to be refused. An index whose name sql-traits cannot predict is refused with a request to name it, since emitting it unnamed is what SQLite rejects. A gauntlet test compares the index names SQLite ends up with against pg_indexes on a live PostgreSQL.

This needs connetto-rs/sql-traits#146 for ParserDBIngestor::create_index_name, so CI here stays red until that merges.

@LucaCappelletti94 LucaCappelletti94 added bug Something isn't working rust Pull requests that update rust code labels Oct 27, 2026
@LucaCappelletti94
LucaCappelletti94 force-pushed the upstream/unnamed-create-index branch from 8652b70 to 3fc9176 Compare October 28, 2026 12:44
@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@LucaCappelletti94
LucaCappelletti94 merged commit 83be933 into main Oct 28, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant