make metacmd tokenization and quoted-string parsing match psql#565
Open
BapTruongSinh wants to merge 1 commit intoxo:mainfrom
Open
Conversation
This is the core parser change. The metacmd scanner/parser needs to stop treating quoted text and `:` substitutions as mostly literal text and instead parse them with psql-compatible rules. The issue examples show three failures that all point here: `:{?name}` is not recognized at all, single-quoted strings used by `\set` are not decoded with psql escape rules, and backtick bodies are not being tokenized with the same interpolation-aware logic as normal metacmd arguments. This file should be updated so the lexer/parser can distinguish plain tokens, single-quoted strings, double-quoted strings, backtick command bodies, and variable references with enough context to apply the correct expansion rules later.
Affected files: parse.go
Signed-off-by: Ngô Quang Sinh <omaken567@gmail.com>
Member
|
@BapTruongSinh I actually was aware of the issue with the variables, and have a half-implementation that I didn't have time to complete from over a year ago. I'll review and merge this if it's clean. Appreciate the contribution, thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the core parser change. The metacmd scanner/parser needs to stop treating quoted text and ' :' substitutions as mostly literal text and instead parse them with psql-compatible rules. The issue examples show three failures that all point here: ':{?name}' is not recognized at all, single-quoted strings used by ' \set' are not decoded with psql escape rules, and backtick bodies are not being tokenized with the same interpolation-aware logic as normal metacmd arguments. This file should be updated so the lexer/parser can distinguish plain tokens, single-quoted strings, double-quoted strings, backtick command bodies, and variable references with enough context to apply the correct expansion rules later.
Affected files: parse.go