From c8d85cc646de98b20b378c95b676b3eb8b9a7f04 Mon Sep 17 00:00:00 2001 From: icefery Date: Tue, 1 Dec 2026 21:08:40 +0800 Subject: [PATCH] PostgreSQL: Support ALTER MATERIALIZED VIEW column options and storage Share column SET, RESET, and SET STORAGE parsing with ALTER TABLE. Keep STORAGE DEFAULT specific to column alterations. --- ...alter_materialized_view_column_options.sql | 3 + src/ast/ddl.rs | 41 ++- src/ast/spans.rs | 6 + src/dialect/generic.rs | 4 + src/dialect/mod.rs | 6 + src/dialect/postgresql.rs | 4 + src/parser/mod.rs | 115 ++++++--- tests/sqlparser_postgres.rs | 243 +++++++++++++++--- 8 files changed, 343 insertions(+), 79 deletions(-) create mode 100644 fuzz/fuzz_seeds/postgres_alter_materialized_view_column_options.sql diff --git a/fuzz/fuzz_seeds/postgres_alter_materialized_view_column_options.sql b/fuzz/fuzz_seeds/postgres_alter_materialized_view_column_options.sql new file mode 100644 index 0000000000..378a38f68a --- /dev/null +++ b/fuzz/fuzz_seeds/postgres_alter_materialized_view_column_options.sql @@ -0,0 +1,3 @@ +ALTER MATERIALIZED VIEW IF EXISTS v ALTER c SET (n_distinct = -0.5, n_distinct_inherited = 3); +ALTER MATERIALIZED VIEW v ALTER COLUMN c RESET (n_distinct, n_distinct_inherited); +ALTER MATERIALIZED VIEW v ALTER c SET STORAGE DEFAULT; diff --git a/src/ast/ddl.rs b/src/ast/ddl.rs index 7b583ca746..5c774d2f18 100644 --- a/src/ast/ddl.rs +++ b/src/ast/ddl.rs @@ -1415,7 +1415,7 @@ impl fmt::Display for OperatorOption { } } -/// An `ALTER COLUMN` (`Statement::AlterTable`) operation +/// An `ALTER COLUMN` operation in `ALTER TABLE` or `ALTER [ MATERIALIZED ] VIEW`. #[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "visitor", derive(Visit, VisitMut))] @@ -1461,12 +1461,12 @@ pub enum AlterColumnOperation { /// Whether `IF EXISTS` was specified. if_exists: bool, }, - /// `SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN }` + /// `SET STORAGE { PLAIN | EXTERNAL | EXTENDED | MAIN | DEFAULT }` /// /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-altertable.html) SetStorage { - /// The type of storage. - storage: UserDefinedTypeStorage, + /// The storage mode, or `None` for `DEFAULT`. + storage: Option, }, /// `OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ...] )`, changing the /// options of a foreign table column. @@ -1476,6 +1476,20 @@ pub enum AlterColumnOperation { /// The option changes, in source order. options: Vec, }, + /// `SET ( attribute_option [ = value ] [, ... ] )` + /// + /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-altertable.html) + SetOptions { + /// Options to set, using [`SqlOption::Ident`] when no value is given. + options: Vec, + }, + /// `RESET ( attribute_option [, ... ] )` + /// + /// [PostgreSQL](https://www.postgresql.org/docs/current/sql-altertable.html) + ResetOptions { + /// Option names to reset, possibly qualified. + options: Vec, + }, } impl fmt::Display for AlterColumnOperation { @@ -1536,12 +1550,19 @@ impl fmt::Display for AlterColumnOperation { } Ok(()) } - AlterColumnOperation::SetStorage { storage } => { - write!(f, "SET STORAGE {storage}") - } + AlterColumnOperation::SetStorage { storage } => match storage { + Some(storage) => write!(f, "SET STORAGE {storage}"), + None => write!(f, "SET STORAGE DEFAULT"), + }, AlterColumnOperation::GenericOptions { options } => { write!(f, "OPTIONS ({})", display_comma_separated(options)) } + AlterColumnOperation::SetOptions { options } => { + write!(f, "SET ({})", display_comma_separated(options)) + } + AlterColumnOperation::ResetOptions { options } => { + write!(f, "RESET ({})", display_comma_separated(options)) + } } } } @@ -5392,8 +5413,7 @@ impl Spanned for AlterCollation { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "visitor", derive(Visit, VisitMut))] pub struct AlterView { - /// Whether `MATERIALIZED` was specified. A materialized view's operation is never - /// [`AlterViewOperation::As`] or [`AlterViewOperation::AlterColumn`]. + /// Whether `MATERIALIZED` was specified. pub materialized: bool, /// View name being altered. #[cfg_attr(feature = "visitor", visit(with = "visit_relation"))] @@ -5428,11 +5448,12 @@ pub enum AlterViewOperation { }, /// ```sql /// ALTER VIEW name ALTER [ COLUMN ] column_name { SET DEFAULT expression | DROP DEFAULT } + /// ALTER MATERIALIZED VIEW name ALTER [ COLUMN ] column_name { SET (...) | RESET (...) | SET STORAGE mode } /// ``` AlterColumn { /// The column to alter. column_name: Ident, - /// Either [`AlterColumnOperation::SetDefault`] or [`AlterColumnOperation::DropDefault`]. + /// A column default operation, or an attribute option or storage change on a materialized view. op: AlterColumnOperation, }, /// ```sql diff --git a/src/ast/spans.rs b/src/ast/spans.rs index 4baf106c9a..acea3d5123 100644 --- a/src/ast/spans.rs +++ b/src/ast/spans.rs @@ -998,6 +998,12 @@ impl Spanned for AlterColumnOperation { AlterColumnOperation::GenericOptions { options } => { union_spans(options.iter().map(|option| option.span())) } + AlterColumnOperation::SetOptions { options } => { + union_spans(options.iter().map(|option| option.span())) + } + AlterColumnOperation::ResetOptions { options } => { + union_spans(options.iter().map(|option| option.span())) + } } } } diff --git a/src/dialect/generic.rs b/src/dialect/generic.rs index fdf3529054..759df0593f 100644 --- a/src/dialect/generic.rs +++ b/src/dialect/generic.rs @@ -145,6 +145,10 @@ impl Dialect for GenericDialect { true } + fn supports_alter_column_options(&self) -> bool { + true + } + fn supports_explain_with_utility_options(&self) -> bool { true } diff --git a/src/dialect/mod.rs b/src/dialect/mod.rs index b975805b5f..7ddccf01ba 100644 --- a/src/dialect/mod.rs +++ b/src/dialect/mod.rs @@ -1367,6 +1367,12 @@ pub trait Dialect: Debug + Any { false } + /// Whether `ALTER COLUMN` supports `SET (...)`, `RESET (...)`, and `SET STORAGE DEFAULT`, + /// as well as explicit `SET STORAGE` modes on materialized views. + fn supports_alter_column_options(&self) -> bool { + false + } + /// Whether `INTERVAL` expressions require units (called "qualifiers" in the ANSI SQL spec) to be specified, /// e.g. `INTERVAL 1 DAY` vs `INTERVAL 1`. /// diff --git a/src/dialect/postgresql.rs b/src/dialect/postgresql.rs index 4e7265cb02..d23fbdad93 100644 --- a/src/dialect/postgresql.rs +++ b/src/dialect/postgresql.rs @@ -409,6 +409,10 @@ impl Dialect for PostgreSqlDialect { true } + fn supports_alter_column_options(&self) -> bool { + true + } + /// see fn supports_explain_with_utility_options(&self) -> bool { true diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 2e653c7983..8601eef589 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -11473,19 +11473,25 @@ impl<'a> Parser<'a> { Token::Word(w) if w.keyword == Keyword::CLUSTERED && is_mssql => { self.parse_option_clustered() } - _ => { - let name = ObjectName::from(self.parse_period_separated(|p| p.parse_identifier())?); - if self.dialect.supports_sql_option_without_value() - && matches!(self.peek_token_ref().token, Token::Comma | Token::RParen) - { - return Ok(SqlOption::Ident(name)); - } - self.expect_token(&Token::Eq)?; - let value = self.parse_expr()?; + _ => self.parse_simple_sql_option(), + } + } - Ok(SqlOption::KeyValue { key: name, value }) - } + fn parse_sql_option_name(&mut self) -> Result { + self.parse_period_separated(Self::parse_identifier) + .map(ObjectName::from) + } + + fn parse_simple_sql_option(&mut self) -> Result { + let key = self.parse_sql_option_name()?; + if self.dialect.supports_sql_option_without_value() + && matches!(self.peek_token_ref().token, Token::Comma | Token::RParen) + { + return Ok(SqlOption::Ident(key)); } + self.expect_token(&Token::Eq)?; + let value = self.parse_expr()?; + Ok(SqlOption::KeyValue { key, value }) } /// Parse a `CLUSTERED` table option (MSSQL-specific syntaxes supported). @@ -11956,10 +11962,8 @@ impl<'a> Parser<'a> { AlterColumnOperation::GenericOptions { options: self.parse_alter_generic_options()?, } - } else if self.parse_keywords(&[Keyword::SET, Keyword::STORAGE]) { - AlterColumnOperation::SetStorage { - storage: self.parse_user_defined_type_storage()?, - } + } else if let Some(op) = self.parse_optional_alter_column_options(true)? { + op } else { let message = if is_postgresql { "SET/DROP NOT NULL, SET DEFAULT, SET DATA TYPE, ADD GENERATED, or OPTIONS after ALTER COLUMN" @@ -12154,6 +12158,43 @@ impl<'a> Parser<'a> { Ok(operation) } + fn parse_optional_alter_column_options( + &mut self, + is_alter_table: bool, + ) -> Result, ParserError> { + let supports_options = self.dialect.supports_alter_column_options(); + let op = if (is_alter_table || supports_options) + && self.parse_keywords(&[Keyword::SET, Keyword::STORAGE]) + { + let storage = if let Some(storage) = self.parse_optional_user_defined_type_storage() { + Some(storage) + } else if supports_options && self.parse_keyword(Keyword::DEFAULT) { + None + } else { + let expected = if supports_options { + "storage value (plain, external, extended, main, or default)" + } else { + "storage value (plain, external, extended, or main)" + }; + return self.expected_ref(expected, self.peek_token_ref()); + }; + AlterColumnOperation::SetStorage { storage } + } else if !supports_options { + return Ok(None); + } else if self.parse_keyword_with_tokens(Keyword::SET, &[Token::LParen]) { + let options = self.parse_comma_separated(Self::parse_simple_sql_option)?; + self.expect_token(&Token::RParen)?; + AlterColumnOperation::SetOptions { options } + } else if self.parse_keyword(Keyword::RESET) { + let options = + self.parse_parenthesized(|p| p.parse_comma_separated(Self::parse_sql_option_name))?; + AlterColumnOperation::ResetOptions { options } + } else { + return Ok(None); + }; + Ok(Some(op)) + } + fn parse_set_data_type(&mut self, had_set: bool) -> Result { let data_type = self.parse_data_type()?; let collation = if self.parse_keyword(Keyword::COLLATE) { @@ -12589,17 +12630,26 @@ impl<'a> Parser<'a> { } else if self.parse_keyword(Keyword::ALTER) { let _ = self.parse_keyword(Keyword::COLUMN); let column_name = self.parse_identifier()?; - let op = if self.parse_keywords(&[Keyword::SET, Keyword::DEFAULT]) { + let column_options = if materialized { + self.parse_optional_alter_column_options(false)? + } else { + None + }; + let op = if let Some(op) = column_options { + op + } else if self.parse_keywords(&[Keyword::SET, Keyword::DEFAULT]) { AlterColumnOperation::SetDefault { value: self.parse_expr()?, } } else if self.parse_keywords(&[Keyword::DROP, Keyword::DEFAULT]) { AlterColumnOperation::DropDefault } else { - return self.expected_ref( - "SET DEFAULT or DROP DEFAULT after ALTER COLUMN", - self.peek_token_ref(), - ); + let expected = if materialized && self.dialect.supports_alter_column_options() { + "SET DEFAULT, DROP DEFAULT, SET (...), RESET (...), or SET STORAGE after ALTER COLUMN" + } else { + "SET DEFAULT or DROP DEFAULT after ALTER COLUMN" + }; + return self.expected_ref(expected, self.peek_token_ref()); }; AlterViewOperation::AlterColumn { column_name, op } } else { @@ -22752,9 +22802,13 @@ impl<'a> Parser<'a> { } Some(Keyword::STORAGE) => { self.expect_token(&Token::Eq)?; - Ok(UserDefinedTypeSqlDefinitionOption::Storage( - self.parse_user_defined_type_storage()?, - )) + let Some(storage) = self.parse_optional_user_defined_type_storage() else { + return self.expected_ref( + "storage value (plain, external, extended, or main)", + self.peek_token_ref(), + ); + }; + Ok(UserDefinedTypeSqlDefinitionOption::Storage(storage)) } Some(Keyword::LIKE) => { self.expect_token(&Token::Eq)?; @@ -22803,7 +22857,7 @@ impl<'a> Parser<'a> { } /// Parses `PLAIN`, `EXTERNAL`, `EXTENDED` or `MAIN`. - fn parse_user_defined_type_storage(&mut self) -> Result { + fn parse_optional_user_defined_type_storage(&mut self) -> Option { let storage_keyword = self.parse_one_of_keywords(&[ Keyword::PLAIN, Keyword::EXTERNAL, @@ -22811,14 +22865,11 @@ impl<'a> Parser<'a> { Keyword::MAIN, ]); match storage_keyword { - Some(Keyword::PLAIN) => Ok(UserDefinedTypeStorage::Plain), - Some(Keyword::EXTERNAL) => Ok(UserDefinedTypeStorage::External), - Some(Keyword::EXTENDED) => Ok(UserDefinedTypeStorage::Extended), - Some(Keyword::MAIN) => Ok(UserDefinedTypeStorage::Main), - _ => self.expected_ref( - "storage value (plain, external, extended, or main)", - self.peek_token_ref(), - ), + Some(Keyword::PLAIN) => Some(UserDefinedTypeStorage::Plain), + Some(Keyword::EXTERNAL) => Some(UserDefinedTypeStorage::External), + Some(Keyword::EXTENDED) => Some(UserDefinedTypeStorage::Extended), + Some(Keyword::MAIN) => Some(UserDefinedTypeStorage::Main), + _ => None, } } diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs index 9c59720aa8..8985e1323c 100644 --- a/tests/sqlparser_postgres.rs +++ b/tests/sqlparser_postgres.rs @@ -12839,6 +12839,10 @@ fn parse_alter_foreign_table() { "ALTER FOREIGN TABLE ft ALTER COLUMN id OPTIONS column_name 'remote_id'", "Expected: (, found: column_name", ), + ( + "ALTER FOREIGN TABLE ft ALTER COLUMN id RESET", + "Expected: (, found: EOF", + ), ( "ALTER FOREIGN ft OWNER TO app", "Expected: TABLE, found: ft", @@ -12853,20 +12857,6 @@ fn parse_alter_foreign_table() { "{sql}" ); } - - assert_eq!( - pg().parse_sql_statements("ALTER FOREIGN TABLE ft ALTER COLUMN id RESET") - .unwrap_err() - .to_string(), - "sql parser error: Expected: SET/DROP NOT NULL, SET DEFAULT, SET DATA TYPE, ADD GENERATED, or OPTIONS after ALTER COLUMN, found: RESET" - ); - assert_eq!( - TestedDialects::new(vec![Box::new(GenericDialect {})]) - .parse_sql_statements("ALTER FOREIGN TABLE ft ALTER COLUMN id RESET") - .unwrap_err() - .to_string(), - "sql parser error: Expected: SET/DROP NOT NULL, SET DEFAULT, SET DATA TYPE, or OPTIONS after ALTER COLUMN, found: RESET" - ); } #[test] @@ -14793,39 +14783,72 @@ fn parse_alter_table_set_schema() { #[test] fn parse_alter_column_set_storage() { + let dialects = pg_and_generic(); for (input, output, storage) in [ - ("PLAIN", "plain", UserDefinedTypeStorage::Plain), - ("EXTERNAL", "external", UserDefinedTypeStorage::External), - ("EXTENDED", "extended", UserDefinedTypeStorage::Extended), - ("MAIN", "main", UserDefinedTypeStorage::Main), + ("PLAIN", "plain", Some(UserDefinedTypeStorage::Plain)), + ( + "EXTERNAL", + "external", + Some(UserDefinedTypeStorage::External), + ), + ( + "EXTENDED", + "extended", + Some(UserDefinedTypeStorage::Extended), + ), + ("MAIN", "main", Some(UserDefinedTypeStorage::Main)), + ("DEFAULT", "DEFAULT", None), ] { - let statement = pg_and_generic().one_statement_parses_to( + let statement = dialects.one_statement_parses_to( &format!("ALTER TABLE t ALTER COLUMN b SET STORAGE {input}"), &format!("ALTER TABLE t ALTER COLUMN b SET STORAGE {output}"), ); - - let Statement::AlterTable(AlterTable { operations, .. }) = statement else { - panic!("expected ALTER TABLE, got {statement:?}") - }; + let op = AlterColumnOperation::SetStorage { storage }; assert_eq!( - operations, - vec![AlterTableOperation::AlterColumn { + alter_table_op_with_name(statement, "t"), + AlterTableOperation::AlterColumn { column_name: Ident::new("b"), - op: AlterColumnOperation::SetStorage { storage } - }] - ) - } - - for (sql, found) in [ - ("ALTER TABLE t ALTER COLUMN b SET STORAGE", "EOF"), - ("ALTER TABLE t ALTER COLUMN b SET STORAGE fast", "fast"), - ] { + op: op.clone(), + } + ); assert_eq!( - pg_and_generic().parse_sql_statements(sql).unwrap_err().to_string(), - format!("sql parser error: Expected: storage value (plain, external, extended, or main), found: {found}"), - "{sql}" + dialects.one_statement_parses_to( + &format!("ALTER MATERIALIZED VIEW IF EXISTS m ALTER b SET STORAGE {input}"), + &format!("ALTER MATERIALIZED VIEW IF EXISTS m ALTER COLUMN b SET STORAGE {output}"), + ), + Statement::AlterView(AlterView { + materialized: true, + name: ObjectName::from(Ident::new("m")), + if_exists: true, + operation: AlterViewOperation::AlterColumn { + column_name: Ident::new("b"), + op, + }, + }) ); } + + for relation in ["TABLE", "MATERIALIZED VIEW"] { + for (suffix, found) in [("", "EOF"), (" fast", "fast")] { + let sql = format!("ALTER {relation} t ALTER COLUMN b SET STORAGE{suffix}"); + assert_eq!( + dialects.parse_sql_statements(&sql).unwrap_err().to_string(), + format!("sql parser error: Expected: storage value (plain, external, extended, main, or default), found: {found}"), + "{sql}" + ); + } + } + + TestedDialects::new(vec![Box::new(MySqlDialect {})]) + .verified_stmt("ALTER TABLE t ALTER COLUMN b SET STORAGE external"); + + assert_eq!( + dialects + .parse_sql_statements("CREATE TYPE t (INPUT = f_in, OUTPUT = f_out, STORAGE = DEFAULT)") + .unwrap_err() + .to_string(), + "sql parser error: Expected: storage value (plain, external, extended, or main), found: DEFAULT" + ); } #[test] @@ -14874,3 +14897,149 @@ fn parse_create_function_transform() { ); } } + +#[test] +fn parse_alter_column_options() { + let dialects = pg_and_generic(); + let name = ObjectName::from(vec![Ident::new("s"), Ident::new("r")]); + let key = ObjectName::from(Ident::with_quote('"', "n_distinct")); + let qualified_key = + ObjectName::from(vec![Ident::new("ns"), Ident::new("n_distinct_inherited")]); + for (input, canonical, op) in [ + ( + r#"c SET ("n_distinct"=5, ns.n_distinct_inherited='0.25')"#, + r#"COLUMN c SET ("n_distinct" = 5, ns.n_distinct_inherited = '0.25')"#, + AlterColumnOperation::SetOptions { + options: vec![ + SqlOption::KeyValue { + key: key.clone(), + value: Expr::value(number("5")), + }, + SqlOption::KeyValue { + key: qualified_key.clone(), + value: Expr::value(Value::SingleQuotedString("0.25".into())), + }, + ], + }, + ), + ( + r#"COLUMN c RESET ( "n_distinct", ns.n_distinct_inherited )"#, + r#"COLUMN c RESET ("n_distinct", ns.n_distinct_inherited)"#, + AlterColumnOperation::ResetOptions { + options: vec![key, qualified_key], + }, + ), + ] { + let statement = dialects.one_statement_parses_to( + &format!("ALTER TABLE IF EXISTS s.r ALTER {input}"), + &format!("ALTER TABLE IF EXISTS s.r ALTER {canonical}"), + ); + let Statement::AlterTable(AlterTable { + name: table_name, + if_exists: true, + operations, + .. + }) = statement + else { + panic!("Expected ALTER TABLE IF EXISTS, got {statement:?}"); + }; + assert_eq!(table_name, name); + assert_eq!( + operations, + vec![AlterTableOperation::AlterColumn { + column_name: Ident::new("c"), + op: op.clone(), + }] + ); + assert_eq!( + dialects.one_statement_parses_to( + &format!("ALTER MATERIALIZED VIEW IF EXISTS s.r ALTER {input}"), + &format!("ALTER MATERIALIZED VIEW IF EXISTS s.r ALTER {canonical}"), + ), + Statement::AlterView(AlterView { + materialized: true, + name: name.clone(), + if_exists: true, + operation: AlterViewOperation::AlterColumn { + column_name: Ident::new("c"), + op, + }, + }) + ); + } + + dialects.verified_stmt( + "ALTER TABLE foo ALTER COLUMN baz SET (opt1, opt2 = 5, opt3 = 'str', ns.opt4, ns.opt5 = 6, ns.opt6 = 'str', opt7 = asc)", + ); +} + +#[test] +fn parse_alter_column_option_spans() { + let dialects = pg_and_generic(); + for relation in ["TABLE", "MATERIALIZED VIEW"] { + for (operation, start, end) in [ + ( + "ALTER c SET (n_distinct = 2, n_distinct_inherited = 3)", + 7, + 54, + ), + ( + "ALTER COLUMN c RESET (n_distinct, n_distinct_inherited)", + 14, + 55, + ), + ("ALTER c SET STORAGE DEFAULT", 7, 8), + ] { + let sql = format!("ALTER {relation} r\n{operation}"); + let span = dialects.run_parser_method(&sql, |parser| { + match parser.parse_statement().unwrap() { + Statement::AlterTable(AlterTable { operations, .. }) => only(operations).span(), + Statement::AlterView(AlterView { operation, .. }) => operation.span(), + statement => { + panic!("Expected ALTER TABLE or ALTER MATERIALIZED VIEW, got {statement:?}") + } + } + }); + assert_eq!( + span, + Span::new(Location::new(2, start), Location::new(2, end)), + "{sql}" + ); + } + } +} + +#[test] +fn parse_alter_column_rejects_invalid_options() { + let dialects = pg_and_generic(); + for relation in ["TABLE", "MATERIALIZED VIEW"] { + for (operation, expected) in [ + ("SET ()", "Expected: identifier, found: )"), + ("SET (n_distinct = )", "Expected: an expression, found: )"), + ("SET (n_distinct = 1", "Expected: ), found: EOF"), + ("RESET", "Expected: (, found: EOF"), + ("RESET ()", "Expected: identifier, found: )"), + ("RESET (n_distinct = 1)", "Expected: ), found: ="), + ] { + let sql = format!("ALTER {relation} r ALTER COLUMN c {operation}"); + assert_eq!( + dialects.parse_sql_statements(&sql).unwrap_err().to_string(), + format!("sql parser error: {expected}"), + "{sql}" + ); + } + } + + for (operation, found) in [ + ("SET (n_distinct = 1)", "SET"), + ("RESET (n_distinct)", "RESET"), + ("SET STORAGE DEFAULT", "SET"), + ] { + let sql = format!("ALTER VIEW v ALTER c {operation}"); + assert_eq!( + dialects.parse_sql_statements(&sql).unwrap_err().to_string(), + format!("sql parser error: Expected: SET DEFAULT or DROP DEFAULT after ALTER COLUMN, found: {found}"), + "{sql}" + ); + } +}