apache / apache/datafusion-sqlparser-rs
PostgreSQL: Support `PRIMARY KEY USING INDEX` syntax in `ALTER TABLE`
- 主要语言
- 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