-
Notifications
You must be signed in to change notification settings - Fork 627
SGA-11783 Added support for SHOW CHARSET #1974
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 | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -3704,6 +3704,20 @@ pub enum Statement { | |||||||||
history: bool, | ||||||||||
show_options: ShowStatementOptions, | ||||||||||
}, | ||||||||||
// ```sql | ||||||||||
// SHOW {CHARACTER SET | CHARSET} [like_or_where] | ||||||||||
// ``` | ||||||||||
// where: | ||||||||||
// like_or_where: { | ||||||||||
// LIKE 'pattern' | ||||||||||
// | WHERE expr | ||||||||||
// } | ||||||||||
// MySQL specific statement | ||||||||||
// <https://dev.mysql.com/doc/refman/8.4/en/show.html#:~:text=SHOW%20%7BCHARACTER%20SET%20%7C%20CHARSET%7D%20%5Blike_or_where%5D> | ||||||||||
Comment on lines
+3715
to
+3716
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
Or something similar, essentially dropping the mention of it being mysql specific, since that can change in the future or other existing dialects might also support it in some form |
||||||||||
ShowCharset { | ||||||||||
is_shorthand: bool, | ||||||||||
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. Could we add a description what this flag does? |
||||||||||
filter: Option<ShowStatementFilter>, | ||||||||||
}, | ||||||||||
Comment on lines
+3717
to
+3720
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 switch to using a named struct syntax for this statement? See ref we're trying to move away from the anonymous struct syntax ideally. We could have something like? struct ShowCharSet { ... }
Statement::ShowCharSet(ShowCharSet{...}) |
||||||||||
/// ```sql | ||||||||||
/// SHOW OBJECTS LIKE 'line%' IN mydb.public | ||||||||||
/// ``` | ||||||||||
|
@@ -5674,6 +5688,21 @@ impl fmt::Display for Statement { | |||||||||
} | ||||||||||
Ok(()) | ||||||||||
} | ||||||||||
Statement::ShowCharset { | ||||||||||
is_shorthand, | ||||||||||
filter, | ||||||||||
} => { | ||||||||||
write!(f, "SHOW")?; | ||||||||||
if *is_shorthand { | ||||||||||
write!(f, " CHARSET")?; | ||||||||||
} else { | ||||||||||
write!(f, " CHARACTER SET")?; | ||||||||||
} | ||||||||||
if filter.is_some() { | ||||||||||
write!(f, " {}", filter.as_ref().unwrap())?; | ||||||||||
} | ||||||||||
Ok(()) | ||||||||||
} | ||||||||||
Statement::StartTransaction { | ||||||||||
modes, | ||||||||||
begin: syntax_begin, | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4143,3 +4143,11 @@ fn parse_json_member_of() { | |
_ => panic!("Unexpected statement {stmt}"), | ||
} | ||
} | ||
|
||
#[test] | ||
fn parse_show_charset() { | ||
let _ = mysql().verified_stmt("SHOW CHARACTER SET"); | ||
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. Since this adds a new node to the AST, can we assert one of the scenarios that the AST looks as expected? For example |
||
let _ = mysql().verified_stmt("SHOW CHARACTER SET LIKE 'utf8mb4%'"); | ||
let _ = mysql().verified_stmt("SHOW CHARSET WHERE charset = 'utf8mb4%'"); | ||
let _ = mysql().verified_stmt("SHOW CHARSET LIKE 'utf8mb4%'"); | ||
} |
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.
Thinking a brief example would be enough. For detailed syntax readers can follow the documentation