Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tu6Ie-0004ec-Tz for pgsql-bugs@arkaria.postgresql.org; Sat, 12 Jan 2013 18:59:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tu6Id-0001X6-Rm for pgsql-bugs@arkaria.postgresql.org; Sat, 12 Jan 2013 18:59:23 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tu6Id-0001X0-1r for pgsql-bugs@postgresql.org; Sat, 12 Jan 2013 18:59:23 +0000 Received: from mout.gmx.net ([74.208.4.200]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tu6Ia-0007Yh-DF for pgsql-bugs@postgresql.org; Sat, 12 Jan 2013 18:59:22 +0000 Received: from mailout-us.gmx.com ([172.19.198.45]) by mrigmx.server.lan (mrigmxus001) with ESMTP (Nemesis) id 0MPV5x-1TpPTL2wHR-004hXg for ; Sat, 12 Jan 2013 19:59:18 +0100 Received: (qmail 16937 invoked by uid 0); 12 Jan 2013 18:59:18 -0000 Received: from 76.255.19.161 by rms-us015 with HTTP Cc: pgsql-bugs@postgresql.org Content-Type: text/plain; charset="utf-8" Date: Sat, 12 Jan 2013 13:59:17 -0500 From: "Kevin Grittner" Message-ID: <20130112185917.255770@gmx.com> MIME-Version: 1.0 Subject: Re: wrong search_path being used To: "Rodrigo Rosenfeld Rosas" X-Authenticated: #138763884 X-Flags: 0001 X-Mailer: GMX.com Web Mailer x-registered: 0 Content-Transfer-Encoding: 8bit X-GMX-UID: 0teDcI0C3zOlOQ09Lnwh+9F+IGRvb8Dv X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Rodrigo Rosenfeld Rosas wrote: > I'm curious though. Why wouldn't this behavior be considered a > bug? Is there any link to previous discussions about this subject > that I could read? A plpgsql function generates a plan on initial execution which chooses which particular tables are used. On subsequent executions that saves the overhead of parsing out the statement and looking up the table and its details, which can help performance quite a bit. If you want to have source code evaluated each time the function is called, you should use the EXECUTE statement within your function body, which will force parsing and path resolution of the statement for each execution. That should give you the behavior you want, with some cost in performance. To try to get your function code to work as you expect, the language would essentially need to identify which statements could be pre-planned, and which would needed to be treated as raw source on each execution. That would be tricky to implement, and would itself have some run-time cost. At this point we've put the burden on the programmer to identify this at the time the code is written, rather than adding run-time expense. -Kevin -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs