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
4 changes: 2 additions & 2 deletions regress/expected/expr.out
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,13 @@ $$RETURN [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10][-1..10]$$) AS r(c agtype);
SELECT agtype_access_slice('[0]'::agtype, 'null'::agtype, '1'::agtype);
agtype_access_slice
---------------------
[0]

(1 row)

SELECT agtype_access_slice('[0]'::agtype, '0'::agtype, 'null'::agtype);
agtype_access_slice
---------------------
[0]

(1 row)

-- should error - ERROR: slice must access a list
Expand Down
14 changes: 8 additions & 6 deletions src/backend/utils/adt/agtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -4324,11 +4324,14 @@ Datum agtype_access_slice(PG_FUNCTION_ARGS)
{
agt_lidx = AG_GET_ARG_AGTYPE_P(1);
lidx_value = get_ith_agtype_value_from_container(&agt_lidx->root, 0);
/* adjust for AGTV_NULL */
/*
* Under Cypher null-propagation semantics, list[a..b] is null when
* either bound is null. Return null directly instead of silently
* treating AGTV_NULL as an omitted bound.
*/
if (lidx_value->type == AGTV_NULL)
{
lower_index = 0;
lidx_value = NULL;
PG_RETURN_NULL();
}
}

Expand All @@ -4341,11 +4344,10 @@ Datum agtype_access_slice(PG_FUNCTION_ARGS)
{
agt_uidx = AG_GET_ARG_AGTYPE_P(2);
uidx_value = get_ith_agtype_value_from_container(&agt_uidx->root, 0);
/* adjust for AGTV_NULL */
/* Symmetric to the lower bound: null propagates to a null result. */
if (uidx_value->type == AGTV_NULL)
{
upper_index = array_size;
uidx_value = NULL;
PG_RETURN_NULL();
}
}

Expand Down
Loading