jihot2000 opened a new issue, #222:
URL: https://github.com/apache/incubator-age/issues/222
**Description**
I described a bug in issue #220. But it makes one confused because I cannot
prove that the logic of ```show_list_use_loop``` is the same as
```show_list_use_vle```.
So I rewrite my test case to make the question clear.
**How are you accessing AGE (Command line, driver, etc.)?**
run a sql file using psql command line
**the sql file 1**
```sql
CREATE SCHEMA test_vle;
SET search_path = test_vle, ag_catalog, "$user";
SELECT create_graph('mygraph');
SELECT create_vlabel('mygraph', 'head');
SELECT create_vlabel('mygraph', 'tail');
SELECT create_vlabel('mygraph', 'node');
SELECT create_elabel('mygraph', 'next');
SELECT * FROM cypher('mygraph', $CYPHER$
MERGE (:head {name: "list01"})-[:next]->(:tail {name: "list01"})
$CYPHER$) AS (a agtype);
SELECT * FROM cypher('mygraph', $CYPHER$
MATCH (h:head {name: "list01"})-[e:next]->(v)
DELETE e
CREATE (h)-[:next]->(:node {content: "a"})-[:next]->(v)
$CYPHER$) AS (a agtype);
SELECT * FROM cypher('mygraph', $CYPHER$
MATCH (h:head {name: 'list01'})-[:next*]->(v:node)
RETURN v
$CYPHER$) AS (node agtype);
SELECT * FROM cypher('mygraph', $CYPHER$
MATCH (h:head {name: "list01"})-[e:next]->(v)
DELETE e
CREATE (h)-[:next]->(:node {content: "b"})-[:next]->(v)
$CYPHER$) AS (a agtype);
SELECT * FROM cypher('mygraph', $CYPHER$
MATCH (h:head {name: 'list01'})-[:next*]->(v:node)
RETURN v
$CYPHER$) AS (node agtype);
SELECT * FROM cypher('mygraph', $CYPHER$
MATCH p=(:head)-[:next]->(:node)-[:next]->(:node)-[:next]->(:tail)
RETURN p
$CYPHER$) AS (path agtype);
SELECT drop_graph('mygraph', true);
DROP SCHEMA test_vle CASCADE;
```
Its output is
```
a
---
(0 rows)
a
---
(0 rows)
node
-----------------------------------------------------------------------------------
{"id": 1407374883553281, "label": "node", "properties": {"content":
"a"}}::vertex
(1 row)
a
---
(0 rows)
node
-----------------------------------------------------------------------------------
{"id": 1407374883553281, "label": "node", "properties": {"content":
"a"}}::vertex
{"id": 1407374883553282, "label": "node", "properties": {"content":
"b"}}::vertex
(2 rows)
path
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[{"id": 844424930131969, "label": "head", "properties": {"name":
"list01"}}::vertex, {"id": 1688849860263941, "label": "next", "end_id":
1407374883553282, "start_id": 844424930131969, "properties": {}}::edge, {"id":
1407374883553282, "label": "node", "properties": {"content": "b"}}::vertex,
{"id": 1688849860263940, "label": "next", "end_id": 1407374883553281,
"start_id": 1407374883553282, "properties": {}}::edge, {"id": 1407374883553281,
"label": "node", "properties": {"content": "a"}}::vertex, {"id":
1688849860263938, "label": "next", "end_id": 1125899906842625, "start_id":
1407374883553281, "properties": {}}::edge, {"id": 1125899906842625, "label":
"tail", "properties": {"name": "list01"}}::vertex]::path
(1 row)
```
**the sql file 2**
```sql
CREATE SCHEMA test_vle;
SET search_path = test_vle, ag_catalog, "$user";
SELECT create_graph('mygraph');
SELECT create_vlabel('mygraph', 'head');
SELECT create_vlabel('mygraph', 'tail');
SELECT create_vlabel('mygraph', 'node');
SELECT create_elabel('mygraph', 'next');
CREATE OR REPLACE FUNCTION show_list_use_vle()
RETURNS TABLE(node agtype)
LANGUAGE 'plpgsql'
AS $$
DECLARE
BEGIN
RETURN QUERY
SELECT * FROM cypher('mygraph', $CYPHER$
MATCH (h:head {name: "list01"})-[:next*]->(v:node)
RETURN v
$CYPHER$) AS (node agtype);
END $$;
SELECT * FROM cypher('mygraph', $CYPHER$
MERGE (:head {name: "list01"})-[:next]->(:tail {name: "list01"})
$CYPHER$) AS (a agtype);
SELECT * FROM cypher('mygraph', $CYPHER$
MATCH (h:head {name: "list01"})-[e:next]->(v)
DELETE e
CREATE (h)-[:next]->(:node {content: "a"})-[:next]->(v)
$CYPHER$) AS (a agtype);
SELECT * FROM show_list_use_vle();
SELECT * FROM cypher('mygraph', $CYPHER$
MATCH (h:head {name: "list01"})-[e:next]->(v)
DELETE e
CREATE (h)-[:next]->(:node {content: "b"})-[:next]->(v)
$CYPHER$) AS (a agtype);
SELECT * FROM show_list_use_vle();
SELECT * FROM cypher('mygraph', $CYPHER$
MATCH p=(:head)-[:next]->(:node)-[:next]->(:node)-[:next]->(:tail)
RETURN p
$CYPHER$) AS (path agtype);
SELECT drop_graph('mygraph', true);
DROP SCHEMA test_vle CASCADE;
```
Its output is
```
a
---
(0 rows)
a
---
(0 rows)
node
-----------------------------------------------------------------------------------
{"id": 1407374883553281, "label": "node", "properties": {"content":
"a"}}::vertex
(1 row)
a
---
(0 rows)
node
-----------------------------------------------------------------------------------
{"id": 1407374883553281, "label": "node", "properties": {"content":
"a"}}::vertex
(1 row)
path
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[{"id": 844424930131969, "label": "head", "properties": {"name":
"list01"}}::vertex, {"id": 1688849860263941, "label": "next", "end_id":
1407374883553282, "start_id": 844424930131969, "properties": {}}::edge, {"id":
1407374883553282, "label": "node", "properties": {"content": "b"}}::vertex,
{"id": 1688849860263940, "label": "next", "end_id": 1407374883553281,
"start_id": 1407374883553282, "properties": {}}::edge, {"id": 1407374883553281,
"label": "node", "properties": {"content": "a"}}::vertex, {"id":
1688849860263938, "label": "next", "end_id": 1125899906842625, "start_id":
1407374883553281, "properties": {}}::edge, {"id": 1125899906842625, "label":
"tail", "properties": {"name": "list01"}}::vertex]::path
(1 row)
```
**My questions**
1. The difference between sql file 1 and sql file 2 is that sql file 1
queries the list directly using a VLE cypher statement, but sql file 2 queries
the list using a function with the VLE cypher statement inside. However, the
outputs of them are different after prepending the node 'b'. Sql file 1 printed
both 'a' and 'b'. But sql file 2 printed only 'a'. Why are they different?
2. Assume that the output of sql file 1 is correct. The path printed proves
that the path is (head)->(b)->(a)->(tail). But the the VLE cypher statement
first printed 'a' then printed 'b'. Is it the expected behaviour of the VLE
that return the results not as the path order?
**Environment (please complete the following information):**
PostgreSQL 11 and AGE commit id 95ca659
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]