-
-
Notifications
You must be signed in to change notification settings - Fork 651
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
Added support for psql meta commands to Postgres #1423
Added support for psql meta commands to Postgres #1423
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1423 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 127 127
Lines 8603 8604 +1
=========================================
+ Hits 8603 8604 +1
Continue to review full report at Codecov.
|
I was curious how comments were handled as seems like a similar use case. From a quick look it looks like it basically trims the details as part of the lexing, so those symbols aren’t sent to the parser and are effectively ignored. The downside would be that you can’t check the grammar of meta commands (as they will effectively not exist to the parser), but doesn’t look like you are doing that here anyway so for now that wouldn’t matter. But your solution at least opens that possibility later. Any thoughts on whether following the comments process would be the better solution than what’s proposed here? |
Yeah, that might be easier. The only thing I think could cause an issue, is: |
Sure they can, with SELECT *
/* this is our main table */ FROM table 1 |
Good point. I've updated meta commands to function like comments. |
Wow that seems almost too simple now!!! I took ages trying to hunt for the code to figure out where the actual magic was happening - but guess it's all handled just by calling it a |
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.
LGTM! One small suggestion.
Co-authored-by: Barry Pollard <barry_pollard@hotmail.com>
Brief summary of the change made
This PR adds support for psql meta commands. Psql commands here start with , followed by at least one alphabet character, and are then terminated by newline or \. The File and Statement Segments had to be edited to accommodate for this new functionality.
Fixes #1327
Are there any other side effects of this change that we should be aware of?
No, Postgres-specific, and all dialect tests are passing
Pull Request checklist
Test cases added for psql meta commands, and sql commands in the same file (or same line for \)
Documented regex in file