Description:
Run these statements:
CREATE TABLE t85 (c0 INT,c4 TEXT);
INSERT INTO t85 VALUES (69,'5'),(-22,'3'),(-24,'8'),(73,'a');
CREATE TABLE t100 (c0 INT);
Then these queries:
SELECT 1 FROM t100 RIGHT JOIN t85 USING (c0);
SELECT 1 FROM t100 RIGHT JOIN t85 USING (c0) WHERE t85.c4 NOT BETWEEN -50 AND field(t85.c0, t100.c0);
SELECT 1 FROM t100 RIGHT JOIN t85 USING (c0) WHERE NOT (t85.c4 NOT BETWEEN -50 AND field(t85.c0, t100.c0));
SELECT 1 FROM t100 RIGHT JOIN t85 USING (c0) WHERE (t85.c4 NOT BETWEEN -50 AND field(t85.c0, t100.c0)) IS NULL;
The cardinality of the 3 bottom queries must match the upper one (true, false, and NULL). The top SELECT query returns 4 lines, the true query 3, and the others none. By looking more carefully, the query:
SELECT 1 FROM t100 RIGHT JOIN t85 USING (c0) WHERE NOT (t85.c4 NOT BETWEEN -50 AND field(t85.c0, t100.c0));
has a wrong result because the tuple (73,'a') should match in this case: the NOT cancel each other, field(t85.c0, t100.c0) evaluates to 0 and 'a' BETWEEN -50 AND 0 evaluates to 1.
The compilation parameters are the same as issue 108148:
-DWITH_DEBUG=1 -DWITH_ASAN=ON -DWITH_UBSAN=ON and boost library version 1.77
How to repeat:
Run the queries above.