Skip to content

Unexpected result when using CONTAINS and type casting #7463

@suyZhong

Description

@suyZhong

Describe the bug
Consider the test cases below. It is unexpected that the third query returns 1 1, since there is no true in the second query, and thus the third query should return an empty result. Anyway, the predicate cannot to be evaluated to true at the same time, and one of the third or the forth query should return an empty result.

To Reproduce

DROP TABLE t0 CASCADE;

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

SELECT * FROM t0; -- 0 null, 1 1
SELECT (t0.c1)AND(CAST(CONTAINS(0, t0.c0) AS VARCHAR)) FROM t0; -- null, false
SELECT * FROM t0 WHERE ((t0.c1)AND(CAST(CONTAINS(0, t0.c0) AS VARCHAR)));  -- 1 1 (unexpected, should be empty)

SELECT * FROM t0 WHERE (NOT ((t0.c1)AND(CAST(CONTAINS(0, t0.c0) AS VARCHAR)))); -- 1 1

Expected behavior
As mentioned above

Screenshots
N/A

Software versions
Build from source:

> docker exec monetdb-test mserver5 --version --dbname=monetdb
MonetDB 5 server 11.50.0 (hg id: 5f31415) (64-bit, 128-bit integers)
This is an unreleased version
Copyright (c) 1993 - July 2008 CWI
Copyright (c) August 2008 - 2023 MonetDB B.V., all rights reserved
Visit https://www.monetdb.org/ for further information
Found 503.5GiB available memory, 128 available cpu cores
Libraries:
Compiled by: @97de17abeb72 (x86_64-pc-linux-gnu)
Compilation: /usr/bin/cc 
Linking    : /usr/bin/ld

Issue labeling
Bug

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions