Skip to content

Commit 094e29f

Browse files
committed
Support Cypher Subquery expression in Cypher Query
1 parent f7e2e3f commit 094e29f

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

regress/expected/cypher_match.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,18 @@ RETURN (SELECT COUNT(*) FROM tst);
15721572
3
15731573
(1 row)
15741574

1575+
CYPHER WITH (RETURN 1) as a RETURN a;
1576+
a
1577+
---
1578+
1
1579+
(1 row)
1580+
1581+
CYPHER WITH (SELECT i FROM tst LIMIT 1) as a RETURN a;
1582+
a
1583+
---
1584+
1
1585+
(1 row)
1586+
15751587
--
15761588
-- Clean up
15771589
--

regress/sql/cypher_match.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ RETURN (SELECT * FROM tst);
352352

353353
RETURN (SELECT COUNT(*) FROM tst);
354354

355+
CYPHER WITH (RETURN 1) as a RETURN a;
356+
CYPHER WITH (SELECT i FROM tst LIMIT 1) as a RETURN a;
357+
355358
--
356359
-- Clean up
357360
--

src/backend/parser/cypher_gram.y

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17914,6 +17914,23 @@ cypher_expr_atom:
1791417914
}
1791517915
| expr_case
1791617916
| cypher_expr_func
17917+
| '(' cypher_stmt ')' %prec UMINUS
17918+
{
17919+
cypher_sub_pattern *sub;
17920+
17921+
sub = make_ag_node(cypher_sub_pattern);
17922+
sub->pattern = $2;
17923+
sub->kind = CSP_EXISTS;
17924+
17925+
SubLink *n = makeNode(SubLink);
17926+
n->subLinkType = EXPR_SUBLINK;
17927+
n->subLinkId = 0;
17928+
n->testexpr = NULL;
17929+
n->operName = NIL;
17930+
n->subselect = sub;
17931+
n->location = @1;
17932+
$$ = (Node *)n;
17933+
}
1791717934
| EXISTS '(' anonymous_path ')'
1791817935
{
1791917936
cypher_match *match = make_ag_node(cypher_match);

0 commit comments

Comments
 (0)