Repository navigation
PostgreSQL: Support ALTER VIEW operations - #2730
LucaCappelletti94 wants to merge 6 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2730 +/- ##
==========================================
+ Coverage 82.67% 82.81% +0.13%
==========================================
Files 42 42
Lines 35737 35865 +128
Branches 35737 35865 +128
==========================================
+ Hits 29547 29702 +155
+ Misses 2671 2653 -18
+ Partials 3519 3510 -9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| with_options, | ||
| } => { | ||
| if !with_options.is_empty() { | ||
| write!(f, "WITH ({}) ", display_comma_separated(with_options))?; |
There was a problem hiding this comment.
Pre-existing, but the parser reads (columns) before WITH (...) while this writes them the other way round, so ALTER VIEW v (a) WITH (x = 1) AS SELECT 1 displays as ALTER VIEW v WITH (x = 1) (a) AS SELECT 1, which doesn't re-parse. Swapping the two blocks here fixes the round-trip.
| } | ||
|
|
||
| #[test] | ||
| fn parse_alter_view_postgres() { |
There was a problem hiding this comment.
parse_alter_view has no dialect check, so these could use all_dialects() next to the existing parse_alter_view tests in sqlparser_common.rs.
There was a problem hiding this comment.
Moved, and adjusted for the DuckDB corner case
a408cf1 to
27b559f
Compare
2540424 to
65e4595
Compare
f582bca to
9a84f13
Compare
cc98590 to
99ff07d
Compare
99ff07d to
acdcf55
Compare
ALTER VIEW v OWNER TO oandALTER VIEW v SET (security_invoker = true)fail withExpected: AS, found: OWNER, becauseparse_alter_viewonly knows the MySQL formALTER VIEW v AS SELECT .... The other PostgreSQL forms of the statement fail the same way.Statement::AlterViewnow wraps anAlterViewstruct holdingIF EXISTSand anAlterViewOperation, the shapeAlterCollationalready uses. The MySQL form becomes one variant beside the PostgreSQL ones, which changes the public AST ofStatement::AlterView. PostgreSQL lets aSET (...)option omit its value, so such an option parses toSqlOption::Ident.The syntax follows https://www.postgresql.org/docs/current/sql-alterview.html.
Closes #886.