Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YBXFO-0007P2-E7 for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Jan 2015 23:21:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YBXFN-0006L0-1D for pgsql-bugs@arkaria.postgresql.org; Wed, 14 Jan 2015 23:21:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YBXFL-0006Kr-2O for pgsql-bugs@postgresql.org; Wed, 14 Jan 2015 23:21:07 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YBXFH-0003LF-Lg for pgsql-bugs@postgresql.org; Wed, 14 Jan 2015 23:21:05 +0000 MIME-Version: 1.0 Subject: BUG #12553: Altering search_path between function calls To: pgsql-bugs@postgresql.org From: rs@plusw.de Date: Wed, 14 Jan 2015 23:20:13 +0000 Message-ID: <20150114232013.2504.41170@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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 The following bug has been logged on the website: Bug reference: 12553 Logged by: Rolf Schaufelberger Email address: rs@plusw.de PostgreSQL version: 9.2.4 Operating system: Ubuntu 4.4.3-4ubuntu5.1 Description: Hello, given the following setup: create schema a; create table a.company (id integer primary key , name varchar (100) ); create table a.company_objects(id serial, company_id integer references a.company(id) , obj_class varchar(100)); create schema b; create table b.company (id integer primary key , name varchar (100) ); create table b.company_objects(id serial, company_id integer references b.company(id) , obj_class varchar(100)); create or replace function public.xxx( coid integer) returns integer as $$ DECLARE newid integer; BEGIN insert into company_objects(company_id, obj_class) values (coid, 'TEST') returning id into newid; return newid; END; $$ language plpgsql; set search_path to a; insert into company values (123,'A'); set search_path to b; insert into company values (987,'B'); set search_path to a, public; select xxx(123); set search_path to b, public; select xxx(987); drop schema a cascade; drop schema b cascade; drop function public.xxx(integer); and now executing gives : (sorry messages ar in German, but I think problem could be understood anyway) CREATE SCHEMA psql:/tmp/xxx.sql:2: HINWEIS: CREATE TABLE / PRIMARY KEY erstellt implizit einen Index »company_pkey« für Tabelle »company« CREATE TABLE psql:/tmp/xxx.sql:3: HINWEIS: CREATE TABLE erstellt implizit eine Sequenz »company_objects_id_seq« für die »serial«-Spalte »company_objects.id« CREATE TABLE CREATE SCHEMA psql:/tmp/xxx.sql:6: HINWEIS: CREATE TABLE / PRIMARY KEY erstellt implizit einen Index »company_pkey« für Tabelle »company« CREATE TABLE psql:/tmp/xxx.sql:7: HINWEIS: CREATE TABLE erstellt implizit eine Sequenz »company_objects_id_seq« für die »serial«-Spalte »company_objects.id« CREATE TABLE CREATE FUNCTION SET INSERT 0 1 SET INSERT 0 1 SET xxx ----- 1 (1 Zeile) SET psql:/tmp/xxx.sql:28: FEHLER: Einfügen oder Aktualisieren in Tabelle »company_objects« verletzt Fremdschlüssel-Constraint »company_objects_company_id_fkey« DETAIL: Schlüssel (company_id)=(987) ist nicht in Tabelle »company« vorhanden. KONTEXT: SQL-Anweisung »insert into company_objects(company_id, obj_class) values (coid, 'TEST') returning id« PL/pgSQL function xxx(integer) line 3 at SQL-Anweisung psql:/tmp/xxx.sql:31: HINWEIS: Löschvorgang löscht ebenfalls 2 weitere Objekte DETAIL: Löschvorgang löscht ebenfalls Tabelle a.company Löschvorgang löscht ebenfalls Tabelle a.company_objects DROP SCHEMA psql:/tmp/xxx.sql:32: HINWEIS: Löschvorgang löscht ebenfalls 2 weitere Objekte DETAIL: Löschvorgang löscht ebenfalls Tabelle company Löschvorgang löscht ebenfalls Tabelle company_objects DROP SCHEMA DROP FUNCTION =============== so , changing the search_path between two function calls within one session doesn't seem to work. Now , is this a bug or , if not, is this behaviour documented somewhere ? Thanks for your answer and many thanks for giving us PostgreSQL ! Rolf -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs