apache / apache/datafusion-sqlparser-rs

PostgreSQL: Support `PRIMARY KEY USING INDEX` syntax in `ALTER TABLE`

Offen
#2,132 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Rust
Sterne
3.5k
Forks
772
Ø Merge
4 T. 9 Std.
Gemergte PRs (30 T.)
17

Beschreibung

The parser fails to parse the PostgreSQL-specific `PRIMARY KEY USING INDEX index_name` syntax in `ALTER TABLE` statements:

```sql
ALTER TABLE version_downloads
ADD CONSTRAINT version_downloads_pkey PRIMARY KEY USING INDEX version_downloads_unique;
```

```
Expected: a list of columns in parentheses, found: INDEX
```

## Expected behavior

This is valid PostgreSQL syntax per the [ALTER TABLE documentation](https://www.postgresql.org/docs/current/sql-altertable.html). The grammar allows:

```
ADD table_constraint_using_index
```

Where `table_constraint_using_index` can be:

```
[ CONSTRAINT constraint_name ]
{ UNIQUE | PRIMARY KEY } USING INDEX index_name
[ DEFERRABLE | NOT DEFERRABLE ] [ INITIALLY DEFERRED | INITIALLY IMMEDIATE ]
```

Note that `PRIMARY KEY USING INDEX index_name` is a distinct form that does **not** require a column list - it promotes an existing unique index to be the primary key constraint.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne damit, die ALTER TABLE-Grammatik und die Verarbeitung von Tabellen-Constraints im Rust-SQL-Parser zu lokalisieren. Verwende das PostgreSQL-Beispiel aus diesem Issue als Parsing-Eingabe, füge dann Abdeckung für PRIMARY KEY USING INDEX hinzu und bestätige, dass das Statement geparst wird, ohne eine Spaltenliste zu erfordern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
postgresql, rust, sql
Bereich
compilers, databases
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.