From 7522d8ae2637ace8fe7aeec786b197af83780a40 Mon Sep 17 00:00:00 2001 From: Sai Harsha Vinay Kudikala Date: Mon, 16 Nov 2026 07:25:06 -0500 Subject: [PATCH] Present default-label vertices and edges consistently across access paths Vertices and edges in the default labels (_ag_label_vertex and _ag_label_edge) are presented as having no label when they are built by pattern matching or CREATE, but startNode()/endNode() and the VLE path builder used the internal label name, so the same vertex could report labels() as ["_ag_label_vertex"] or [""] depending on how it was reached - e.g. when rebound by id across an OPTIONAL MATCH barrier. Add get_display_label_name() and use it wherever a vertex or edge is reconstructed for output: get_vertex() (startNode, endNode and _get_vertex_by_graphid) and the VLE path/edges builders. _label_name() now uses the same helper. Update the affected regression expectations and add a regression test comparing labels() across access paths. Fixes #2612 --- regress/expected/age_global_graph.out | 84 +++++++++++++------------- regress/expected/cypher_match.out | 10 ++-- regress/expected/cypher_unwind.out | 6 +- regress/expected/cypher_vle.out | 86 +++++++++++++-------------- regress/expected/cypher_with.out | 16 ++--- regress/expected/expr.out | 65 ++++++++++++++++++++ regress/sql/expr.sql | 29 +++++++++ src/backend/catalog/ag_label.c | 23 ++++--- src/backend/utils/adt/age_vle.c | 3 + src/backend/utils/adt/agtype.c | 3 +- src/include/catalog/ag_label.h | 1 + 11 files changed, 216 insertions(+), 110 deletions(-) diff --git a/regress/expected/age_global_graph.out b/regress/expected/age_global_graph.out index 6f269e6ab..705ca9cd6 100644 --- a/regress/expected/age_global_graph.out +++ b/regress/expected/age_global_graph.out @@ -779,9 +779,9 @@ $$) AS (v agtype); SELECT * FROM cypher('rewrite_inval', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710715, "label": "_ag_label_vertex", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "_ag_label_vertex", "properties": {"id": 60}}::vertex]::path + p +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710715, "label": "", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "", "properties": {"id": 60}}::vertex]::path (1 row) -- CLUSTER rewrites in index order, moving the survivors to the front @@ -789,9 +789,9 @@ CLUSTER rewrite_inval."_ag_label_vertex" USING "_ag_label_vertex_pkey"; SELECT * FROM cypher('rewrite_inval', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710715, "label": "_ag_label_vertex", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "_ag_label_vertex", "properties": {"id": 60}}::vertex]::path + p +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710715, "label": "", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "", "properties": {"id": 60}}::vertex]::path (1 row) -- make dead space again so VACUUM FULL has something to compact away @@ -812,9 +812,9 @@ $$) AS (v agtype); SELECT * FROM cypher('rewrite_inval', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710715, "label": "_ag_label_vertex", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "_ag_label_vertex", "properties": {"id": 60}}::vertex]::path + p +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710715, "label": "", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "", "properties": {"id": 60}}::vertex]::path (1 row) VACUUM FULL rewrite_inval."_ag_label_vertex"; @@ -822,9 +822,9 @@ VACUUM FULL rewrite_inval."R"; SELECT * FROM cypher('rewrite_inval', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710715, "label": "_ag_label_vertex", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "_ag_label_vertex", "properties": {"id": 60}}::vertex]::path + p +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710715, "label": "", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "", "properties": {"id": 60}}::vertex]::path (1 row) -- plain VACUUM and ANALYZE leave tuples in place, so they are not rewrites and @@ -834,9 +834,9 @@ ANALYZE rewrite_inval."_ag_label_vertex"; SELECT * FROM cypher('rewrite_inval', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710715, "label": "_ag_label_vertex", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "_ag_label_vertex", "properties": {"id": 60}}::vertex]::path + p +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710715, "label": "", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "", "properties": {"id": 60}}::vertex]::path (1 row) -- the parenthesised spelling is a rewrite too @@ -844,9 +844,9 @@ VACUUM (FULL) rewrite_inval."_ag_label_vertex"; SELECT * FROM cypher('rewrite_inval', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710715, "label": "_ag_label_vertex", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "_ag_label_vertex", "properties": {"id": 60}}::vertex]::path + p +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710715, "label": "", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "", "properties": {"id": 60}}::vertex]::path (1 row) -- and FULL turned off explicitly is not @@ -854,9 +854,9 @@ VACUUM (FULL false) rewrite_inval."_ag_label_vertex"; SELECT * FROM cypher('rewrite_inval', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710715, "label": "_ag_label_vertex", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "_ag_label_vertex", "properties": {"id": 60}}::vertex]::path + p +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710715, "label": "", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "", "properties": {"id": 60}}::vertex]::path (1 row) -- naming no relation rewrites the whole database, which has to invalidate @@ -865,9 +865,9 @@ VACUUM FULL; SELECT * FROM cypher('rewrite_inval', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710715, "label": "_ag_label_vertex", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "_ag_label_vertex", "properties": {"id": 60}}::vertex]::path + p +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710715, "label": "", "properties": {"id": 59}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710716, "start_id": 281474976710715, "properties": {}}::edge, {"id": 281474976710716, "label": "", "properties": {"id": 60}}::vertex]::path (1 row) SELECT drop_graph('rewrite_inval', true); @@ -926,9 +926,9 @@ UPDATE null_props."R" SET properties = ag_catalog.agtype_build_map(); SELECT * FROM cypher('null_props', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {}}::vertex]::path + p +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {}}::vertex]::path (1 row) SELECT drop_graph('null_props', true); @@ -994,9 +994,9 @@ $$) AS (v agtype); SELECT * FROM cypher('drop_rollback', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path + p +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path (1 row) BEGIN; @@ -1015,9 +1015,9 @@ ROLLBACK; SELECT * FROM cypher('drop_rollback', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path + p +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path (1 row) -- and a later mutation still invalidates correctly @@ -1029,9 +1029,9 @@ SELECT * FROM cypher('drop_rollback', $$ CREATE ({id: 3}) $$) AS (v agtype); SELECT * FROM cypher('drop_rollback', $$ MATCH p = (n0)-[:R*..2]->(n1) RETURN p $$) AS (p agtype); - p -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path + p +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path (1 row) SELECT drop_graph('drop_rollback', true); @@ -1066,9 +1066,9 @@ $$) AS (v agtype); SELECT * FROM cypher('slot_reuse', $$ MATCH p = (a)-[:R*..2]->(b) RETURN p $$) AS (p agtype); - p ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 111}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 222}}::vertex]::path + p +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 111}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 222}}::vertex]::path (1 row) SELECT drop_graph('slot_reuse', true); @@ -1100,9 +1100,9 @@ $$) AS (v agtype); SELECT * FROM cypher('slot_reuse', $$ MATCH p = (a)-[:R*..2]->(b) RETURN p $$) AS (p agtype); - p ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 333}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 444}}::vertex]::path + p +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 333}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 444}}::vertex]::path (1 row) SELECT drop_graph('slot_reuse', true); diff --git a/regress/expected/cypher_match.out b/regress/expected/cypher_match.out index ab51486b3..53d51b5be 100644 --- a/regress/expected/cypher_match.out +++ b/regress/expected/cypher_match.out @@ -2802,11 +2802,11 @@ SELECT * FROM cypher('cypher_match', $$ MATCH p=()-[*]->() WHERE length(p) > 1 R (3 rows) SELECT * FROM cypher('cypher_match', $$ MATCH p=()-[*]->() WHERE size(nodes(p)) = 3 RETURN nodes(p)[0] $$) as (nodes agtype); - nodes ------------------------------------------------------------------------------------------------------ - {"id": 281474976710660, "label": "_ag_label_vertex", "properties": {"age": 4, "name": "F"}}::vertex - {"id": 281474976710667, "label": "_ag_label_vertex", "properties": {"name": "Dave"}}::vertex - {"id": 281474976710668, "label": "_ag_label_vertex", "properties": {"name": "John"}}::vertex + nodes +------------------------------------------------------------------------------------- + {"id": 281474976710660, "label": "", "properties": {"age": 4, "name": "F"}}::vertex + {"id": 281474976710667, "label": "", "properties": {"name": "Dave"}}::vertex + {"id": 281474976710668, "label": "", "properties": {"name": "John"}}::vertex (3 rows) SELECT * FROM cypher('cypher_match', $$ MATCH (n {name:'Dave'}) MATCH p=()-[*]->() WHERE nodes(p)[0] = n RETURN length(p) $$) as (length agtype); diff --git a/regress/expected/cypher_unwind.out b/regress/expected/cypher_unwind.out index fae1a26ff..bc7a67891 100644 --- a/regress/expected/cypher_unwind.out +++ b/regress/expected/cypher_unwind.out @@ -152,9 +152,9 @@ SELECT * FROM cypher('cypher_unwind', $$ UNWIND [p] as path RETURN path $$) as (i agtype); - i ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"a": [1, 2, 3], "name": "node1"}}::vertex, {"id": 844424930131969, "label": "KNOWS", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"a": [4, 5, 6], "name": "node2"}}::vertex, {"id": 844424930131970, "label": "KNOWS", "end_id": 281474976710659, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"a": [7, 8, 9], "name": "node3"}}::vertex]::path + i +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"a": [1, 2, 3], "name": "node1"}}::vertex, {"id": 844424930131969, "label": "KNOWS", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"a": [4, 5, 6], "name": "node2"}}::vertex, {"id": 844424930131970, "label": "KNOWS", "end_id": 281474976710659, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"a": [7, 8, 9], "name": "node3"}}::vertex]::path (1 row) SELECT * FROM cypher('cypher_unwind', $$ diff --git a/regress/expected/cypher_vle.out b/regress/expected/cypher_vle.out index fac61e5f3..fdde43a32 100644 --- a/regress/expected/cypher_vle.out +++ b/regress/expected/cypher_vle.out @@ -1368,10 +1368,10 @@ SELECT * FROM cypher('issue_2549', $$ DETACH DELETE n0, n1 RETURN id(n1) AS k, p $$) AS (k agtype, p agtype) ORDER BY k; - k | p ------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 281474976710658 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path - 281474976710659 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710657, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"id": 3}}::vertex]::path + k | p +-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 281474976710658 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path + 281474976710659 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710657, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"id": 3}}::vertex]::path (2 rows) SELECT drop_graph('issue_2549', true); @@ -1407,12 +1407,12 @@ SELECT * FROM cypher('issue_2549', $$ DETACH DELETE n0, n1 RETURN id(n1) AS k, p $$) AS (k agtype, p agtype) ORDER BY k; - k | p ------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 281474976710658 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path - 281474976710659 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710657, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"id": 3}}::vertex]::path - 281474976710660 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131971, "label": "R", "end_id": 281474976710657, "start_id": 281474976710660, "properties": {}}::edge, {"id": 281474976710660, "label": "_ag_label_vertex", "properties": {"id": 4}}::vertex]::path - 281474976710661 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131972, "label": "R", "end_id": 281474976710657, "start_id": 281474976710661, "properties": {}}::edge, {"id": 281474976710661, "label": "_ag_label_vertex", "properties": {"id": 5}}::vertex]::path + k | p +-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 281474976710658 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path + 281474976710659 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710657, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"id": 3}}::vertex]::path + 281474976710660 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131971, "label": "R", "end_id": 281474976710657, "start_id": 281474976710660, "properties": {}}::edge, {"id": 281474976710660, "label": "", "properties": {"id": 4}}::vertex]::path + 281474976710661 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131972, "label": "R", "end_id": 281474976710657, "start_id": 281474976710661, "properties": {}}::edge, {"id": 281474976710661, "label": "", "properties": {"id": 5}}::vertex]::path (4 rows) SELECT drop_graph('issue_2549', true); @@ -1446,10 +1446,10 @@ SELECT * FROM cypher('issue_2549', $$ DETACH DELETE n1 RETURN id(n1) AS k, p $$) AS (k agtype, p agtype) ORDER BY k; - k | p ------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 281474976710658 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path - 281474976710659 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710657, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"id": 3}}::vertex]::path + k | p +-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 281474976710658 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path + 281474976710659 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710657, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"id": 3}}::vertex]::path (2 rows) SELECT drop_graph('issue_2549', true); @@ -1483,9 +1483,9 @@ SELECT * FROM cypher('issue_2549', $$ DELETE e RETURN p $$) AS (p agtype); - p -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {"w": 7}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path + p +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {"w": 7}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path (1 row) SELECT drop_graph('issue_2549', true); @@ -1556,9 +1556,9 @@ SELECT * FROM cypher('issue_2549', $$ DETACH DELETE n0, n1 RETURN p $$) AS (p agtype); - p -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {"w": 7}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path + p +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {"w": 7}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path (1 row) SELECT drop_graph('issue_2549', true); @@ -1592,11 +1592,11 @@ SELECT * FROM cypher('issue_2549', $$ DETACH DELETE n0, n1 RETURN id(n0) AS k0, id(n1) AS k1, length(p) AS len, p $$) AS (k0 agtype, k1 agtype, len agtype, p agtype) ORDER BY k0, k1, len; - k0 | k1 | len | p ------------------+-----------------+-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 281474976710657 | 281474976710657 | 0 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex]::path - 281474976710657 | 281474976710658 | 1 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path - 281474976710658 | 281474976710658 | 0 | [{"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path + k0 | k1 | len | p +-----------------+-----------------+-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 281474976710657 | 281474976710657 | 0 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex]::path + 281474976710657 | 281474976710658 | 1 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path + 281474976710658 | 281474976710658 | 0 | [{"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path (3 rows) SELECT drop_graph('issue_2549', true); @@ -1635,9 +1635,9 @@ SELECT * FROM cypher('issue_2549', $$ DETACH DELETE n0 RETURN p $$) AS (p agtype); - p -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710657, "properties": {"s": 1}}::edge, {"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex]::path + p +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710657, "properties": {"s": 1}}::edge, {"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex]::path (1 row) SELECT drop_graph('issue_2549', true); @@ -1709,9 +1709,9 @@ SELECT * FROM cypher('issue_2549', $$ DETACH DELETE n0, n1 RETURN p $$) AS (p agtype); - p ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131971, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710659, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"id": 3}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710660, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710660, "label": "_ag_label_vertex", "properties": {"id": 4}}::vertex]::path + p +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131971, "label": "R", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710659, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"id": 3}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710660, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710660, "label": "", "properties": {"id": 4}}::vertex]::path (1 row) SELECT drop_graph('issue_2549', true); @@ -1753,9 +1753,9 @@ SELECT * FROM cypher('issue_2549', $$ MATCH p = (n0)<-[:R*..2]-(n1) RETURN id(n1) AS k, p $$) AS (k agtype, p agtype) ORDER BY k; - k | p ------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 281474976710659 | [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710657, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"id": 3}}::vertex]::path + k | p +-----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 281474976710659 | [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131970, "label": "R", "end_id": 281474976710657, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"id": 3}}::vertex]::path (1 row) COMMIT; @@ -1792,9 +1792,9 @@ SELECT * FROM cypher('issue_2549', $$ DETACH DELETE n0, n1 RETURN p $$) AS (p agtype); - p -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path + p +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path (1 row) ROLLBACK TO s1; @@ -1802,9 +1802,9 @@ SELECT * FROM cypher('issue_2549', $$ MATCH p = (n0)<-[:R*..2]-(n1) RETURN p $$) AS (p agtype); - p -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path + p +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path (1 row) COMMIT; @@ -1847,9 +1847,9 @@ SELECT * FROM cypher('issue_2549', $$ DETACH DELETE n0, n1 RETURN p $$) AS (p agtype); - p -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"id": 2}}::vertex]::path + p +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"id": 1}}::vertex, {"id": 844424930131969, "label": "R", "end_id": 281474976710657, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"id": 2}}::vertex]::path (1 row) ROLLBACK; diff --git a/regress/expected/cypher_with.out b/regress/expected/cypher_with.out index 2fc330616..3569e744d 100644 --- a/regress/expected/cypher_with.out +++ b/regress/expected/cypher_with.out @@ -138,14 +138,14 @@ SELECT * FROM cypher('cypher_with', $$ RETURN p ORDER BY p ASC $$) AS (pattern agtype); - pattern --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 844424930131969, "label": "BLOCKS", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"age": 25, "name": "Caesar"}}::vertex, {"id": 1125899906842626, "label": "KNOWS", "end_id": 281474976710661, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710661, "label": "_ag_label_vertex", "properties": {"age": 37, "name": "George"}}::vertex]::path - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 1125899906842625, "label": "KNOWS", "end_id": 281474976710659, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"age": 55, "name": "Bossman"}}::vertex, {"id": 844424930131970, "label": "BLOCKS", "end_id": 281474976710660, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710660, "label": "_ag_label_vertex", "properties": {"age": 35, "name": "David"}}::vertex]::path - [{"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 1125899906842625, "label": "KNOWS", "end_id": 281474976710659, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"age": 55, "name": "Bossman"}}::vertex, {"id": 1125899906842627, "label": "KNOWS", "end_id": 281474976710661, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710661, "label": "_ag_label_vertex", "properties": {"age": 37, "name": "George"}}::vertex]::path - [{"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"age": 55, "name": "Bossman"}}::vertex, {"id": 844424930131970, "label": "BLOCKS", "end_id": 281474976710660, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710660, "label": "_ag_label_vertex", "properties": {"age": 35, "name": "David"}}::vertex, {"id": 1125899906842628, "label": "KNOWS", "end_id": 281474976710657, "start_id": 281474976710660, "properties": {}}::edge, {"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"age": 36, "name": "Andres"}}::vertex]::path - [{"id": 281474976710660, "label": "_ag_label_vertex", "properties": {"age": 35, "name": "David"}}::vertex, {"id": 1125899906842628, "label": "KNOWS", "end_id": 281474976710657, "start_id": 281474976710660, "properties": {}}::edge, {"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 844424930131969, "label": "BLOCKS", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "_ag_label_vertex", "properties": {"age": 25, "name": "Caesar"}}::vertex]::path - [{"id": 281474976710660, "label": "_ag_label_vertex", "properties": {"age": 35, "name": "David"}}::vertex, {"id": 1125899906842628, "label": "KNOWS", "end_id": 281474976710657, "start_id": 281474976710660, "properties": {}}::edge, {"id": 281474976710657, "label": "_ag_label_vertex", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 1125899906842625, "label": "KNOWS", "end_id": 281474976710659, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710659, "label": "_ag_label_vertex", "properties": {"age": 55, "name": "Bossman"}}::vertex]::path + pattern +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + [{"id": 281474976710657, "label": "", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 844424930131969, "label": "BLOCKS", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"age": 25, "name": "Caesar"}}::vertex, {"id": 1125899906842626, "label": "KNOWS", "end_id": 281474976710661, "start_id": 281474976710658, "properties": {}}::edge, {"id": 281474976710661, "label": "", "properties": {"age": 37, "name": "George"}}::vertex]::path + [{"id": 281474976710657, "label": "", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 1125899906842625, "label": "KNOWS", "end_id": 281474976710659, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"age": 55, "name": "Bossman"}}::vertex, {"id": 844424930131970, "label": "BLOCKS", "end_id": 281474976710660, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710660, "label": "", "properties": {"age": 35, "name": "David"}}::vertex]::path + [{"id": 281474976710657, "label": "", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 1125899906842625, "label": "KNOWS", "end_id": 281474976710659, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"age": 55, "name": "Bossman"}}::vertex, {"id": 1125899906842627, "label": "KNOWS", "end_id": 281474976710661, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710661, "label": "", "properties": {"age": 37, "name": "George"}}::vertex]::path + [{"id": 281474976710659, "label": "", "properties": {"age": 55, "name": "Bossman"}}::vertex, {"id": 844424930131970, "label": "BLOCKS", "end_id": 281474976710660, "start_id": 281474976710659, "properties": {}}::edge, {"id": 281474976710660, "label": "", "properties": {"age": 35, "name": "David"}}::vertex, {"id": 1125899906842628, "label": "KNOWS", "end_id": 281474976710657, "start_id": 281474976710660, "properties": {}}::edge, {"id": 281474976710657, "label": "", "properties": {"age": 36, "name": "Andres"}}::vertex]::path + [{"id": 281474976710660, "label": "", "properties": {"age": 35, "name": "David"}}::vertex, {"id": 1125899906842628, "label": "KNOWS", "end_id": 281474976710657, "start_id": 281474976710660, "properties": {}}::edge, {"id": 281474976710657, "label": "", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 844424930131969, "label": "BLOCKS", "end_id": 281474976710658, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710658, "label": "", "properties": {"age": 25, "name": "Caesar"}}::vertex]::path + [{"id": 281474976710660, "label": "", "properties": {"age": 35, "name": "David"}}::vertex, {"id": 1125899906842628, "label": "KNOWS", "end_id": 281474976710657, "start_id": 281474976710660, "properties": {}}::edge, {"id": 281474976710657, "label": "", "properties": {"age": 36, "name": "Andres"}}::vertex, {"id": 1125899906842625, "label": "KNOWS", "end_id": 281474976710659, "start_id": 281474976710657, "properties": {}}::edge, {"id": 281474976710659, "label": "", "properties": {"age": 55, "name": "Bossman"}}::vertex]::path (6 rows) -- MATCH/WHERE with WITH/WHERE diff --git a/regress/expected/expr.out b/regress/expected/expr.out index 806a6f65c..65d556289 100644 --- a/regress/expected/expr.out +++ b/regress/expected/expr.out @@ -2880,6 +2880,71 @@ ERROR: function ag_catalog.age_endnode() does not exist LINE 2: RETURN endNode() ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. +-- +-- Labels of a vertex in the default vertex label must be presented the +-- same way whether the vertex comes from pattern matching or from +-- startNode()/endNode(), and must not change when the vertex is rebound +-- by id across an OPTIONAL MATCH barrier (issue #2612) +-- +SELECT * FROM create_graph('default_label'); +NOTICE: graph "default_label" has been created + create_graph +-------------- + +(1 row) + +SELECT * FROM cypher('default_label', $$ + CREATE (s:L {role: 'source'})-[:R]->(t {role: 'target'}) +$$) AS (v agtype); + v +--- +(0 rows) + +SELECT * FROM cypher('default_label', $$ + MATCH (s:L)-[r:R]->(t) + RETURN labels(t) AS from_match, labels(endNode(r)) AS from_endnode, + labels(startNode(r)) AS from_startnode +$$) AS (from_match agtype, from_endnode agtype, from_startnode agtype); + from_match | from_endnode | from_startnode +------------+--------------+---------------- + [""] | [""] | ["L"] +(1 row) + +SELECT * FROM cypher('default_label', $$ + MATCH (s:L)-[r:R]->(t) + WITH endNode(r) AS e + OPTIONAL MATCH (v) WHERE id(v) = id(e) + RETURN labels(e) AS before_barrier, labels(v) AS after_barrier +$$) AS (before_barrier agtype, after_barrier agtype); + before_barrier | after_barrier +----------------+--------------- + [""] | [""] +(1 row) + +-- a vertex reached through a variable-length path must be identical to +-- the same vertex returned by endNode() +SELECT * FROM cypher('default_label', $$ + MATCH p=(s:L)-[*1]->(t) + RETURN nodes(p)[1] = endNode(relationships(p)[0]) AS vle_matches_endnode, + labels(nodes(p)[1]) AS vle_labels +$$) AS (vle_matches_endnode agtype, vle_labels agtype); + vle_matches_endnode | vle_labels +---------------------+------------ + true | [""] +(1 row) + +SELECT * FROM drop_graph('default_label', true); +NOTICE: drop cascades to 4 other objects +DETAIL: drop cascades to table default_label._ag_label_vertex +drop cascades to table default_label._ag_label_edge +drop cascades to table default_label."L" +drop cascades to table default_label."R" +NOTICE: graph "default_label" has been dropped + drop_graph +------------ + +(1 row) + -- type() SELECT * FROM cypher('expr', $$ MATCH ()-[e]-() RETURN type(e) diff --git a/regress/sql/expr.sql b/regress/sql/expr.sql index d4d900a1c..e8b9b41ec 100644 --- a/regress/sql/expr.sql +++ b/regress/sql/expr.sql @@ -1212,6 +1212,35 @@ $$) AS (endNode agtype); SELECT * FROM cypher('expr', $$ RETURN endNode() $$) AS (endNode agtype); +-- +-- Labels of a vertex in the default vertex label must be presented the +-- same way whether the vertex comes from pattern matching or from +-- startNode()/endNode(), and must not change when the vertex is rebound +-- by id across an OPTIONAL MATCH barrier (issue #2612) +-- +SELECT * FROM create_graph('default_label'); +SELECT * FROM cypher('default_label', $$ + CREATE (s:L {role: 'source'})-[:R]->(t {role: 'target'}) +$$) AS (v agtype); +SELECT * FROM cypher('default_label', $$ + MATCH (s:L)-[r:R]->(t) + RETURN labels(t) AS from_match, labels(endNode(r)) AS from_endnode, + labels(startNode(r)) AS from_startnode +$$) AS (from_match agtype, from_endnode agtype, from_startnode agtype); +SELECT * FROM cypher('default_label', $$ + MATCH (s:L)-[r:R]->(t) + WITH endNode(r) AS e + OPTIONAL MATCH (v) WHERE id(v) = id(e) + RETURN labels(e) AS before_barrier, labels(v) AS after_barrier +$$) AS (before_barrier agtype, after_barrier agtype); +-- a vertex reached through a variable-length path must be identical to +-- the same vertex returned by endNode() +SELECT * FROM cypher('default_label', $$ + MATCH p=(s:L)-[*1]->(t) + RETURN nodes(p)[1] = endNode(relationships(p)[0]) AS vle_matches_endnode, + labels(nodes(p)[1]) AS vle_labels +$$) AS (vle_matches_endnode agtype, vle_labels agtype); +SELECT * FROM drop_graph('default_label', true); -- type() SELECT * FROM cypher('expr', $$ MATCH ()-[e]-() RETURN type(e) diff --git a/src/backend/catalog/ag_label.c b/src/backend/catalog/ag_label.c index 78579fe8d..4f8b988c6 100644 --- a/src/backend/catalog/ag_label.c +++ b/src/backend/catalog/ag_label.c @@ -179,6 +179,19 @@ char *get_label_name(int32 label_id, Oid graph_oid) return NULL; } +/* + * Vertices and edges that belong to a default label are presented to + * users as having no label. Map a label name to the name that should + * appear in a constructed vertex or edge. The result may be a string + * literal; it must not be modified or freed. + */ +char *get_display_label_name(char *label_name) +{ + if (IS_AG_DEFAULT_LABEL(label_name)) + return ""; + return label_name; +} + PG_FUNCTION_INFO_V1(_label_name); /* @@ -219,14 +232,8 @@ Datum _label_name(PG_FUNCTION_ARGS) } /* Convert cstring to agtype string */ - if (IS_AG_DEFAULT_LABEL(label_name)) - { - result = DATUM_GET_AGTYPE_P(string_to_agtype("")); - } - else - { - result = DATUM_GET_AGTYPE_P(string_to_agtype(label_name)); - } + result = DATUM_GET_AGTYPE_P( + string_to_agtype(get_display_label_name(label_name))); PG_RETURN_POINTER(result); } diff --git a/src/backend/utils/adt/age_vle.c b/src/backend/utils/adt/age_vle.c index c4dc7efdb..495393487 100644 --- a/src/backend/utils/adt/age_vle.c +++ b/src/backend/utils/adt/age_vle.c @@ -1803,6 +1803,7 @@ static agtype_value *build_edge_list(VLE_path_container *vpc) ee = get_edge_entry(ggctx, graphid_array[index]); /* get the label name from the oid */ label_name = get_rel_name(get_edge_entry_label_table_oid(ee)); + label_name = get_display_label_name(label_name); /* reconstruct the edge */ agtv_edge = agtype_value_build_edge(get_edge_entry_id(ee), label_name, get_edge_entry_end_vertex_id(ee), @@ -1874,6 +1875,7 @@ static agtype_value *build_path(VLE_path_container *vpc) ve = get_vertex_entry(ggctx, graphid_array[index]); /* get the label name from the oid */ label_name = get_rel_name(get_vertex_entry_label_table_oid(ve)); + label_name = get_display_label_name(label_name); /* reconstruct the vertex */ agtv_vertex = agtype_value_build_vertex(get_vertex_entry_id(ve), label_name, @@ -1895,6 +1897,7 @@ static agtype_value *build_path(VLE_path_container *vpc) ee = get_edge_entry(ggctx, graphid_array[index+1]); /* get the label name from the oid */ label_name = get_rel_name(get_edge_entry_label_table_oid(ee)); + label_name = get_display_label_name(label_name); /* reconstruct the edge */ agtv_edge = agtype_value_build_edge(get_edge_entry_id(ee), label_name, get_edge_entry_end_vertex_id(ee), diff --git a/src/backend/utils/adt/agtype.c b/src/backend/utils/adt/agtype.c index cc9cc7717..a2268e2f8 100644 --- a/src/backend/utils/adt/agtype.c +++ b/src/backend/utils/adt/agtype.c @@ -6239,7 +6239,8 @@ static Datum get_vertex(const char *graph, const char *vertex_label, properties = column_get_datum(tupdesc, tuple, 1, "properties", AGTYPEOID, true); /* reconstruct the vertex */ - label_agtype = DATUM_GET_AGTYPE_P(string_to_agtype((char *)vertex_label)); + label_agtype = DATUM_GET_AGTYPE_P( + string_to_agtype(get_display_label_name((char *)vertex_label))); result = DirectFunctionCall3(_agtype_build_vertex, id, PointerGetDatum(label_agtype), properties); diff --git a/src/include/catalog/ag_label.h b/src/include/catalog/ag_label.h index e6b9a1ca7..52fbb9a8a 100644 --- a/src/include/catalog/ag_label.h +++ b/src/include/catalog/ag_label.h @@ -75,6 +75,7 @@ char *get_label_relation_name(const char *label_name, Oid graph_oid); char get_label_kind(const char *label_name, Oid label_graph); char *get_label_seq_relation_name(const char *label_name); char *get_label_name(int32 label_id, Oid graph_oid); +char *get_display_label_name(char *label_name); bool label_id_exists(Oid graph_oid, int32 label_id); RangeVar *get_label_range_var(char *graph_name, Oid graph_oid,