@@ -5097,12 +5097,16 @@ impl<'a> Parser<'a> {
50975097 let temporary = self
50985098 .parse_one_of_keywords(&[Keyword::TEMP, Keyword::TEMPORARY])
50995099 .is_some();
5100+ let unlogged = dialect_of!(self is PostgreSqlDialect | GenericDialect)
5101+ && self.parse_keyword(Keyword::UNLOGGED);
51005102 let persistent = dialect_of!(self is DuckDbDialect)
51015103 && self.parse_one_of_keywords(&[Keyword::PERSISTENT]).is_some();
51025104 let create_view_params = self.parse_create_view_params()?;
51035105 if self.parse_keyword(Keyword::TABLE) {
5104- self.parse_create_table(or_replace, temporary, global, transient)
5106+ self.parse_create_table(or_replace, temporary, unlogged, global, transient)
51055107 .map(Into::into)
5108+ } else if unlogged {
5109+ self.expected_ref("TABLE after UNLOGGED", self.peek_token_ref())
51065110 } else if self.peek_keyword(Keyword::MATERIALIZED)
51075111 || self.peek_keyword(Keyword::VIEW)
51085112 || self.peek_keywords(&[Keyword::SECURE, Keyword::MATERIALIZED, Keyword::VIEW])
@@ -8264,6 +8268,7 @@ impl<'a> Parser<'a> {
82648268 &mut self,
82658269 or_replace: bool,
82668270 temporary: bool,
8271+ unlogged: bool,
82678272 global: Option<bool>,
82688273 transient: bool,
82698274 ) -> Result<CreateTable, ParserError> {
@@ -8382,6 +8387,7 @@ impl<'a> Parser<'a> {
83828387
83838388 Ok(CreateTableBuilder::new(table_name)
83848389 .temporary(temporary)
8390+ .unlogged(unlogged)
83858391 .columns(columns)
83868392 .constraints(constraints)
83878393 .or_replace(or_replace)
@@ -10377,21 +10383,31 @@ impl<'a> Parser<'a> {
1037710383 let name = self.parse_identifier()?;
1037810384 AlterTableOperation::ValidateConstraint { name }
1037910385 } else {
10380- let mut options =
10381- self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;
10382- if !options.is_empty() {
10383- AlterTableOperation::SetTblProperties {
10384- table_properties: options,
10385- }
10386+ if dialect_of!(self is PostgreSqlDialect | GenericDialect)
10387+ && self.parse_keywords(&[Keyword::SET, Keyword::LOGGED])
10388+ {
10389+ AlterTableOperation::SetLogged
10390+ } else if dialect_of!(self is PostgreSqlDialect | GenericDialect)
10391+ && self.parse_keywords(&[Keyword::SET, Keyword::UNLOGGED])
10392+ {
10393+ AlterTableOperation::SetUnlogged
1038610394 } else {
10387- options = self.parse_options(Keyword::SET)?;
10395+ let mut options =
10396+ self.parse_options_with_keywords(&[Keyword::SET, Keyword::TBLPROPERTIES])?;
1038810397 if !options.is_empty() {
10389- AlterTableOperation::SetOptionsParens { options }
10398+ AlterTableOperation::SetTblProperties {
10399+ table_properties: options,
10400+ }
1039010401 } else {
10391- return self.expected_ref(
10392- "ADD, RENAME, PARTITION, SWAP, DROP, REPLICA IDENTITY, SET, or SET TBLPROPERTIES after ALTER TABLE",
10393- self.peek_token_ref(),
10394- );
10402+ options = self.parse_options(Keyword::SET)?;
10403+ if !options.is_empty() {
10404+ AlterTableOperation::SetOptionsParens { options }
10405+ } else {
10406+ return self.expected_ref(
10407+ "ADD, RENAME, PARTITION, SWAP, DROP, REPLICA IDENTITY, SET, or SET TBLPROPERTIES after ALTER TABLE",
10408+ self.peek_token_ref(),
10409+ );
10410+ }
1039510411 }
1039610412 }
1039710413 };
0 commit comments