Skip to content

reduce()/list comprehension in a LIMIT or SKIP clause raises internal error unsupported SubLink (0A000) #2518

Description

@hkjiang26

Bug description

Putting a reduce() expression — or a list comprehension — inside a LIMIT or SKIP clause makes AGE 1.8.0 fail with the internal error ERROR: 0A000: unsupported SubLink. The query has no subquery and no outer variable; the trigger is the reduce's own list iteration variable (b IN [0]).

Access method

  • Command line via psql, inside the official Docker container apache/age:1.8.0

Data setup

No data is required — the error reproduces on an empty graph. Only the graph itself must exist:

CREATE EXTENSION IF NOT EXISTS age;
LOAD 'age';
SET search_path = ag_catalog, "$user", public;
SELECT create_graph('graph_test');

Configuration

  • None beyond the stock AGE extension. No additional modules (no PostGIS, etc.), default search_path handling as shown above.

Command that triggers the error

SELECT * FROM cypher('graph_test', $$ RETURN 1 LIMIT reduce(a = 1, b IN [0] | a + b) $$) AS (c0 agtype);
ERROR:  unsupported SubLink

(SQLSTATE 0A000, internal error.) Run the statement on its own (e.g. psql -c "..."): when several statements are piped to psql at once, stdout/stderr buffering can push the ERROR line to a different position in the output and make it look like the query succeeded.

The failure is specific to LIMIT/SKIP: the same reduce returns a row without one, and LIMIT accepts other data-free expressions:

-- works: reduce without LIMIT
SELECT * FROM cypher('graph_test', $$ RETURN reduce(a = 1, b IN [0] | a + b) $$) AS (c0 agtype);
-- works: arithmetic / function in LIMIT
SELECT * FROM cypher('graph_test', $$ RETURN 1 LIMIT 1 + 1 $$) AS (c0 agtype);
SELECT * FROM cypher('graph_test', $$ RETURN 1 LIMIT size([0, 0]) $$) AS (c0 agtype);

Environment

  • Version: 1.8.0 (official apache/age:1.8.0 Docker image)
  • PostgreSQL: 18.1 (Debian 18.1-1.pgdg13+2), x86_64

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