I'm totally confused about what sql array indexing does and what the return types of indexing []
should be.
I have a 3,2 array:
select ARRAY[
[1,1],
[2,2],
[3,3]];
--> {{1,1},{2,2},{3,3}}
(BTW, pgadmin3 says this is an "array integer[]", not "array integer[][]").
Let's say I want to extract the first row (indexes start at 1 right?):
-- A
select (ARRAY[
[1,1],
[2,2],
[3,3]])[1];
--> NULL
Huh? Why not {1,1}
(of type int[]
).
-- B
select (ARRAY[
[1,1],
[2,2],
[3,3]])[1][:];
--> {{1,1}}
... seems legit. But:
-- C
select (ARRAY[
[1,1],
[2,2],
[3,3]])[1][:][1];
--> {}
why is this different to A?
And how can I extract a row from an int[][] (1d array) as an int[] (1d array).