-
Notifications
You must be signed in to change notification settings - Fork 619
Support for Postgres's CREATE SERVER #1914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -4662,6 +4662,10 @@ impl<'a> Parser<'a> { | |||
self.parse_create_procedure(or_alter) | |||
} else if self.parse_keyword(Keyword::CONNECTOR) { | |||
self.parse_create_connector() | |||
} else if self.parse_keyword(Keyword::SERVER) | |||
&& dialect_of!(self is PostgreSqlDialect | GenericDialect) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&& dialect_of!(self is PostgreSqlDialect | GenericDialect) |
I think it should be fine to let the parser be permissive and accept this statement whenever it shows up
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))] | ||
pub struct ServerOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub struct ServerOption { | |
pub struct CreateServerOption { |
/// CREATE SERVER | ||
/// ``` | ||
/// See [PostgreSQL](https://www.postgresql.org/docs/current/sql-createserver.html) | ||
CreateServer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For new statements we're moving away from using anonymous structs, here can we introduce a dedicated struct for this statement?
CreateServer(CreateServerStatement)
See Statement::Raise as an example
if_not_exists: bool, | ||
server_type: Option<Ident>, | ||
version: Option<Ident>, | ||
fdw_name: ObjectName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to something more descriptive e.g. explicitly foreign_data_wrapper
?
/// ```sql | ||
/// CREATE SERVER [ IF NOT EXISTS ] server_name [ TYPE 'server_type' ] [ VERSION 'server_version' ] | ||
/// FOREIGN DATA WRAPPER fdw_name | ||
/// [ OPTIONS ( option 'value' [, ... ] ) ] | ||
/// ``` | ||
/// | ||
/// [PostgreSQL Documentation](https://www.postgresql.org/docs/current/sql-createserver.html) | ||
pub fn parse_pg_create_server(&mut self) -> Result<Statement, ParserError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// ```sql | |
/// CREATE SERVER [ IF NOT EXISTS ] server_name [ TYPE 'server_type' ] [ VERSION 'server_version' ] | |
/// FOREIGN DATA WRAPPER fdw_name | |
/// [ OPTIONS ( option 'value' [, ... ] ) ] | |
/// ``` | |
/// | |
/// [PostgreSQL Documentation](https://www.postgresql.org/docs/current/sql-createserver.html) | |
pub fn parse_pg_create_server(&mut self) -> Result<Statement, ParserError> { | |
/// Parse a `CREATE SERVER` statement. | |
/// | |
/// See [Statement::CreateServer] | |
pub fn parse_pg_create_server(&mut self) -> Result<Statement, ParserError> { |
I think we can do something like this to avoid duplicating the comments. The syntax we can skip entirely since that should be covered by the doc link if the reader requires further context
Closes #1814