Re: strange evaluation Window function and SRF functions? - Mailing list pgsql-hackers

From Merlin Moncure
Subject Re: strange evaluation Window function and SRF functions?
Date
Msg-id CAHyXU0yaDvb5j7fVHbMB9GfK1KBEnY4jnqnbTQt--+8k5TZy1w@mail.gmail.com
Whole thread Raw
In response to Re: strange evaluation Window function and SRF functions?  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
On Mon, Jul 30, 2012 at 11:47 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>
>
> 2012/7/30 Thom Brown <thom@linux.com>
>>
>> On 30 July 2012 17:19, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>>>
>>> Hello
>>>
>>> I seen nice trick based on window function
>>> http://stackoverflow.com/questions/11700930/how-can-i-trim-a-text-array-in-postgresql
>>>
>>> but isn't it example of wrong evaluation? Result of row_number is not
>>> correct
>>
>>
>> Looks right to me.  I guess the way to get the row_number they're after
>> out of the result set would involve changing OVER () to OVER (ORDER BY
>> unnest(myTextArrayColumn))
>>
>
> it looks like row_number is evaluated before SRF - this behave is absolutely
> undefined - for me - more native behave is different evaluation.

If it was me, I'd have expanded the array with generate_series (as
with the undocumented information_schema._pg_expandarray) and stacked
the array with array() not array_agg().

merlin


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: [PATCH] Support for foreign keys with arrays
Next
From: Gabriele Bartolini
Date:
Subject: Re: [PATCH] Support for foreign keys with arrays