Skip to content

WHERE 1 IN [] is silently evaluated to WHERE true #2290

@zihaozeng0021

Description

@zihaozeng0021

Note

This looks closely related to issue #2289, but it doesn’t seem to be the same underlying problem, so I opened a new report.

Configuration

AGE Version: apache/age:latest (pulled 2025-12-26)

Operating System: WSL2 – Ubuntu 24.04.1 LTS

Installation Method: Docker


Steps to reproduce

  1. Start AGE via Docker
docker run \
  --name age \
  -p 5455:5432 \
  -e POSTGRES_USER=postgresUser \
  -e POSTGRES_PASSWORD=postgresPW \
  -e POSTGRES_DB=postgresDB \
  -d \
  apache/age:latest
  1. Connect with psql
PGPASSWORD='postgresPW' psql -h localhost -p 5455 -U postgresUser -d postgresDB
  1. Run the following query

Set up:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions