Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 93C04DDBC27 for ; Fri, 2 Dec 2011 02:21:40 -0400 (AST) Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RWMVA-00061x-6W for pgsql-bugs@postgresql.org; Fri, 02 Dec 2011 06:21:40 +0000 Received: from [204.145.120.229] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RWMUx-0002KF-OM for pgsql-bugs@postgresql.org; Fri, 02 Dec 2011 06:21:28 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1RWMUx-0007Gn-C9 for pgsql-bugs@postgresql.org; Fri, 02 Dec 2011 06:21:27 +0000 Date: Fri, 02 Dec 2011 06:21:27 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6316: function search_path causes set_config() is_local = true to have no effect To: pgsql-bugs@postgresql.org From: postgresql@thewickedtribe.net X-Pg-Spam-Score: -3.1 (---) X-Archive-Number: 201112/19 X-Sequence-Number: 31830 The following bug has been logged on the website: Bug reference: 6316 Logged by: Jon Erdman Email address: postgresql@thewickedtribe.net PostgreSQL version: 9.1.1 Operating system: Ubuntu Description: = Hi Tom! :) So, found this in 8.3 but tested and it effects everything up to 9.1.1. If search_path on a function is set to anything, calls to set_config() with is_local =3D true inside that function have no effect. = See test case and output below: BEGIN; CREATE OR REPLACE FUNCTION public.setting_bug_true() RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN PERFORM pg_catalog.set_config( 'search_path', 'pg_catalog&#= 39;, true ); END; $$ SET search_path =3D public ; CREATE OR REPLACE FUNCTION public.setting_bug_false() RETURNS VOID LANGUAGE plpgsql AS $$ BEGIN PERFORM pg_catalog.set_config( 'search_path', 'pg_catalog&#= 39;, false ); END; $$ SET search_path =3D public ; SET search_path =3D public; SHOW search_path; SELECT public.setting_bug_true(); \echo Search path should now be pg_catalog SHOW search_path; SET search_path =3D public; SHOW search_path; SELECT public.setting_bug_false(); \echo Oddly, if is_local is false, it *does* work SHOW search_path; ALTER FUNCTION public.setting_bug_true() SET search_path =3D DEFAULT; SET search_path =3D public; SHOW search_path; SELECT public.setting_bug_true(); \echo Take search_path off the function and it works!?! /me smells a bug... SHOW search_path; ROLLBACK; And the output: postgres@[local]/cnuapp_dev:5437=3D# \i ~/bug.sql BEGIN Time: 0.070 ms CREATE FUNCTION Time: 0.208 ms CREATE FUNCTION Time: 0.164 ms SET Time: 0.055 ms search_path ------------- public (1 row) Time: 0.025 ms setting_bug_true ------------------ (1 row) Time: 0.138 ms Search path should now be pg_catalog search_path ------------- public (1 row) Time: 0.022 ms SET Time: 0.019 ms search_path ------------- public (1 row) Time: 0.023 ms setting_bug_false ------------------- (1 row) Time: 0.085 ms Oddly, if is_local is false, it *does* work search_path ------------- pg_catalog (1 row) Time: 0.021 ms ALTER FUNCTION Time: 0.051 ms SET Time: 0.014 ms search_path ------------- public (1 row) Time: 0.018 ms setting_bug_true ------------------ (1 row) Time: 0.108 ms Take search_path off the function and it works!?! /me smells a bug... search_path ------------- pg_catalog (1 row) Time: 0.018 ms ROLLBACK Time: 0.050 ms postgres@[local]/cnuapp_dev:5437=3D#