Skip to content

sql: Incorrect result for LIKE query #44123

@mrigger

Description

@mrigger

Consider the following test case:

CREATE TABLE t0(c0 STRING UNIQUE);
INSERT INTO t0 (c0) VALUES ('\a');
SELECT * FROM t0 WHERE c0 LIKE '\a'; -- unexpected: row is fetched

Unexpectedly, the query fetches a row. When removing the UNIQUE constraint, no row is fetched. That the predicate should evaluate to FALSE is also demonstrated by the following query:

SELECT c0 LIKE '\a' FROM t0; -- FALSE

I built CockroachDB from source (commit 55c0e012b9539a327640e42ceaaf556b7a0e7b10) on Ubuntu 19.04.

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.E-quick-winLikely to be a quick win for someone experienced.S-0-visible-logical-errorDatabase stores inconsistent data in some cases, or queries return invalid results silently.T-sql-queriesSQL Queries Team

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions