Skip to content

Add support for SHOW CHARSET#1974

Merged
iffyio merged 3 commits intoapache:mainfrom
SatoriCyber:show-charset
Jul 29, 2025
Merged

Add support for SHOW CHARSET#1974
iffyio merged 3 commits intoapache:mainfrom
SatoriCyber:show-charset

Conversation

@etgarperets
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread src/ast/mod.rs Outdated
// 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>
ShowCharset {
is_shorthand: bool,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a description what this flag does?

Comment thread src/ast/mod.rs Outdated
Comment on lines +3717 to +3720
ShowCharset {
is_shorthand: bool,
filter: Option<ShowStatementFilter>,
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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{...})

Comment thread src/ast/mod.rs Outdated
Comment on lines +3715 to +3716
// 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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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>
//
[MySQL]: 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

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

Comment thread src/ast/mod.rs Outdated
Comment on lines +3708 to +3714
// SHOW {CHARACTER SET | CHARSET} [like_or_where]
// ```
// where:
// like_or_where: {
// LIKE 'pattern'
// | WHERE expr
// }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// SHOW {CHARACTER SET | CHARSET} [like_or_where]
// ```
// where:
// like_or_where: {
// LIKE 'pattern'
// | WHERE expr
// }
// SHOW {CHARACTER SET | CHARSET}
// ```

Thinking a brief example would be enough. For detailed syntax readers can follow the documentation

Comment thread tests/sqlparser_mysql.rs Outdated

#[test]
fn parse_show_charset() {
let _ = mysql().verified_stmt("SHOW CHARACTER SET");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Improves the initial `SHOW CHARSET` implementation by:
- Using a named struct for the AST node
- Adding AST assertion to the parser test
- Improving code comments
Copy link
Copy Markdown
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @etgarperets! Left a minor doc comment otherwise I think this looks good!

Comment thread src/ast/mod.rs Outdated
@iffyio iffyio changed the title SGA-11783 Added support for SHOW CHARSET Add support for SHOW CHARSET Jul 28, 2025
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Copy link
Copy Markdown
Contributor

@iffyio iffyio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @etgarperets!
cc @alamb

@iffyio iffyio merged commit 15d8bfe into apache:main Jul 29, 2025
10 checks passed
ayman-sigma pushed a commit to sigmacomputing/sqlparser-rs that referenced this pull request Feb 3, 2026
Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants