By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
select arr[array_lower(arr,1)+1:array_upper(arr,1)-1] as ok1
, trim_array(arr[array_lower(arr,1)+1:],1) as ok2
, arr[2:] as wrong1
, arr[2:3] as wrong2
, arr[2:array_length(arr,1)-1] as wrong3
, arr[2:-2] as wrong4
, (arr[2:])[:-2] as wrong5
from (SELECT '[50:53]={50,51,52,53}'::int[]) as your(arr);
ok1 | ok2 | wrong1 | wrong2 | wrong3 | wrong4 | wrong5 |
---|---|---|---|---|---|---|
{51,52} | {51,52} | {50,51,52,53} | {} | {} | {} | {} |
SELECT 1
select ('[-5:-3]={a,b,c}'::char[])[-4] as minus_fourth;
minus_fourth |
---|
b |
SELECT 1