Skip to content

sql: syntax X'...' should be byte array not string #13049

@knz

Description

@knz

CockroachDB supports the non-standard extension syntax x'.....' to enter a literal string using hexadecimal codes only.

This is all fine and dandy but it's not so clear to me that we have a use case for it.

Meanwhile, we do have a use case for entering raw bytes containing possibly invalid UTF-8 sequences (a byte array) in hexadecimal, for example a uuid value or a SHA hash, but CockroachDB does not provide a compact syntax to do so yet -- the best we have so far is b'\xAA\xAA\xAA\xAA... which is 50% less efficient to type.

It seems to me we should simply repurpose the syntax x'....' to become a byte array literal (BCONST) instead of a string array literal (SCONST).

@jordanlewis what do you think? (You added this support initially)

cc @nvanbenschoten

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions