Skip to content
Permalink
Browse files
Add zero boundary case [*0..x] to VLE
Added the zero boundary case [*0..x] to the VLE.

Fixed some Travis CI warnings in the VLE code.

Added additional regression tests.
  • Loading branch information
jrgemignani committed Jan 6, 2022
1 parent 0fe482d commit e64df3b96d7da57fbbb12e910dda141c36ca4db3
Showing 4 changed files with 140 additions and 36 deletions.
@@ -332,7 +332,7 @@ SELECT * FROM cypher('cypher_vle', $$MATCH p=(u:begin)-[*3..3]-(v:end) RETURN p
[{"id": 844424930131969, "label": "begin", "properties": {}}::vertex, {"id": 1125899906842628, "label": "edge", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {"name": "main edge", "number": 1, "dangerous": {"type": "all", "level": "all"}}}::edge, {"id": 1407374883553281, "label": "middle", "properties": {}}::vertex, {"id": 1125899906842627, "label": "edge", "end_id": 1407374883553282, "start_id": 1407374883553281, "properties": {"name": "main edge", "number": 2, "packages": [2, 4, 6], "dangerous": {"type": "all", "level": "all"}}}::edge, {"id": 1407374883553282, "label": "middle", "properties": {}}::vertex, {"id": 2533274790395905, "label": "bypass_edge", "end_id": 1688849860263937, "start_id": 1407374883553282, "properties": {"name": "bypass edge", "number": 1, "packages": [1, 3, 5, 7]}}::edge, {"id": 1688849860263937, "label": "end", "properties": {}}::vertex]::path
(12 rows)

-- Should find 2
-- Each should find 2
SELECT * FROM cypher('cypher_vle', $$MATCH p=(u:begin)<-[*]-(v:end) RETURN p $$) AS (e agtype);
e
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -449,13 +449,52 @@ $$) AS (e1 agtype);
13
(1 row)

-- should return 1 path
-- Should return 1 path
SELECT * FROM cypher('cypher_vle', $$ MATCH p=()<-[e1*]-(:end)-[e2*]->(:begin) RETURN p $$) AS (result agtype);
result
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[{"id": 1688849860263937, "label": "end", "properties": {}}::vertex, {"id": 1970324836974594, "label": "self_loop", "end_id": 1688849860263937, "start_id": 1688849860263937, "properties": {"name": "self loop", "number": 2, "dangerous": {"type": "all", "level": "all"}}}::edge, {"id": 1688849860263937, "label": "end", "properties": {}}::vertex, {"id": 2251799813685252, "label": "alternate_edge", "end_id": 1407374883553283, "start_id": 1688849860263937, "properties": {"name": "backup edge", "number": 1, "packages": [1, 3, 5, 7]}}::edge, {"id": 1407374883553283, "label": "middle", "properties": {}}::vertex, {"id": 2251799813685253, "label": "alternate_edge", "end_id": 1407374883553282, "start_id": 1407374883553283, "properties": {"name": "backup edge", "number": 2, "packages": [1, 3, 5, 7]}}::edge, {"id": 1407374883553282, "label": "middle", "properties": {}}::vertex, {"id": 2533274790395906, "label": "bypass_edge", "end_id": 844424930131969, "start_id": 1407374883553282, "properties": {"name": "bypass edge", "number": 2, "packages": [1, 3, 5, 7], "dangerous": {"type": "poisons", "level": "all"}}}::edge, {"id": 844424930131969, "label": "begin", "properties": {}}::vertex]::path
(1 row)

-- Each should return 3
SELECT * FROM cypher('cypher_vle', $$MATCH (u:begin)-[e*0..1]->(v) RETURN id(u), e, id(v) $$) AS (u agtype, e agtype, v agtype);
u | e | v
-----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------
844424930131969 | [] | 844424930131969
844424930131969 | [{"id": 2251799813685249, "label": "alternate_edge", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {"name": "alternate edge", "number": 1, "packages": [2, 4, 6], "dangerous": {"type": "poisons", "level": "all"}}}::edge] | 1407374883553281
844424930131969 | [{"id": 1125899906842628, "label": "edge", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {"name": "main edge", "number": 1, "dangerous": {"type": "all", "level": "all"}}}::edge] | 1407374883553281
(3 rows)

SELECT * FROM cypher('cypher_vle', $$MATCH p=(u:begin)-[e*0..1]->(v) RETURN p $$) AS (p agtype);
p
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[{"id": 844424930131969, "label": "begin", "properties": {}}::vertex]::path
[{"id": 844424930131969, "label": "begin", "properties": {}}::vertex, {"id": 2251799813685249, "label": "alternate_edge", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {"name": "alternate edge", "number": 1, "packages": [2, 4, 6], "dangerous": {"type": "poisons", "level": "all"}}}::edge, {"id": 1407374883553281, "label": "middle", "properties": {}}::vertex]::path
[{"id": 844424930131969, "label": "begin", "properties": {}}::vertex, {"id": 1125899906842628, "label": "edge", "end_id": 1407374883553281, "start_id": 844424930131969, "properties": {"name": "main edge", "number": 1, "dangerous": {"type": "all", "level": "all"}}}::edge, {"id": 1407374883553281, "label": "middle", "properties": {}}::vertex]::path
(3 rows)

-- Each should return 5
SELECT * FROM cypher('cypher_vle', $$MATCH (u)-[e*0..0]->(v) RETURN id(u), e, id(v) $$) AS (u agtype, e agtype, v agtype);
u | e | v
------------------+----+------------------
844424930131969 | [] | 844424930131969
1407374883553281 | [] | 1407374883553281
1407374883553282 | [] | 1407374883553282
1407374883553283 | [] | 1407374883553283
1688849860263937 | [] | 1688849860263937
(5 rows)

SELECT * FROM cypher('cypher_vle', $$MATCH p=(u)-[e*0..0]->(v) RETURN id(u), p, id(v) $$) AS (u agtype, p agtype, v agtype);
u | p | v
------------------+-------------------------------------------------------------------------------+------------------
844424930131969 | [{"id": 844424930131969, "label": "begin", "properties": {}}::vertex]::path | 844424930131969
1407374883553281 | [{"id": 1407374883553281, "label": "middle", "properties": {}}::vertex]::path | 1407374883553281
1407374883553282 | [{"id": 1407374883553282, "label": "middle", "properties": {}}::vertex]::path | 1407374883553282
1407374883553283 | [{"id": 1407374883553283, "label": "middle", "properties": {}}::vertex]::path | 1407374883553283
1688849860263937 | [{"id": 1688849860263937, "label": "end", "properties": {}}::vertex]::path | 1688849860263937
(5 rows)

--
-- Clean up
--
DROP TABLE start_and_end_points;
@@ -114,66 +114,59 @@ SELECT * FROM cypher('cypher_vle', $$MATCH p=()-[*]->(v) RETURN count(*) $$) AS
SELECT * FROM cypher('cypher_vle', $$MATCH p=(u:begin)-[*3..3]->(v:end) RETURN p $$) AS (e agtype);
-- Should find 12
SELECT * FROM cypher('cypher_vle', $$MATCH p=(u:begin)-[*3..3]-(v:end) RETURN p $$) AS (e agtype);
-- Should find 2
-- Each should find 2
SELECT * FROM cypher('cypher_vle', $$MATCH p=(u:begin)<-[*]-(v:end) RETURN p $$) AS (e agtype);
SELECT * FROM cypher('cypher_vle', $$MATCH p=(u:begin)<-[e*]-(v:end) RETURN p $$) AS (e agtype);
SELECT * FROM cypher('cypher_vle', $$MATCH p=(u:begin)<-[e*]-(v:end) RETURN e $$) AS (e agtype);
SELECT * FROM cypher('cypher_vle', $$MATCH p=(:begin)<-[*]-()<-[]-(:end) RETURN p $$) AS (e agtype);
-- Each should return 31
SELECT count(*) FROM cypher('cypher_vle', $$ MATCH ()-[e1]->(v)-[e2]->() RETURN e1,e2 $$) AS (e1 agtype, e2 agtype);

SELECT count(*) FROM cypher('cypher_vle', $$
MATCH ()-[e1*1..1]->(v)-[e2*1..1]->()
RETURN e1, e2
$$) AS (e1 agtype, e2 agtype);

SELECT count(*) FROM cypher('cypher_vle', $$
MATCH (v)-[e1*1..1]->()-[e2*1..1]->()
RETURN e1, e2
$$) AS (e1 agtype, e2 agtype);


SELECT count(*) FROM cypher('cypher_vle', $$
MATCH ()-[e1]->(v)-[e2*1..1]->()
RETURN e1, e2
$$) AS (e1 agtype, e2 agtype);

SELECT count(*) FROM cypher('cypher_vle', $$
MATCH ()-[e1]->()-[e2*1..1]->()
RETURN e1, e2
$$) AS (e1 agtype, e2 agtype);

SELECT count(*) FROM cypher('cypher_vle', $$
MATCH ()-[e1*1..1]->(v)-[e2]->()
RETURN e1, e2
$$) AS (e1 agtype, e2 agtype);

SELECT count(*) FROM cypher('cypher_vle', $$
MATCH ()-[e1*1..1]->()-[e2]->()
RETURN e1, e2
$$) AS (e1 agtype, e2 agtype);

SELECT count(*) FROM cypher('cypher_vle', $$
MATCH (a)-[e1]->(a)-[e2*1..1]->()
RETURN e1, e2
$$) AS (e1 agtype, e2 agtype);

SELECT count(*) FROM cypher('cypher_vle', $$
MATCH (a) MATCH (a)-[e1*1..1]->(v)
RETURN e1
$$) AS (e1 agtype);


SELECT count(*) FROM cypher('cypher_vle', $$
MATCH (a) MATCH ()-[e1*1..1]->(a)
RETURN e1
$$) AS (e1 agtype);


-- should return 1 path
-- Should return 1 path
SELECT * FROM cypher('cypher_vle', $$ MATCH p=()<-[e1*]-(:end)-[e2*]->(:begin) RETURN p $$) AS (result agtype);
-- Each should return 3
SELECT * FROM cypher('cypher_vle', $$MATCH (u:begin)-[e*0..1]->(v) RETURN id(u), e, id(v) $$) AS (u agtype, e agtype, v agtype);
SELECT * FROM cypher('cypher_vle', $$MATCH p=(u:begin)-[e*0..1]->(v) RETURN p $$) AS (p agtype);
-- Each should return 5
SELECT * FROM cypher('cypher_vle', $$MATCH (u)-[e*0..0]->(v) RETURN id(u), e, id(v) $$) AS (u agtype, e agtype, v agtype);
SELECT * FROM cypher('cypher_vle', $$MATCH p=(u)-[e*0..0]->(v) RETURN id(u), p, id(v) $$) AS (u agtype, p agtype, v agtype);


--
-- Clean up
--

@@ -2469,8 +2469,13 @@ static transform_entity *transform_VLE_edge_entity(cypher_parsestate *cpstate,
/* get the function */
func = (FuncCall*)rel->varlen;

/* it better be one of our functions */
Assert(list_length(func->funcname) == 1);
/* only our functions are supported here */
if (list_length(func->funcname) != 1)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("only AGE functions are supported here")));
}

/* set the pstate */
pstate = &cpstate->pstate;
@@ -3936,11 +3941,19 @@ transform_cypher_clause_as_subquery(cypher_parsestate *cpstate,
*/
if (list_length(pstate->p_rtable) > 1)
{
List *namespace;
int rtindex;
List *namespace = NULL;
int rtindex = 0;

/* get the index of the last entry */
rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtindex, pstate->p_rtable));

/* the rte at the end should be the rte just added */
if (rte != rt_fetch(rtindex, pstate->p_rtable))
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("rte must be last entry in p_rtable")));
}

namespace = list_make1(makeNamespaceItem(rte, true, true, false, true));

0 comments on commit e64df3b

Please sign in to comment.