postgresql - Accessing array-item from array of arrays -
so simple... need retrieve item of array-of-arrays, item must simple array. example:
with t (select '{{1,2,3},{333,444,555}}'::int[][] a, '{{{{1,2}}}}'::int[] b) select a[2], -- returns null (!), why not works? a[2:2], -- returns array-into-array, not simple array b[1][1], -- null b[1][1][1:2], -- ugly array-into-array-into...-array a[1][1] -- correct, works scalars t; the result null,{{333,444,555}},null,{{{{1,2}}}},1... need simple array a[2], {333,444,555}... how access it?
ps: guide , google-examples show slices... perhaps obvious not remember why a[2] invalid in postgresql.
i had forgotten discussed here: restricted form of "array of arrays"... named "multidimensional array"... persisted in thinking in ambiguous way, is, thinking in array of arrays...
the best answer comes tom lane @ pgsql-hackers.at.postgresql.org forum, "multi-dimensional arrays in postgres not 'arrays of arrays'".
so, in "multidimensional array" world, not exist kind of "access array-item" expected.
as @viníciusgobboa.deoliveira commented here, solution write function, through pl/sql (low performance) or c (high performance).
Comments
Post a Comment