pg_restore & search_path, COPY failed for table "mytable": ERROR: function myinnerfunction(integer) does not exist

Поиск
Список
Период
Сортировка
От Jean-Pierre Pelletier
Тема pg_restore & search_path, COPY failed for table "mytable": ERROR: function myinnerfunction(integer) does not exist
Дата
Msg-id 4c9fbd42cfdebef6726ce4a68baa51af@mail.gmail.com
обсуждение исходный текст
Ответы Re: pg_restore & search_path, COPY failed for table "mytable": ERROR: function myinnerfunction(integer) does not exist  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-hackers
Hi,

The following steps reproduce an error with pg_restore:

DROP TABLE IF EXISTS myTable;
DROP FUNCTION IF EXISTS myInnerFunction(INTEGER);
DROP FUNCTION IF EXISTS myOuterFunction(INTEGER);
DROP SCHEMA IF EXISTS myOtherSchema;

CREATE SCHEMA myOtherSchema;

SET search_path = myPrimarySchema, myOtherSchema, public;

CREATE OR REPLACE FUNCTION myOtherSchema.myInnerFunction(INTEGER) RETURNS
boolean   LANGUAGE sql IMMUTABLE STRICT   AS $$SELECT TRUE;
$$;

CREATE OR REPLACE FUNCTION myOuterFunction(INTEGER) RETURNS boolean   LANGUAGE sql IMMUTABLE STRICT   AS $$SELECT
myInnerFunction($1);
$$;

CREATE TABLE myTable( mycol INTEGER, CONSTRAINT MyConstraint CHECK (myOuterFunction(mycol))
);

INSERT INTO myTable VALUES (1);


Do a pg_dump of myTable.

Doing a pg_restore, throws:
COPY failed for table "mytable": ERROR:  function myinnerfunction(integer)
does not exist
LINE 2:  SELECT myInnerFunction($1);               ^
HINT:  No function matches the given name and argument types. You might
need to add explicit type casts.
QUERY:SELECT myInnerFunction($1);
CONTEXT:  SQL function "myouterfunction" during inlining


Using pg_dump plain on myTable shows that search_path is set to
myPrimarySchema, pg_catalog, so is missing myOtherSchema.

I'm puzzled as to how search_path should be used,.
Should all references be schema qualified inside functions body ?
Or is search_path safe except in the body of functions used in index or
constraints ?

That's with version 9.5.3 & 9.6 beta 3.

Thanks,
Jean-Pierre Pelletier



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Geoghegan
Дата:
Сообщение: Re: fixes for the Danish locale
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: fixes for the Danish locale