Skip to content

fix: allow reduce and list comprehensions in LIMIT and SKIP - #2557

Open
1fanwang wants to merge 1 commit into
apache:masterfrom
1fanwang:fix/sublink-limit-offset
Open

fix: allow reduce and list comprehensions in LIMIT and SKIP#2557
1fanwang wants to merge 1 commit into
apache:masterfrom
1fanwang:fix/sublink-limit-offset

Conversation

@1fanwang

Copy link
Copy Markdown

LIMIT and SKIP reject reduce() and list comprehensions with ERROR: 0A000: unsupported SubLink. These expressions do not contain a user-written subquery, but AGE represents their iteration internally as a sublink.

The parser now permits sublinks while transforming LIMIT and OFFSET expressions, matching PostgreSQL's handling of those contexts. On current master, all four cases from the issue fail. On this branch, each returns 1.

Closes #2518.

Testing

Regression tests
$ git restore --source=0e30566226f017d53b7f52025803b38af3ad2b3f -- src/backend/parser/cypher_expr.c
$ docker build --target build -t age-2518 -f docker/Dockerfile .
$ docker run --rm age-2518 bash -lc 'chown -R postgres:postgres /age && su postgres -c "make -C /age PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config installcheck REGRESS=\"list_comprehension age_reduce\""'
not ok 1     - list_comprehension
not ok 2     - age_reduce
# 2 of 2 tests failed.

$ git restore --source=HEAD -- src/backend/parser/cypher_expr.c
$ docker build --target build -t age-2518 -f docker/Dockerfile .
$ docker run --rm age-2518 bash -lc 'chown -R postgres:postgres /age && su postgres -c "make -C /age PG_CONFIG=/usr/lib/postgresql/18/bin/pg_config installcheck REGRESS=\"list_comprehension age_reduce cypher_match cypher_subquery\""'
ok 1         - list_comprehension
ok 2         - age_reduce
ok 3         - cypher_match
ok 4         - cypher_subquery
1..4
# All 4 tests passed.
PostgreSQL 18.6 query results
# Current master, one error from each LIMIT/SKIP and reduce/list-comprehension case
ERROR:  0A000: unsupported SubLink
ERROR:  0A000: unsupported SubLink
ERROR:  0A000: unsupported SubLink
ERROR:  0A000: unsupported SubLink

# This branch, running the same four statements
 result
--------
 1
(1 row)

 result
--------
 1
(1 row)

 result
--------
 1
(1 row)

 result
--------
 1
(1 row)

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant