pg_dump does not honor namespaces when functions are used in index - Mailing list pgsql-hackers

From Jean-Baptiste Quenot
Subject pg_dump does not honor namespaces when functions are used in index
Date
Msg-id AANLkTinLbpmO1YnK2i5k3lYS9BZWASl8Uiv81wH_P12A@mail.gmail.com
Whole thread Raw
Responses Re: pg_dump does not honor namespaces when functions are used in index  (Thom Brown <thombrown@gmail.com>)
List pgsql-hackers
Dear hackers,

I have a pretty nasty problem to submit to your careful scrutiny.

Please consider the following piece of SQL code:


CREATE SCHEMA bar;
SET search_path = bar;

CREATE FUNCTION bar() RETURNS text AS $$
BEGIN   RETURN 'foobar';
END
$$ LANGUAGE plpgsql IMMUTABLE;

CREATE SCHEMA foo;
SET search_path = foo;

CREATE FUNCTION foo() RETURNS text AS $$
BEGIN   RETURN bar();
END
$$ LANGUAGE plpgsql IMMUTABLE;

SET search_path = public;

CREATE TABLE foobar (d text);
insert into foobar (d) values ('foobar');

set search_path = public, foo, bar;
CREATE INDEX foobar_d on foobar using btree(foo());


Run this on a newly created database, and dump it with pg_dump. You'll
notice that the dump is unusable.  Creating a new database from this
dump will trigger the following error:

ERROR:  function bar() does not exist
LINE 1: SELECT bar()              ^
HINT:  No function matches the given name and argument types. You
might need to add explicit type casts.
QUERY:  SELECT bar()
CONTEXT:  PL/pgSQL function "foo" line 2 at RETURN

How can we fix this?
-- 
Jean-Baptiste Quenot


pgsql-hackers by date:

Previous
From: Felde Norbert
Date:
Subject: DB crash SOS
Next
From: Robert Haas
Date:
Subject: Re: Should the JSON datatype be a specialization of text?