bitnine-oss / agensgraph

AgensGraph, a transactional graph database based on PostgreSQL
http://www.agensgraph.org
Other
1.34k stars 148 forks source link

Query Crashes Server in `transformCypherMatchClause` #611

Open yype opened 1 year ago

yype commented 1 year ago

Hi there, I come across the following query that will crash the server. Tested on AG v2.13.1.

CREATE GRAPH network;
SET graph_path = network;
MATCH path_0 = (node_0{prop2:'LIT7'})-->(node_0:label2{prop6:TRUE}) DETACH DELETE node_0 , node_0 , node_0 , node_0 , node_0 SET node_0.prop6 = path_0;
MERGE (node_0{prop9:node_0.prop1}) ON MATCH SET node_0.prop8 = node_0, node_0.prop5 = node_0.prop4, node_0.prop9 = node_0.prop3 DETACH DELETE node_0 , node_0 , node_0 DETACH DELETE node_0 , node_0 , node_0 , node_0 WITH DISTINCT node_0.prop3 AS alias_0, node_0.prop1 AS alias_1, node_0.prop6 AS alias_2, node_0.prop7 AS alias_3 ORDER BY edge_1.prop8 SKIP 50 CREATE path_0 = (node_0:label6{}) MERGE (node_1:label9{})-[:reltype5]->(:label2{}) ON MATCH SET path_0.prop8 = NULL, node_1.prop1 = node_0.prop6;

GDB backtrace for the server:

Core was generated by `postgres: postgres postgres [local] CYPHER         '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000555555795c28 in transformCypherMatchClause ()
(gdb) bt
#0  0x0000555555795c28 in transformCypherMatchClause ()
#1  0x000055555574dcd7 in transformStmt ()
#2  0x000055555578eeb0 in transformClauseImpl ()
#3  0x000055555579295b in transformMergeMatch ()
#4  0x000055555578eeb0 in transformClauseImpl ()
#5  0x0000555555797fa5 in transformCypherMergeClause ()
#6  0x000055555574dc7d in transformStmt ()
#7  0x000055555578eeb0 in transformClauseImpl ()
#8  0x0000555555792b3e in transformDeleteEdges ()
#9  0x000055555578eeb0 in transformClauseImpl ()
#10 0x0000555555792e0e in transformDeleteJoin ()
#11 0x000055555578eeb0 in transformClauseImpl ()
#12 0x00005555557979df in transformCypherDeleteClause ()
#13 0x000055555574dc9b in transformStmt ()
#14 0x000055555578eeb0 in transformClauseImpl ()
#15 0x00005555557956f2 in transformCypherProjection ()
#16 0x000055555574dcc8 in transformStmt ()
#17 0x000055555578eeb0 in transformClauseImpl ()
#18 0x00005555557954f6 in transformCypherProjection ()
#19 0x000055555574dcc8 in transformStmt ()
#20 0x000055555578eeb0 in transformClauseImpl ()
#21 0x000055555579701d in transformCypherCreateClause ()
#22 0x000055555574dcaa in transformStmt ()
#23 0x000055555578eeb0 in transformClauseImpl ()
#24 0x00005555557928cd in transformMergeMatch ()
#25 0x000055555578eeb0 in transformClauseImpl ()
#26 0x0000555555797fa5 in transformCypherMergeClause ()
#27 0x000055555574dc7d in transformStmt ()
#28 0x000055555574d910 in transformStmt ()
#29 0x000055555574f071 in parse_analyze ()
#30 0x0000555555979399 in exec_simple_query ()
#31 0x000055555597b597 in PostgresMain ()
#32 0x0000555555909876 in ServerLoop ()
#33 0x000055555590a797 in PostmasterMain ()
#34 0x000055555568681c in main ()

Thanks.

yype commented 1 year ago

Another shorter crash sample:

CREATE GRAPH network;
SET graph_path = network;
CREATE (node_0{})--(:label7);
MATCH path_0 = (node_0{prop6:node_1.prop9}), path_1 = (node_1{}) WHERE node_1.prop5 < node_1.prop5 OR node_1.prop2 >= TRUE  MERGE (:label6);