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
6 changes: 3 additions & 3 deletions regress/expected/expr.out
Original file line number Diff line number Diff line change
Expand Up @@ -8039,17 +8039,17 @@ SELECT * FROM cypher('list', $$ RETURN tail(["a","b","c","d","e"]) $$) AS (tail
["b", "c", "d", "e"]
(1 row)

-- should return null
-- should return an empty list
SELECT * FROM cypher('list', $$ RETURN tail([1]) $$) AS (tail agtype);
tail
------

[]
(1 row)

SELECT * FROM cypher('list', $$ RETURN tail([]) $$) AS (tail agtype);
tail
------

[]
(1 row)

-- should throw errors
Expand Down
2 changes: 1 addition & 1 deletion regress/sql/expr.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3269,7 +3269,7 @@ SELECT * from cypher('list', $$RETURN range(0, -10.0, -3.0)$$) as (range agtype)
-- should return the last elements of the list
SELECT * FROM cypher('list', $$ RETURN tail([1,2,3,4,5]) $$) AS (tail agtype);
SELECT * FROM cypher('list', $$ RETURN tail(["a","b","c","d","e"]) $$) AS (tail agtype);
-- should return null
-- should return an empty list
SELECT * FROM cypher('list', $$ RETURN tail([1]) $$) AS (tail agtype);
SELECT * FROM cypher('list', $$ RETURN tail([]) $$) AS (tail agtype);
-- should throw errors
Expand Down
10 changes: 5 additions & 5 deletions src/backend/utils/adt/agtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -6056,11 +6056,11 @@ Datum age_tail(PG_FUNCTION_ARGS)

count = AGT_ROOT_COUNT(agt_arg);

/* if we have an empty list or only one element in the list, return null */
if (count <= 1)
{
PG_RETURN_NULL();
}
/*
* For an empty or singleton list, tail() returns an empty list. The loop
* below already produces that result (i starts at 1 so nothing is pushed
* when count <= 1), so we do not special-case the count here.
*/

/* clear the result structure */
MemSet(&agis_result, 0, sizeof(agtype_in_state));
Expand Down
Loading