Re: BUG #8226: Inconsistent unnesting of arrays

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Denis de Bernardy <ddebernardy(at)yahoo(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8226: Inconsistent unnesting of arrays
Date: 2013-06-12 11:03:04
Message-ID: 20130612110304.GA20851@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message hubert depesz lubaczewski 2013-06-12 11:03:50 Re: BUG #8226: Inconsistent unnesting of arrays
Previous Message Pavel Stehule 2013-06-12 11:01:43 Re: BUG #8226: Inconsistent unnesting of arrays