Re: Re: [COMMITTERS] pgsql: Adjust things so that the query_string of a cached plan and the - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Re: [COMMITTERS] pgsql: Adjust things so that the query_string of a cached plan and the
Date
Msg-id 7781.1231372693@sss.pgh.pa.us
Whole thread Raw
In response to Re: Re: [COMMITTERS] pgsql: Adjust things so that the query_string of a cached plan and the  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I wrote:
> The good thing about using debug_query_string is that "the current
> client query" is well-defined and easy to explain.  I'm worried
> whether using ActivePortal isn't likely to result in a rather
> implementation-dependent behavior that changes from release to release.

In fact, it *is* rather implementation-dependent.  Compare what you'll
get from these two functions:

create function plpgsqlf() returns text as '
begin return current_query();
end' language plpgsql;

create function plpgsqlf2() returns text as '
declare t text;
begin for t in select current_query() loop   return t; end loop;
end' language plpgsql;

My testing says that if we use ActivePortal then "select plpgsqlf()"
returns "select plpgsqlf()" but "select plpgsqlf2()" returns
" select current_query()", ie, the query associated with the implicit
plpgsql cursor.  I'm interested to know how you'll document that.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: reloptions and toast tables
Next
From: Alvaro Herrera
Date:
Subject: Re: Updates of SE-PostgreSQL 8.4devel patches (r1389)