Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions regress/expected/expr.out
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,50 @@ $$RETURN 1 IN [[null]]$$) AS r(c boolean);
f
(1 row)

-- edge/vertex IN relationships()/nodes() (issue #2542 regression)
SELECT * FROM create_graph('expr_in_op');
NOTICE: graph "expr_in_op" has been created
create_graph
--------------

(1 row)

SELECT * FROM cypher('expr_in_op',
$$CREATE (a:L)-[:R]->(b)$$) AS r(c agtype);
c
---
(0 rows)

SELECT * FROM cypher('expr_in_op',
$$MATCH ()-[r0]->()
MATCH p0 = (:L)-[:R]->()
RETURN r0 IN relationships(p0)$$) AS r(c boolean);
c
---
t
(1 row)

SELECT * FROM cypher('expr_in_op',
$$MATCH (a:L)
MATCH p0 = (:L)-[:R]->()
RETURN a IN nodes(p0)$$) AS r(c boolean);
c
---
t
(1 row)

SELECT * FROM drop_graph('expr_in_op', true);
NOTICE: drop cascades to 4 other objects
DETAIL: drop cascades to table expr_in_op._ag_label_vertex
drop cascades to table expr_in_op._ag_label_edge
drop cascades to table expr_in_op."L"
drop cascades to table expr_in_op."R"
NOTICE: graph "expr_in_op" has been dropped
drop_graph
------------

(1 row)

-- empty list: x IN [] should always return false
SELECT * FROM cypher('expr',
$$RETURN 1 IN []$$) AS r(c boolean);
Expand Down
13 changes: 13 additions & 0 deletions regress/sql/expr.sql
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ SELECT * FROM cypher('expr',
$$RETURN 1 in [[1]]$$) AS r(c boolean);
SELECT * FROM cypher('expr',
$$RETURN 1 IN [[null]]$$) AS r(c boolean);
-- edge/vertex IN relationships()/nodes() (issue #2542 regression)
SELECT * FROM create_graph('expr_in_op');
SELECT * FROM cypher('expr_in_op',
$$CREATE (a:L)-[:R]->(b)$$) AS r(c agtype);
SELECT * FROM cypher('expr_in_op',
$$MATCH ()-[r0]->()
MATCH p0 = (:L)-[:R]->()
RETURN r0 IN relationships(p0)$$) AS r(c boolean);
SELECT * FROM cypher('expr_in_op',
$$MATCH (a:L)
MATCH p0 = (:L)-[:R]->()
RETURN a IN nodes(p0)$$) AS r(c boolean);
SELECT * FROM drop_graph('expr_in_op', true);
-- empty list: x IN [] should always return false
SELECT * FROM cypher('expr',
$$RETURN 1 IN []$$) AS r(c boolean);
Expand Down
18 changes: 10 additions & 8 deletions src/backend/utils/adt/agtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -4976,13 +4976,14 @@ Datum agtype_in_operator(PG_FUNCTION_ARGS)
agtv_arg = agtv_materialize_vle_edges(agt_arg);
array_size = agtv_arg->val.array.num_elems;

/* return null if the item to find is null */
if (PG_ARGISNULL(1))
/* get the item to search for, with proper edge/vertex coercion */
agt_item = get_one_agtype_from_variadic_args(fcinfo, 1, 1);

/* return null if the item is null or an agtype null */
if (agt_item == NULL)
{
PG_RETURN_NULL();
}
/* get the item to search for */
agt_item = AG_GET_ARG_AGTYPE_P(1);

/* init item iterator */
it_item = agtype_iterator_init(&agt_item->root);
Expand Down Expand Up @@ -5043,13 +5044,14 @@ Datum agtype_in_operator(PG_FUNCTION_ARGS)

array_size = AGT_ROOT_COUNT(agt_arg);

/* return null if the item to find is null */
if (PG_ARGISNULL(1))
/* get the item to search for, with proper edge/vertex coercion */
agt_item = get_one_agtype_from_variadic_args(fcinfo, 1, 1);

/* return null if the item is null or an agtype null */
if (agt_item == NULL)
{
PG_RETURN_NULL();
}
/* get the item to search for */
agt_item = AG_GET_ARG_AGTYPE_P(1);

/* init item iterator */
it_item = agtype_iterator_init(&agt_item->root);
Expand Down