sql: repurpose the syntax x'...' for byte array literals.#13094
Merged
knz merged 1 commit intocockroachdb:masterfrom Jan 24, 2017
Merged
sql: repurpose the syntax x'...' for byte array literals.#13094knz merged 1 commit intocockroachdb:masterfrom
knz merged 1 commit intocockroachdb:masterfrom
Conversation
Member
|
Like magic! LGTM. Could you add a test case illustrating the cast to string, just for completeness? |
Contributor
Author
|
Like magic! LGTM. Could you add a test case illustrating the cast to
string, just for completeness?
Done
|
Contributor
Author
|
TFYR :) |
| @@ -1042,7 +1042,7 @@ SELECT 0x FROM t | |||
| }, | |||
| { | |||
| `SELECT x'fail' FROM t`, | |||
Contributor
There was a problem hiding this comment.
I'd also like to see an error case with the valid characters but wrong number of characters: SELECT x'01a'
Prior to this patch this syntax would produce string literals. Like for all string values it would also check that the string does not contain invalid UTF-8 sequences, so it was not usable to enter byte array constants. Meanwhile there was no convenient syntax to enter arbitrary byte sequences using hex codes only (like hash values, binary encoded data, etc). As this feature was originally intended to mimic MySQL's similar syntax, which does serve to produce byte arrays, this patch aligns the feature more closely with its original intent by ensuring the syntax produces byte array literals instead of string literals. Its usage for string literals is still possible however by means of a simple cast.
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.
Prior to this patch this syntax would produce string literals. Like
for all string values it would also check that the string does not
contain invalid UTF-8 sequences, so it was not usable to enter byte
array constants. Meanwhile there was no convenient syntax to enter
arbitrary byte sequences using hex codes only (like hash values,
binary encoded data, etc).
As this feature was originally intended to mimic MySQL's similar
syntax, which does serve to produce byte arrays, this patch aligns the
feature more closely with its original intent by ensuring the syntax
produces byte array literals instead of string literals.
Its usage for string literals is still possible however by means of a
simple cast.
Fixes #13049.
This change is