apache / apache/datafusion-sqlparser-rs

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

未關閉
#2,132 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Rust
星號
3.5k
分支
772
平均合併
4 天 9 小時
30 天內合併 PR
17

描述

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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

先定位 Rust SQL 解析器中的 ALTER TABLE 文法以及資料表約束的處理方式。使用此 issue 中的 PostgreSQL 範例作為解析輸入,接著為 PRIMARY KEY USING INDEX 新增涵蓋範圍,並確認該陳述式不需要欄位清單即可解析。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
postgresql, rust, sql
領域
compilers, databases
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。