Re: Multiple unnests in query

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Aron Widforss <pgsql-general(at)antarkt(dot)is>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Multiple unnests in query
Date: 2017-11-13 01:51:01
Message-ID: 5065.1510537861@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Aron Widforss <pgsql-general(at)antarkt(dot)is> writes:
> Is this first query expected behavior? If so, what is the rationale?

The short answer is "because it's always worked that way". You
might find the last half of section 37.4.8 illuminating:

https://www.postgresql.org/docs/devel/static/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-SET

but if you're on a pre-v10 release, pay close attention to what it says
about the difference between v10 and pre-v10 behavior.

> I would have expected nine rows returned (as in my second example).

Your second example has approximately nothing to do with your first.
It has only one SRF in the SELECT list, so there's not much doubt
about what ought to happen.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2017-11-13 02:18:58 Re: Postgres 10.1 fails to start: server did not start in time
Previous Message Aron Widforss 2017-11-13 01:22:58 Multiple unnests in query