Skip to content

sql: CockroachDB's extended literal formats are not compatible with postgres #26128

@knz

Description

@knz
  • format x'aaaaaaa'

    • in PostgreSQL: BIT literal, defines a bit string and allows any number of hexadecimal digits (i.e. the smallest value is 4 bits).
    • in CockroachDB: BYTES literal, defines a byte string and only allows pairs of hexadecimal digits.
  • format b'aaaaaaa'

    • in PostgreSQL: BIT literal, defines a bit string and allows any number of binary digits (i.e. the smallest value is 1 bit).
    • in CockroachDB: BYTES literal, defines a byte string using escapes.

In PostgreSQL, byte array literals use a different syntax, either:

  • e'ab\nc'::BYTEA (escaped string, the same is achieved currently with b'...' in crdb)
  • '\xAAAA'::BYTEA (i.e. string starting with \x; the same is achieved currently with x'...' in crdb)

@nvanbenschoten @bdarnell what do you think? We need to support the BIT type properly ultimately. I am tempted to set up a plan to deprecate the current literal format in 2.1 so that it becomes available for BIT in 2.2. Thoughts?

Jira issue: CRDB-5687

Epic CRDB-60814

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-sql-pgcompatSemantic compatibility with PostgreSQLA-sql-syntaxIssues strictly related to the SQL grammar, with no semantic aspectC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)X-nostaleMarks an issue/pr that should be ignored by the stale bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions