X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E0DD39DC813 for ; Mon, 13 Mar 2006 08:34:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30993-08 for ; Mon, 13 Mar 2006 08:34:25 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (unknown [212.211.145.186]) by postgresql.org (Postfix) with ESMTP id 47DDF9DC819 for ; Mon, 13 Mar 2006 08:34:20 -0400 (AST) Received: from kingfisher.intern.logix-tt.com (T85bc.t.pppool.de [89.55.133.188]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 936C5656D3; Mon, 13 Mar 2006 13:34:43 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id EABCB18148F55; Mon, 13 Mar 2006 13:34:23 +0100 (CET) Message-ID: <441566CF.2040105@logix-tt.com> Date: Mon, 13 Mar 2006 13:34:23 +0100 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: PostgreSQL SQL List Subject: Re: Set generating functions and subqueries References: <44116ED2.9060901@logix-tt.com> <5142.1142002128@sss.pgh.pa.us> In-Reply-To: <5142.1142002128@sss.pgh.pa.us> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.092 required=5 tests=[AWL=0.092] X-Spam-Score: 0.092 X-Spam-Level: X-Archive-Number: 200603/184 X-Sequence-Number: 24530 Hi, Tom, Tom Lane wrote: > The behavior of the subquery expression is dictated by the SQL spec: > > 1) If the cardinality of a or a 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