Re: proposal: row_to_array function - Mailing list pgsql-hackers

From Jim Nasby
Subject Re: proposal: row_to_array function
Date
Msg-id 54C81E77.5040108@BlueTreble.com
Whole thread Raw
In response to Re: proposal: row_to_array function  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: proposal: row_to_array function
List pgsql-hackers
On 1/27/15 12:58 PM, Pavel Stehule wrote:
>       postgres=# select array(select unnest('{{{1,2},{3,4}},{{5,6},{7,8}}}'::int[]));
>             array
>     -------------------
>       {1,2,3,4,5,6,7,8}
>     (1 row)
>
>     so it generate pairs {1,2}{3,4},{5,6},{7,8}
>
>
> I fixed situation when array has not enough elements.
>
> More tests, simple doc

Hrm, this wasn't what I was expecting:

+ select foreach_test_ab(array[1,2,3,4]);
+ NOTICE:  a: 1, b: 2
+ NOTICE:  a: 3, b: 4

I was expecting that foreach a,b array would be expecting something in the array to have a dimension of 2. :(

I think this is bad, because this:

foreach_test_ab('{{1,2,3},{4,5,6}}'::int[]);

will give you 1,2; 3,4; 5,6. I don't see any way that that makes sense. Even if it did make sense, I'm more concerned
thatadding this will seriously paint us into a corner when it comes to the (to me) more rational case of returning
{1,2,3},{4,5,6}.

I think we need to think some more about this, at least to make sure we're not painting ourselves into a corner for
moreappropriate array iteration.
 
-- 
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com



pgsql-hackers by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: jsonb, unicode escapes and escaped backslashes
Next
From: Tom Lane
Date:
Subject: Re: jsonb, unicode escapes and escaped backslashes