mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-09 21:42:05 +00:00
Postgresql: Add REPLICA IDENTITY
operation for ALTER TABLE
(#1844)
This commit is contained in:
parent
74a95fdbd1
commit
c6e897dc12
5 changed files with 80 additions and 2 deletions
|
@ -8774,6 +8774,23 @@ impl<'a> Parser<'a> {
|
|||
let equals = self.consume_token(&Token::Eq);
|
||||
let value = self.parse_number_value()?;
|
||||
AlterTableOperation::AutoIncrement { equals, value }
|
||||
} else if self.parse_keywords(&[Keyword::REPLICA, Keyword::IDENTITY]) {
|
||||
let identity = if self.parse_keyword(Keyword::NONE) {
|
||||
ReplicaIdentity::None
|
||||
} else if self.parse_keyword(Keyword::FULL) {
|
||||
ReplicaIdentity::Full
|
||||
} else if self.parse_keyword(Keyword::DEFAULT) {
|
||||
ReplicaIdentity::Default
|
||||
} else if self.parse_keywords(&[Keyword::USING, Keyword::INDEX]) {
|
||||
ReplicaIdentity::Index(self.parse_identifier()?)
|
||||
} else {
|
||||
return self.expected(
|
||||
"NONE, FULL, DEFAULT, or USING INDEX index_name after REPLICA IDENTITY",
|
||||
self.peek_token(),
|
||||
);
|
||||
};
|
||||
|
||||
AlterTableOperation::ReplicaIdentity { identity }
|
||||
} else {
|
||||
let options: Vec<SqlOption> =
|
||||
self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;
|
||||
|
@ -8783,7 +8800,7 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
} else {
|
||||
return self.expected(
|
||||
"ADD, RENAME, PARTITION, SWAP, DROP, or SET TBLPROPERTIES after ALTER TABLE",
|
||||
"ADD, RENAME, PARTITION, SWAP, DROP, REPLICA IDENTITY, or SET TBLPROPERTIES after ALTER TABLE",
|
||||
self.peek_token(),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue