From: Markus Schaber <schabi@logix-tt.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL SQL List <pgsql-sql@postgresql.org>
Subject: Re: Set generating functions and subqueries
Date: Mon, 13 Mar 2006 13:34:23 +0100
Message-ID: <441566CF.2040105@logix-tt.com> (raw)
In-Reply-To: <5142.1142002128@sss.pgh.pa.us>
References: <44116ED2.9060901@logix-tt.com>
<5142.1142002128@sss.pgh.pa.us>
Hi, Tom,
Tom Lane wrote:
> The behavior of the subquery expression is dictated by the SQL spec:
>
> 1) If the cardinality of a <scalar subquery> or a <row subquery> is
> greater than 1, then an exception condition is raised: cardinal-
> ity violation.
That's interesting to know, and it seems to be a clean design.
> The fact that the other form is even allowed is more of a holdover from
> PostQUEL than something we have consciously decided is a good idea.
> (IMHO it's actually a fairly *bad* idea, because it does not work nicely
> when there's more than one SRF in the same targetlist.) It'll probably
> get phased out someday, if we can find a way to replace the
> functionality. I seem to recall speculating that SQL2003's LATERAL
> tables might do the job.
AFAICS, it can be replaced with JOINs:
select * FROM (SELECT 'othercol' AS other) as foo CROSS JOIN (SELECT
generate_series(1,2) as a) as fop CROSS JOIN (SELECT
generate_series(3,4) as b) AS foq;
other | a | b
----------+---+---
othercol | 1 | 3
othercol | 2 | 3
othercol | 1 | 4
othercol | 2 | 4
(4 rows)
> No kidding.
I wasn't kidding, I just wanted to point out the different behaviour
between equal-length and inequal-length sequences.
Thanks,
markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: schabi@logix-tt.com, tgl@sss.pgh.pa.us
Subject: Re: Set generating functions and subqueries
In-Reply-To: <441566CF.2040105@logix-tt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox