pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Fetter <dfetter@vmware.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #6067: In PL/pgsql, EXISTS(SELECT ... INTO...) fails
Date: Fri, 17 Jun 2011 22:46:02 GMT
Message-ID: <201106172246.p5HMk2Qs041851@wwwmaster.postgresql.org> (raw)


The following bug has been logged online:

Bug reference:      6067
Logged by:          David Fetter
Email address:      dfetter@vmware.com
PostgreSQL version: 9.0.4
Operating system:   Linux
Description:        In PL/pgsql, EXISTS(SELECT ... INTO...) fails
Details: 

Here's some example code that reproduces the problem:

CREATE OR REPLACE FUNCTION foo()
RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
    i int;
BEGIN
    IF EXISTS (SELECT 1 INTO STRICT i) THEN
        RAISE NOTICE '%', a;
    END IF;
    RETURN;
END;
$$;
ERROR:  syntax error at or near "i"
LINE 8:     IF EXISTS (SELECT 1 INTO STRICT i) THEN
                                            ^

This came up in a case where there was an IF block that checked some
conditions before checking whether there was a row.  If it found a row, it
was supposed to use it in an EXCEPTION.  Instead, I had to do the query
unconditionally, check the FOUND block in a separate nested IF statement,
and generally uglify the code.

Not everybody in IRC agreed that this is a bug, though.



view thread (6+ messages)  latest in thread

Message-ID: <201106172246.p5HMk2Qs041851@wwwmaster.postgresql.org>
Permalink:  ../201106172246.p5HMk2Qs041851@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201106172246.p5HMk2Qs041851@wwwmaster.postgresql.org

 · 

reply

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: dfetter@vmware.com
  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>

* 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