Skip site navigation (1) Skip section navigation (2)

Re: BUG #4516: FOUND variable does not work after RETURN QUERY

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Andrew Gierth" <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: pgsql-bugs(at)postgresql(dot)org, "postgres hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: BUG #4516: FOUND variable does not work after RETURN QUERY
Date: 2008-11-13 11:00:58
Message-ID: 162867790811130300p47af523dq2857b8299db03436@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
I am sending patch, that adds FOUND and GET DIAGNOSTICS support for
RETURN QUERY statement

Regards
Pavel Stehule



2008/11/10 Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>:
>>>>>> "Pavel" == "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> writes:
>
>  >> Well, changing the semantics of an already-released statement
>  >> carries a risk of breaking existing apps that aren't expecting it
>  >> to change FOUND.  So I'd want to see a pretty strong case why this
>  >> is important --- not just that it didn't meet someone's
>  >> didn't-read-the-manual expectation.
>
>  Pavel> It's should do some problems, but I belive much less than
>  Pavel> change of casting or tsearch2 integration. And actually it's
>  Pavel> not ortogonal.  Every not dynamic statement change FOUND
>  Pavel> variable.
>
> Regardless of what you think of FOUND, a more serious problem is this:
>
> postgres=# create function test(n integer) returns setof integer language plpgsql
>  as $f$
>    declare
>      rc bigint;
>    begin
>      return query (select i from generate_series(1,n) i);
>      get diagnostics rc = row_count;
>      raise notice 'rc = %',rc;
>    end;
> $f$;
> CREATE FUNCTION
> postgres=# select test(3);
> NOTICE:  rc = 0
>  test
> ------
>    1
>    2
>    3
> (3 rows)
>
> Since GET DIAGNOSTICS is documented as working for every SQL query
> executed in the function, rather than for a specific list of
> constructs, this is clearly a bug.
>
> --
> Andrew (irc:RhodiumToad)
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

Attachment: returnquery.diff
Description: text/x-patch (3.4 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Pavel StehuleDate: 2008-11-13 11:26:47
Subject: Re: some strange bugs related to upgrade from 8.1 to 8.3
Previous:From: 崔岩ccuiyyanDate: 2008-11-13 10:55:11
Subject: Synchronization Primitives

pgsql-bugs by date

Next:From: chris woodDate: 2008-11-13 14:44:38
Subject: BUG #4528: (rounding?) error with some timezone names
Previous:From: Russell SmithDate: 2008-11-13 10:19:56
Subject: Re: Re: [BUGS] libpq does not manage SSL callbacks properly when other libraries are involved.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group