hkjiang26 opened a new issue, #2518:
URL: https://github.com/apache/age/issues/2518

   ## 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]`). Neo4j runs 
the same statement normally. 
   
   ## 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:
   
   ```pgsql
   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
   
   ```pgsql
   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:
   
   ```pgsql
   -- 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to