Skip to content

sql: operator precedence does not match PostgreSQL #66866

@mikecaat

Description

@mikecaat

Unfortunately, CockroachDB does not match PostgreSQL's order of operations. An example of this is here: #64699 (comment) and is detailed here: #66866 (comment)

Changing the order of operations is dangerous and will be very broken for backwards compatibility. However, if we want PostgreSQL compatibility we need to do it. One for the record books...


Describe the problem

When I made a test for #66861, I found the order of operation of OPERATOR(pg_config.X) is not same.

root@localhost:26257/postgres> SELECT 'a' || 'b' = 'ab';
  ?column?
------------
    true
(1 row)

root@localhost:26257/postgres> SELECT 'a' || 'b' OPERATOR(pg_catalog.=) 'ab';
  ?column?
------------
  afalse
(1 row)

By the way, the result of executing the same queries with postgresql ver 13.3 is the following.

psql=# SELECT 'a' || 'b' = 'ab';
 ?column?
----------
 t
(1 row)

psql=# SELECT 'a' || 'b' OPERATOR(pg_catalog.=) 'ab';
 ?column?
----------
 t
(1 row)

To Reproduce

Execute the above example.

Expected behavior

I think this should be the same order of operations. Thought?

Environment:

  • CockroachDB version: master branch(c4f134c)
  • Server OS: MacOS BigSur
  • Client app: cockroach sql

Jira issue: CRDB-8268

Epic CRDB-60814

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)X-blathers-triagedblathers was able to find an owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions