Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TuTZd-0000YO-8h for pgsql-bugs@arkaria.postgresql.org; Sun, 13 Jan 2013 19:50:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TuTZb-00079S-Vp for pgsql-bugs@arkaria.postgresql.org; Sun, 13 Jan 2013 19:50:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TuTZb-00079N-As for pgsql-bugs@postgresql.org; Sun, 13 Jan 2013 19:50:27 +0000 Received: from mail-ye0-f170.google.com ([209.85.213.170]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TuTZX-0004Wh-8j for pgsql-bugs@postgresql.org; Sun, 13 Jan 2013 19:50:26 +0000 Received: by mail-ye0-f170.google.com with SMTP id m12so582494yen.15 for ; Sun, 13 Jan 2013 11:50:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=/UDeGzZQhs+Zr2GeS4BrhQtic4Hwgvxw5c/vW5tGPYI=; b=iB4M5EVP+KxhJJ78ALzLaqn7MaLi/KgxGVUrRL4gQk9F+ha49QXmLyeByVUiVzU7Jc cDon9wttnR9yvsLF/s2Q/LeUqnX9mCyKCyOYX3KcZ2tv9FgYws+KYBK8PxwgXtdDjMP7 h2Md1hlNVdQVDuVx8lJU90yn9wUB+p75VDR+r3nXMlIuGLmlCchHtSkCzNeeVUu8ZaFE o0/QZ92T2P/JUmTnfCNW6a+SdBKaOBnYlCk5xqG906qXnMZ1lLzJ9lClPL4KAXVYca3k /Jgc7kZ99X/LTrsLNGKNIWVrAeplK5UE838jIw1AVjwd/jaicYAuqhJGlcLfPN/n88jp Kg6g== X-Received: by 10.236.193.37 with SMTP id j25mr80535831yhn.16.1358106621882; Sun, 13 Jan 2013 11:50:21 -0800 (PST) Received: from [187.64.145.228] ([187.64.145.228]) by mx.google.com with ESMTPS id h62sm10850924yhe.3.2013.01.13.11.50.18 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 13 Jan 2013 11:50:21 -0800 (PST) Message-ID: <50F30FF8.30504@gmail.com> Date: Sun, 13 Jan 2013 17:50:16 -0200 From: Rodrigo Rosenfeld Rosas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.11) Gecko/20121122 Icedove/10.0.11 MIME-Version: 1.0 To: Tom Lane CC: Andres Freund , Kevin Grittner , pgsql-bugs@postgresql.org Subject: Re: wrong search_path being used References: <20130112185917.255770@gmx.com> <21642.1358018978@sss.pgh.pa.us> <20130112193906.GC21523@awork2.anarazel.de> <22441.1358021631@sss.pgh.pa.us> In-Reply-To: <22441.1358021631@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) 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 Em 12-01-2013 18:13, Tom Lane escreveu: > Andres Freund writes: >> On 2013-01-12 14:29:38 -0500, Tom Lane wrote: >>> I think that the alternative most likely to succeed is to consider any >>> change in the active value of search_path as forcing replanning of >>> cached plans. >> I guess it wouldn't really be feasible to keep the search path used to >> plan a query in its cached form and check that it fits the one currently >> used on every use of the cached plan? > Actually that's exactly what I meant: every time we arrive at a query > with a cached plan, check to see if the active search_path value is the > same as what it was when we made the cached plan, and replan if not. > > There's already infrastructure to save the search_path value for a plan, > but what it's being used for right now is to restore the first-plan-time > value of the path when a replan is forced for some other reason. It > wouldn't be that hard to change it around to use it this way instead. > > regards, tom lane Something that would be really handy for applications using schemas for implementing multi-tenant support would be allowing usage of a function param in the SET section of the function. Something like this: CREATE FUNCTION some_function(p_schema, ...) RETURNS VOID AS $$ BEGIN ... END; $$ LANGUAGE plpgsql SET search_path = p_schema, public; Not sure what syntax to use since p_schema could be the name of some existent schema but you got the idea. This would avoid all the wrapper lines to save and restore the old search_path (specially when there are earlier returns in the function body). -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs