You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WHERE 1 IN [] is silently evaluated to WHERE true #2290
CREATE EXTENSION IF NOT EXISTS age;
LOAD 'age';
SET search_path = ag_catalog, "$user", public;
SELECT create_graph('test');
SELECT * FROM cypher('test', $$ CREATE (:N) RETURN 1 $$) AS (x agtype);
First Control Query (WHERE true):
postgresDB=# SELECT count(*)
FROM cypher('test', $$
MATCH (n:N)
WHERE true
RETURN n
$$) AS (n agtype);
count
-------
1
(1 row)
Second Control Query (WHERE false):
postgresDB=# SELECT count(*)
FROM cypher('test', $$
MATCH (n:N)
WHERE false
RETURN n
$$) AS (n agtype);
count
-------
0
(1 row)
Third Control Query (WHERE 1 IN [] throws an error):
postgresDB=# SELECT *
FROM cypher('test', $$
WITH 1 AS x
WHERE 1 IN []
RETURN x AS v
$$) AS (v agtype);
ERROR: cache lookup failed for type 0
LINE 2: FROM cypher('test', $$
^
The buggy query:
postgresDB=# SELECT count(*)
FROM cypher('test', $$
MATCH (n:N)
WHERE 1 IN []
RETURN n
$$) AS (n agtype);
count
-------
1
(1 row)
Expected behaviour
The buggy query should behave the same as the second control query.
However, since 1 IN [] is currently problematic (reported in issue #2289), the buggy query should instead behave the same as the third control query under this condition.
Actual behaviour
The buggy query behaves the same as the first control query.
@zihaozeng0021 Actually, your 3rd control query has the incorrect output and PR #2294 resolves it causing the latter 2 queries to provide the correct results.
3rd query correct result
psql-17.4-5432-pgsql=# SELECT count(*)
psql-17.4-5432-pgsql-# FROM cypher('test', $$
psql-17.4-5432-pgsql$# MATCH (n:N)
psql-17.4-5432-pgsql$# WHERE 1 IN []
psql-17.4-5432-pgsql$# RETURN n
psql-17.4-5432-pgsql$# $$) AS (n agtype);
count
-------
0
(1 row)
buggy query correct result
psql-17.4-5432-pgsql=# SELECT *
psql-17.4-5432-pgsql-# FROM cypher('test', $$
psql-17.4-5432-pgsql$# WITH 1 AS x
psql-17.4-5432-pgsql$# WHERE 1 IN []
psql-17.4-5432-pgsql$# RETURN x AS v
psql-17.4-5432-pgsql$# $$) AS (v agtype);
v
---
(0 rows)
psql-17.4-5432-pgsql=#
Activity
jrgemignani commentedon Jan 12, 2026
@zihaozeng0021 Actually, your 3rd control query has the incorrect output and PR #2294 resolves it causing the latter 2 queries to provide the correct results.
3rd query correct result
buggy query correct result