Postgres: Support U&"..." quoted identifiers and UESCAPE clause - #2509
Open
BenSatori wants to merge 1 commit into
Open
Postgres: Support U&"..." quoted identifiers and UESCAPE clause#2509BenSatori wants to merge 1 commit into
BenSatori wants to merge 1 commit into
Conversation
PostgreSQL supports Unicode-escaped quoted identifiers (U&"...") in addition to Unicode string literals (U&'...'), and both accept an optional trailing UESCAPE '<char>' clause to override the default backslash escape character. Neither was previously supported by the parser. See https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS Co-authored-by: GitHub Copilot <copilot@github.com>
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.
Example
Before this PR, none of these valid Postgres queries parsed:
U&"..."Unicode-escaped quoted identifiers were not tokenized at all (only theU&'...'string literal form was supported), and theUESCAPE '<char>'clause that can follow either aU&'...'string or aU&"..."identifier to override the default\escape character was not implemented, even though theUESCAPEkeyword already existed inkeywords.rs.Fix
U&"..."identifiers now tokenize into a regular quoted identifier (decoded, e.g.U&"d\0061ta"->"data"), and bothU&'...'andU&"..."now support an optional trailingUESCAPE '<char>'clause.See the Postgres docs (identifiers) and UESCAPE docs (escape clause). Relates to #1354, which added the
U&'...'string literal support this PR extends.This PR was authored with the assistance of GitHub Copilot.