Skip to content

Unexpected result when using a record in WHERE filter #130649

Description

@suyZhong

Describe the problem

Consider the test case below. It is unexpected that the third query returns a row 1 NULL, since the second query shows that the expression should be evaluated to false.

To Reproduce

What did you do? Describe in your own words.

Start the CockroachDB instance by using Docker.

docker run --name cockroachdb-test -p 10011:26257 -p 10012:8080 cockroachdb/cockroach:latest start-single-node --insecure

Execute the below statements through psql:

DROP DATABASE IF EXISTS test;
CREATE DATABASE test;
USE test;

CREATE  TABLE  t0(c0 INT, c1 INT);
INSERT INTO t0(c0) VALUES (1);

SELECT * FROM t0; -- 1 NULL
SELECT ((t0.c0, t0.c1) IS NOT NULL) FROM t0; -- f
SELECT * FROM t0 WHERE ((t0.c0, t0.c1) IS NOT NULL);
-- Expected: empty
-- Actual: 1 NULL

Expected behavior
The third query should return an empty result

Additional data / screenshots
If the problem is SQL-related, include a copy of the SQL query and the schema
of the supporting tables.

If a node in your cluster encountered a fatal error, supply the contents of the
log directories (at minimum of the affected node(s), but preferably all nodes).

Note that log files can contain confidential information. Please continue
creating this issue, but contact support@cockroachlabs.com to submit the log
files in private.

If applicable, add screenshots to help explain your problem.

Environment:

  • CockroachDB version 24.2.1
  • Server OS: Docker image
  • Client app: psql and JDBC

Additional context
What was the impact?

Add any other context about the problem here.

Jira issue: CRDB-42161

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityT-sql-queriesSQL Queries TeamX-blathers-triagedblathers was able to find an owner

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions