Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id ED820B5D803 for ; Sat, 18 Jun 2011 17:31:03 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 82451-02 for ; Sat, 18 Jun 2011 20:30:53 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 414BAB5D801 for ; Sat, 18 Jun 2011 17:30:53 -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 p5IKUpPp024371; Sat, 18 Jun 2011 16:30:51 -0400 (EDT) To: "David Fetter" cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6067: In PL/pgsql, EXISTS(SELECT ... INTO...) fails In-reply-to: <201106172246.p5HMk2Qs041851@wwwmaster.postgresql.org> References: <201106172246.p5HMk2Qs041851@wwwmaster.postgresql.org> Comments: In-reply-to "David Fetter" message dated "Fri, 17 Jun 2011 22:46:02 +0000" Date: Sat, 18 Jun 2011 16:30:51 -0400 Message-ID: <24370.1308429051@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/164 X-Sequence-Number: 30543 "David Fetter" writes: > IF EXISTS (SELECT 1 INTO STRICT i) THEN > RAISE NOTICE '%', a; > END IF; Umm ... are you just complaining that the error message isn't very helpful, or are you actually expecting that to do something useful? If the latter, what exactly? I'm particularly confused by your use of the STRICT option here, because if we did support that, I would expect the STRICT to throw an error if there were not exactly one matching row, making the EXISTS test 100% pointless. But the short answer is that we don't support INTO in sub-selects, and in general I doubt that we ever will, since in most cases the behavior wouldn't be very well-defined. It might be worth a TODO to provide a better error message than "syntax error", though. regards, tom lane