Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 3E29A1337B47 for ; Mon, 28 Feb 2011 10:09:58 -0400 (AST) 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 49633-06 for ; Mon, 28 Feb 2011 14:09:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 9339F1337B39 for ; Mon, 28 Feb 2011 10:09:57 -0400 (AST) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p1SE9vAJ050394 for ; Mon, 28 Feb 2011 14:09:57 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p1SE9vcS050393; Mon, 28 Feb 2011 14:09:57 GMT (envelope-from www) Date: Mon, 28 Feb 2011 14:09:57 GMT Message-Id: <201102281409.p1SE9vcS050393@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #5902: pl/pgsql plans are not invalidated on discard all From: "Ingmar Brouns" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201102/235 X-Sequence-Number: 29507 The following bug has been logged online: Bug reference: 5902 Logged by: Ingmar Brouns Email address: swingi@gmail.com PostgreSQL version: 9.0.3 Operating system: Fedora 13 Description: pl/pgsql plans are not invalidated on discard all Details: Hi, I ran into the pl/pgsql Plan Invalidation and search_path bug that is on the todo list http://wiki.postgresql.org/wiki/Todo#PL.2FpgSQL I was looking for a workaround to this problem, and figured that calling 'discard all', or 'discard plans' should do the trick. However, also after discard all, the plpgsql function seems to be executed with the old plan. Kind regards, Ingmar example code create schema a; create schema b; create table a.test_table(a integer); create table b.test_table(b integer); insert into a.test_table values(1); insert into b.test_table values(2); create or replace function public.foo() returns integer as $$ declare retval integer; begin select * into retval from test_table; return retval; end; $$ language plpgsql; set search_path to a,public; select public.foo(); set search_path to b,public; select public.foo(); --this is the todo as known --now lets discard the session state and try it again DISCARD ALL; DISCARD PLANS; set search_path to b,public; select public.foo(); output: CREATE SCHEMA CREATE SCHEMA CREATE TABLE CREATE TABLE INSERT 0 1 INSERT 0 1 CREATE FUNCTION SET foo ----- 1 (1 row) SET foo ----- 1 (1 row) DISCARD ALL SET foo ----- 1 --The output is still (1) instead of (2) (1 row) version ---------------------------------------------------------------------------- -------------------------------- PostgreSQL 9.0.3 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.4.4 20100630 (Red Hat 4.4.4-10), 32-bit