Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 1043: ERROR: container must be an array or object #1046

Merged
merged 1 commit into from
Jul 17, 2023
Merged
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/cypher_vle.out
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,50 @@ NOTICE: graph "access" has been dropped

(1 row)

-- issue 1043
SELECT create_graph('issue_1043');
NOTICE: graph "issue_1043" has been created
create_graph
--------------

(1 row)

SELECT * FROM cypher('issue_1043', $$ CREATE (n)-[:KNOWS {n:'hello'}]->({n:'hello'}) $$) as (a agtype);
a
---
(0 rows)

SELECT * FROM cypher('issue_1043', $$ MATCH (x)<-[y *]-(),({n:y[0].n}) RETURN x $$) as (a agtype);
a
----------------------------------------------------------------------------
{"id": 281474976710658, "label": "", "properties": {"n": "hello"}}::vertex
(1 row)

SELECT * FROM cypher('issue_1043', $$ CREATE (n)-[:KNOWS {n:'hello'}]->({n:'hello'}) $$) as (a agtype);
a
---
(0 rows)

SELECT * FROM cypher('issue_1043', $$ MATCH (x)<-[y *]-(),({n:y[0].n}) RETURN x $$) as (a agtype);
a
----------------------------------------------------------------------------
{"id": 281474976710658, "label": "", "properties": {"n": "hello"}}::vertex
{"id": 281474976710658, "label": "", "properties": {"n": "hello"}}::vertex
{"id": 281474976710660, "label": "", "properties": {"n": "hello"}}::vertex
{"id": 281474976710660, "label": "", "properties": {"n": "hello"}}::vertex
(4 rows)

SELECT drop_graph('issue_1043', true);
NOTICE: drop cascades to 3 other objects
DETAIL: drop cascades to table issue_1043._ag_label_vertex
drop cascades to table issue_1043._ag_label_edge
drop cascades to table issue_1043."KNOWS"
NOTICE: graph "issue_1043" has been dropped
drop_graph
------------

(1 row)

--
-- Clean up
--
Expand Down
9 changes: 9 additions & 0 deletions regress/sql/cypher_vle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ SELECT * FROM cypher('access',$$ MATCH ()-[e*]->() RETURN e[0].arry[2], e[1].arr

SELECT drop_graph('access', true);

-- issue 1043
SELECT create_graph('issue_1043');
SELECT * FROM cypher('issue_1043', $$ CREATE (n)-[:KNOWS {n:'hello'}]->({n:'hello'}) $$) as (a agtype);
SELECT * FROM cypher('issue_1043', $$ MATCH (x)<-[y *]-(),({n:y[0].n}) RETURN x $$) as (a agtype);
SELECT * FROM cypher('issue_1043', $$ CREATE (n)-[:KNOWS {n:'hello'}]->({n:'hello'}) $$) as (a agtype);
SELECT * FROM cypher('issue_1043', $$ MATCH (x)<-[y *]-(),({n:y[0].n}) RETURN x $$) as (a agtype);

SELECT drop_graph('issue_1043', true);

--
-- Clean up
--
Expand Down
19 changes: 18 additions & 1 deletion src/backend/utils/adt/agtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -3486,8 +3486,25 @@ Datum agtype_access_operator(PG_FUNCTION_ARGS)
/* get the container argument. It could be an object or array */
container = DATUM_GET_AGTYPE_P(args[0]);

/* if it is a binary container, check for a VLE vpc */
if (AGT_ROOT_IS_BINARY(container))
{
if (AGT_ROOT_BINARY_FLAGS(container) == AGT_FBINARY_TYPE_VLE_PATH)
{
/* retrieve an array of edges from the vpc */
container_value = agtv_materialize_vle_edges(container);
/* clear the container reference */
container = NULL;
}
else
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("binary container must be a VLE vpc")));
}
}
/* if it is a scalar, open it and pull out the value */
if (AGT_ROOT_IS_SCALAR(container))
else if (AGT_ROOT_IS_SCALAR(container))
{
container_value = get_ith_agtype_value_from_container(&container->root,
0);
Expand Down