iffyio commented on code in PR #2213:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2213#discussion_r2821301988
##########
src/parser/mod.rs:
##########
@@ -9375,6 +9391,22 @@ impl<'a> Parser<'a> {
// after `PRIMARY` always stay `KEY`
self.expect_keyword_is(Keyword::KEY)?;
+ // PostgreSQL: PRIMARY KEY USING INDEX index_name
+ // https://www.postgresql.org/docs/current/sql-altertable.html
+ if self.parse_keywords(&[Keyword::USING, Keyword::INDEX]) {
+ let index_name = self.parse_identifier()?;
+ let characteristics =
self.parse_constraint_characteristics()?;
+ return Ok(Some(
+ ConstraintUsingIndex {
+ name,
+ is_primary_key: true,
+ index_name,
+ characteristics,
+ }
+ .into(),
+ ));
+ }
Review Comment:
can we pull this out into a e.g. `parse_constraint_using_index()` function
so that it can be reused across both cases?
Also repr wise, I think it would be clearer to have both cases as unique
variants on the `TableConstraint` enum vs using the `is_primary_key` bool to
differentiate. i.e.
```rust
TableConstraint::UniqueUsingIndex(ConstraintUsingIndex)
TableConstraint::PrimaryKeyUsingIndex(ConstraintUsingIndex)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]