-
Notifications
You must be signed in to change notification settings - Fork 693
MySQL: Add support for DEFAULT CHARACTER SET in CREATE DATABASE #2182
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5294,6 +5294,8 @@ impl<'a> Parser<'a> { | |||||
| let db_name = self.parse_object_name(false)?; | ||||||
| let mut location = None; | ||||||
| let mut managed_location = None; | ||||||
| let mut default_charset = None; | ||||||
| let mut default_collation = None; | ||||||
| loop { | ||||||
| match self.parse_one_of_keywords(&[Keyword::LOCATION, Keyword::MANAGEDLOCATION]) { | ||||||
| Some(Keyword::LOCATION) => location = Some(self.parse_literal_string()?), | ||||||
|
|
@@ -5309,6 +5311,26 @@ impl<'a> Parser<'a> { | |||||
| None | ||||||
| }; | ||||||
|
|
||||||
| // Parse MySQL-style [DEFAULT] CHARACTER SET and [DEFAULT] COLLATE options | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we move the |
||||||
| loop { | ||||||
| let has_default = self.parse_keyword(Keyword::DEFAULT); | ||||||
| if self.parse_keywords(&[Keyword::CHARACTER, Keyword::SET]) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| || self.parse_keyword(Keyword::CHARSET) | ||||||
| { | ||||||
| self.expect_token(&Token::Eq).ok(); | ||||||
| default_charset = Some(self.parse_identifier()?.value); | ||||||
| } else if self.parse_keyword(Keyword::COLLATE) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| self.expect_token(&Token::Eq).ok(); | ||||||
|
Comment on lines
+5320
to
+5323
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we handle the errors in the calls to |
||||||
| default_collation = Some(self.parse_identifier()?.value); | ||||||
| } else if has_default { | ||||||
| // DEFAULT keyword not followed by CHARACTER SET, CHARSET, or COLLATE | ||||||
| self.prev_token(); | ||||||
| break; | ||||||
| } else { | ||||||
| break; | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| Ok(Statement::CreateDatabase { | ||||||
| db_name, | ||||||
| if_not_exists: ine, | ||||||
|
|
@@ -5325,6 +5347,8 @@ impl<'a> Parser<'a> { | |||||
| default_ddl_collation: None, | ||||||
| storage_serialization_policy: None, | ||||||
| comment: None, | ||||||
| default_charset, | ||||||
| default_collation, | ||||||
| catalog_sync: None, | ||||||
| catalog_sync_namespace_mode: None, | ||||||
| catalog_sync_namespace_flatten_delimiter: None, | ||||||
|
|
||||||
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 include a link to the mysql documentation for the doc comments?