pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: nicolas@cybercat.ca
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #10500: Cannot restore from a dump when some function is used in public shcema
Date: Mon, 02 Jun 2014 14:11:09 -0400
Message-ID: <17970.1401732669@sss.pgh.pa.us> (raw)
In-Reply-To: <20140602161427.2797.72238@wrigleys.postgresql.org>
References: <20140602161427.2797.72238@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

nicolas@cybercat.ca writes:
> I narrow it down to this simple exemple. Here's a pg_dump in plain text of
> my test case :

> CREATE SCHEMA intranet;
> CREATE EXTENSION IF NOT EXISTS unaccent WITH SCHEMA public;
> SET search_path = public, pg_catalog;
> CREATE FUNCTION cyunaccent(character varying) RETURNS character varying
>     LANGUAGE sql IMMUTABLE
>     AS $_$ SELECT unaccent(lower($1)); $_$;

This function is unsafe on its face: it does not specify what schema to
find unaccent() in.  You need to either explicitly schema-qualify:

     SELECT public.unaccent(lower($1));

(for good measure it'd be wise to qualify lower() as well), or else attach
a "SET search_path" clause to the function definition.

It's arguable whether the search path sensitivity of such functions is
a feature or a bug.  But there are people depending on the fact that they
can change the search path and get different results, so it's unlikely
we'd change the definition now.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (5+ messages)  latest in thread

Message-ID: <17970.1401732669@sss.pgh.pa.us>
Permalink:  ../17970.1401732669@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17970.1401732669@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, nicolas@cybercat.ca
  Subject: Re: BUG #10500: Cannot restore from a dump when some function is used in public shcema
  In-Reply-To: <17970.1401732669@sss.pgh.pa.us>
  References: <20140602161427.2797.72238@wrigleys.postgresql.org> <17970.1401732669@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox