Skip to content
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
16 changes: 16 additions & 0 deletions regress/expected/cypher.out
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,22 @@ CREATE TABLE my_edges AS
-- create a table of 4 columns, u, e, v, p. should be 5 rows
CREATE TABLE my_detailed_paths AS
(SELECT * FROM cypher('issue_1767', $$ MATCH p=(u)-[e]->(v) RETURN u,e,v,p $$) as (u agtype, e agtype, v agtype, p agtype));
--
-- Issue 2256: A segmentation fault occurs when calling the coalesce function
-- This also occurs with the greatest function too.
--
SELECT * FROM coalesce(1, 0);
coalesce
----------
1
(1 row)

SELECT * FROM greatest(1, 0);
greatest
----------
1
(1 row)

-- dump out the tables
SELECT * FROM my_vertices;
u
Expand Down
7 changes: 7 additions & 0 deletions regress/sql/cypher.sql
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ CREATE TABLE my_edges AS
CREATE TABLE my_detailed_paths AS
(SELECT * FROM cypher('issue_1767', $$ MATCH p=(u)-[e]->(v) RETURN u,e,v,p $$) as (u agtype, e agtype, v agtype, p agtype));

--
-- Issue 2256: A segmentation fault occurs when calling the coalesce function
-- This also occurs with the greatest function too.
--
SELECT * FROM coalesce(1, 0);
SELECT * FROM greatest(1, 0);

-- dump out the tables
SELECT * FROM my_vertices;
SELECT * FROM my_edges;
Expand Down
26 changes: 19 additions & 7 deletions src/backend/parser/cypher_analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,20 @@ static bool convert_cypher_walker(Node *node, ParseState *pstate)
* JsonConstructorExpr - wrapper over FuncExpr/Aggref/WindowFunc for
* SQL/JSON constructors
*
* These are a special case that needs to be ignored.
* Added the following, although only the first 2 caused crashes in tests -
* CoalesceExpr, MinMaxExpr, CaseExpr, XmlExpr, ArrayExpr, RowExpr
*
* These are all special case that needs to be ignored.
*
*/
if (IsA(funcexpr, SQLValueFunction)
|| IsA(funcexpr, CoerceViaIO)
|| IsA(funcexpr, Var) || IsA(funcexpr, OpExpr)
|| IsA(funcexpr, Const) || IsA(funcexpr, BoolExpr)
|| IsA(funcexpr, JsonConstructorExpr))
|| IsA(funcexpr, CoerceViaIO)
|| IsA(funcexpr, Var) || IsA(funcexpr, OpExpr)
|| IsA(funcexpr, Const) || IsA(funcexpr, BoolExpr)
|| IsA(funcexpr, JsonConstructorExpr)
|| IsA(funcexpr, CoalesceExpr) || IsA(funcexpr, MinMaxExpr)
|| IsA(funcexpr, CaseExpr) || IsA(funcexpr, XmlExpr)
|| IsA(funcexpr, ArrayExpr) || IsA(funcexpr, RowExpr))
{
return false;
}
Expand Down Expand Up @@ -346,14 +352,20 @@ static bool is_func_cypher(FuncExpr *funcexpr)
* JsonConstructorExpr - wrapper over FuncExpr/Aggref/WindowFunc for
* SQL/JSON constructors
*
* These are a special case that needs to be ignored.
* Added the following, although only the first 2 caused crashes in tests -
* CoalesceExpr, MinMaxExpr, CaseExpr, XmlExpr, ArrayExpr, RowExpr
*
* These are all special case that needs to be ignored.
*
*/
if (IsA(funcexpr, SQLValueFunction)
|| IsA(funcexpr, CoerceViaIO)
|| IsA(funcexpr, Var) || IsA(funcexpr, OpExpr)
|| IsA(funcexpr, Const) || IsA(funcexpr, BoolExpr)
|| IsA(funcexpr, JsonConstructorExpr))
|| IsA(funcexpr, JsonConstructorExpr)
|| IsA(funcexpr, CoalesceExpr) || IsA(funcexpr, MinMaxExpr)
|| IsA(funcexpr, CaseExpr) || IsA(funcexpr, XmlExpr)
|| IsA(funcexpr, ArrayExpr) || IsA(funcexpr, RowExpr))
{
return false;
}
Expand Down