Re: BUG #8226: Inconsistent unnesting of arrays - Mailing list pgsql-bugs

From hubert depesz lubaczewski
Subject Re: BUG #8226: Inconsistent unnesting of arrays
Date
Msg-id 20130612110304.GA20851@depesz.com
Whole thread Raw
In response to Re: BUG #8226: Inconsistent unnesting of arrays  (Denis de Bernardy <ddebernardy@yahoo.com>)
List pgsql-bugs
On Wed, Jun 12, 2013 at 12:19:51PM +0200, Denis de Bernardy wrote:
> Methinks the behavior should be consistent. It should always do one
> (presumably like in the first statement) or the other (which leads to
> undefined behavior in the first statement).

It is consistent. You just assume it does something else than what it
does.

It reads values from both sources, until both of them will at the same
time.
If any of them ends earlier, it is scanned again from beginning.

This can be seen, for example, with:

select unnest('{a,b,c,d,e,f}'::text[]), unnest('{1,2,3}'::text[]);

Or, perhaps better, with this one:

select unnest('{a,b,c,d,e,f}'::text[]), unnest('{1,2,3,4}'::text[]);

It doesn't show 6 rows (as first array), or 4 (as the other). or 24 (6
* 4). It shows 12, because this is the smallest common multiple of 6 and
4.

depesz

pgsql-bugs by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: BUG #8226: Inconsistent unnesting of arrays
Next
From: hubert depesz lubaczewski
Date:
Subject: Re: BUG #8226: Inconsistent unnesting of arrays