Skip to content
Open
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
3 changes: 3 additions & 0 deletions regress/expected/cypher_vle.out
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ SELECT count(edges) FROM start_and_end_points, age_vle( '"cypher_vle"'::agtype,
1
(1 row)

-- Test the 8 argument form with a NULL VLE grammar node id - should error
SELECT count(edges) FROM start_and_end_points, age_vle( '"cypher_vle"'::agtype, start_vertex, end_vertex, '{"id": 1111111111111111, "label": "", "end_id": 2222222222222222, "start_id": 333333333333333, "properties": {}}::edge'::agtype, '1'::agtype, 'null'::agtype, '1'::agtype, NULL);
ERROR: age_vle: invalid NULL argument passed
-- Test the VLE match integration
-- Each should find 400
SELECT * FROM cypher('cypher_vle', $$MATCH (u:begin)-[*]->(v:end) RETURN count(*) $$) AS (e agtype);
Expand Down
13 changes: 13 additions & 0 deletions regress/expected/expr.out
Original file line number Diff line number Diff line change
Expand Up @@ -6698,6 +6698,19 @@ ERROR: function ag_catalog.age_stdevp() does not exist
LINE 1: SELECT * FROM cypher('UCSC', $$ RETURN stDevP() $$) AS (stDe...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
-- direct calls of the final functions with a NULL state - should return NULL
SELECT age_float8_stddev_samp_aggfinalfn(NULL);
age_float8_stddev_samp_aggfinalfn
-----------------------------------

(1 row)

SELECT age_float8_stddev_pop_aggfinalfn(NULL);
age_float8_stddev_pop_aggfinalfn
----------------------------------

(1 row)

--
-- aggregate functions percentileCont() & percentileDisc()
--
Expand Down
3 changes: 3 additions & 0 deletions regress/sql/cypher_vle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ SELECT count(edges) FROM start_and_end_points, age_vle( '"cypher_vle"'::agtype,
-- Test object property matching - should match 1
SELECT count(edges) FROM start_and_end_points, age_vle( '"cypher_vle"'::agtype, start_vertex, end_vertex, '{"id": 1111111111111111, "label": "", "end_id": 2222222222222222, "start_id": 333333333333333, "properties": {"dangerous": {"type": "poisons", "level": "all"}}}::edge'::agtype, '1'::agtype, 'null'::agtype, '0'::agtype);

-- Test the 8 argument form with a NULL VLE grammar node id - should error
SELECT count(edges) FROM start_and_end_points, age_vle( '"cypher_vle"'::agtype, start_vertex, end_vertex, '{"id": 1111111111111111, "label": "", "end_id": 2222222222222222, "start_id": 333333333333333, "properties": {}}::edge'::agtype, '1'::agtype, 'null'::agtype, '1'::agtype, NULL);

-- Test the VLE match integration
-- Each should find 400
SELECT * FROM cypher('cypher_vle', $$MATCH (u:begin)-[*]->(v:end) RETURN count(*) $$) AS (e agtype);
Expand Down
3 changes: 3 additions & 0 deletions regress/sql/expr.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2764,6 +2764,9 @@ SELECT * FROM cypher('UCSC', $$ RETURN stDevP(NULL) $$) AS (stDevP agtype);
-- should fail
SELECT * FROM cypher('UCSC', $$ RETURN stDev() $$) AS (stDev agtype);
SELECT * FROM cypher('UCSC', $$ RETURN stDevP() $$) AS (stDevP agtype);
-- direct calls of the final functions with a NULL state - should return NULL
SELECT age_float8_stddev_samp_aggfinalfn(NULL);
SELECT age_float8_stddev_pop_aggfinalfn(NULL);

--
-- aggregate functions percentileCont() & percentileDisc()
Expand Down
3 changes: 2 additions & 1 deletion src/backend/utils/adt/age_vle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,8 @@ Datum age_vle(PG_FUNCTION_ARGS)
/* all of these arguments need to be non NULL */
if (PG_ARGISNULL(0) || /* graph name */
PG_ARGISNULL(3) || /* edge prototype */
PG_ARGISNULL(6)) /* direction */
PG_ARGISNULL(6) || /* direction */
(PG_NARGS() == 8 && PG_ARGISNULL(7))) /* VLE grammar node id */
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
Expand Down
16 changes: 16 additions & 0 deletions src/backend/utils/adt/agtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -11525,6 +11525,16 @@ Datum age_float8_stddev_samp_aggfinalfn(PG_FUNCTION_ARGS)
PGFunction func;
agtype_value agtv_float;

/*
* The function is not STRICT, so it can be called directly with a NULL
* state. float8_stddev_samp does not check for that and would dereference
* it, so return NULL here, as a STRICT function would.
*/
if (PG_ARGISNULL(0))
{
PG_RETURN_NULL();
}

/* we can't use DirectFunctionCall1 as it errors for NULL values */
func = float8_stddev_samp;
result = (*func) (fcinfo);
Expand Down Expand Up @@ -11557,6 +11567,12 @@ Datum age_float8_stddev_pop_aggfinalfn(PG_FUNCTION_ARGS)
PGFunction func;
agtype_value agtv_float;

/* same as above, float8_stddev_pop does not check for a NULL state */
if (PG_ARGISNULL(0))
{
PG_RETURN_NULL();
}

/* we can't use DirectFunctionCall1 as it errors for NULL values */
func = float8_stddev_pop;
result = (*func) (fcinfo);
Expand Down
Loading