This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
The following commit(s) were added to refs/heads/main by this push:
new ed983e09 PostgreSQL: Fix REPLICA IDENTITY to use NOTHING (#2179)
ed983e09 is described below
commit ed983e09c24e2e4c9d4e6d9800c6a34e615efcb8
Author: Michael Victor Zink <[email protected]>
AuthorDate: Fri Jan 30 03:11:07 2026 -0800
PostgreSQL: Fix REPLICA IDENTITY to use NOTHING (#2179)
---
src/ast/ddl.rs | 10 +++++-----
src/parser/mod.rs | 6 +++---
tests/sqlparser_postgres.rs | 24 ++++++++++++++++++++++++
3 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/src/ast/ddl.rs b/src/ast/ddl.rs
index 3a5cd32b..1d0059db 100644
--- a/src/ast/ddl.rs
+++ b/src/ast/ddl.rs
@@ -99,8 +99,8 @@ impl fmt::Display for IndexColumn {
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum ReplicaIdentity {
- /// No replica identity (`REPLICA IDENTITY NONE`).
- None,
+ /// No replica identity (`REPLICA IDENTITY NOTHING`).
+ Nothing,
/// Full replica identity (`REPLICA IDENTITY FULL`).
Full,
/// Default replica identity (`REPLICA IDENTITY DEFAULT`).
@@ -112,7 +112,7 @@ pub enum ReplicaIdentity {
impl fmt::Display for ReplicaIdentity {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
- ReplicaIdentity::None => f.write_str("NONE"),
+ ReplicaIdentity::Nothing => f.write_str("NOTHING"),
ReplicaIdentity::Full => f.write_str("FULL"),
ReplicaIdentity::Default => f.write_str("DEFAULT"),
ReplicaIdentity::Index(idx) => write!(f, "USING INDEX {idx}"),
@@ -1911,7 +1911,7 @@ pub enum ColumnOption {
/// [ MATCH { FULL | PARTIAL | SIMPLE } ]
/// { [ON DELETE <referential_action>] [ON UPDATE <referential_action>] |
/// [ON UPDATE <referential_action>] [ON DELETE <referential_action>]
- /// }
+ /// }
/// [<constraint_characteristics>]
/// `).
ForeignKey(ForeignKeyConstraint),
@@ -4363,7 +4363,7 @@ impl Spanned for CreateExtension {
}
}
-/// DROP EXTENSION statement
+/// DROP EXTENSION statement
/// Note: this is a PostgreSQL-specific statement
///
/// # References
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 9b6b67bd..59ca4522 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -10145,8 +10145,8 @@ impl<'a> Parser<'a> {
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
+ let identity = if self.parse_keyword(Keyword::NOTHING) {
+ ReplicaIdentity::Nothing
} else if self.parse_keyword(Keyword::FULL) {
ReplicaIdentity::Full
} else if self.parse_keyword(Keyword::DEFAULT) {
@@ -10155,7 +10155,7 @@ impl<'a> Parser<'a> {
ReplicaIdentity::Index(self.parse_identifier()?)
} else {
return self.expected(
- "NONE, FULL, DEFAULT, or USING INDEX index_name after
REPLICA IDENTITY",
+ "NOTHING, FULL, DEFAULT, or USING INDEX index_name after
REPLICA IDENTITY",
self.peek_token(),
);
};
diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs
index a449eebc..54e9ee0c 100644
--- a/tests/sqlparser_postgres.rs
+++ b/tests/sqlparser_postgres.rs
@@ -6643,6 +6643,30 @@ fn parse_alter_table_replica_identity() {
}
_ => unreachable!(),
}
+
+ match pg_and_generic().verified_stmt("ALTER TABLE foo REPLICA IDENTITY
NOTHING") {
+ Statement::AlterTable(AlterTable { operations, .. }) => {
+ assert_eq!(
+ operations,
+ vec![AlterTableOperation::ReplicaIdentity {
+ identity: ReplicaIdentity::Nothing
+ }]
+ );
+ }
+ _ => unreachable!(),
+ }
+
+ match pg_and_generic().verified_stmt("ALTER TABLE foo REPLICA IDENTITY
DEFAULT") {
+ Statement::AlterTable(AlterTable { operations, .. }) => {
+ assert_eq!(
+ operations,
+ vec![AlterTableOperation::ReplicaIdentity {
+ identity: ReplicaIdentity::Default
+ }]
+ );
+ }
+ _ => unreachable!(),
+ }
}
#[test]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]