Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id B3C4FB5DC00 for ; Wed, 19 Oct 2011 17:46:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 72442-01 for ; Wed, 19 Oct 2011 20:46:06 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id B086FB5DC04 for ; Wed, 19 Oct 2011 17:46:06 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p9JKjw7Y019519; Wed, 19 Oct 2011 16:45:58 -0400 (EDT) To: Merlin Moncure cc: Robert Haas , Bruce Momjian , depstein@alliedtesting.com, pgsql-bugs@postgresql.org, pgagarinov@alliedtesting.com, vshahov@alliedtesting.com Subject: Re: Can't use WITH in a PERFORM query in PL/pgSQL? In-reply-to: References: <29F36C7C98AB09499B1A209D48EAA615B501DA9401@mail2a.alliedtesting.com> <201109061743.p86HhQX16354@momjian.us> Comments: In-reply-to Merlin Moncure message dated "Wed, 19 Oct 2011 13:31:02 -0500" Date: Wed, 19 Oct 2011 16:45:58 -0400 Message-ID: <19518.1319057158@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/186 X-Sequence-Number: 31456 Merlin Moncure writes: > The point being, how do I convert any query to a non WITH variant so > it can be PERFORM'd? Anyways, I always thought having to do perform > at all was pretty weak sauce -- not sure why it's required. Possibly it was an Oracle compatibility thing ... anyone know PL/SQL well enough to say how this works there? I suppose you could argue that selecting a value and implicitly throwing it away is confusing to novices, but on the other hand I've seen a whole lot of novices confused by the need to write PERFORM instead of SELECT. I think it wouldn't be an unreasonable thing to just interpret a SELECT with no INTO clause as being a PERFORM (ie execute and discard results). Then we'd not have to do anything magic for commands starting with WITH. regards, tom lane