Re: How to add function schema in search_path in option definitio

Поиск
Список
Период
Сортировка
От Peter J. Holzer
Тема Re: How to add function schema in search_path in option definitio
Дата
Msg-id 20230709110149.hdjv6vhukz2sz3c6@hjp.at
обсуждение исходный текст
Ответ на Re: How to add function schema in search_path in option definitio  (Lorusso Domenico <domenico.l76@gmail.com>)
Ответы Re: How to add function schema in search_path in option definitio  (Lorusso Domenico <domenico.l76@gmail.com>)
Список pgsql-general
On 2023-07-08 19:00:02 +0200, Lorusso Domenico wrote:
> I've created a schema to handle some specific features.
> In the schema there are a couple of tables used by many functions (more than
> 20).
> In other words, I've created a schema as a package (as suggested in many
> points).

So this is one specific schema with a specific name and you don't need
this to work in any schema the function happens to be created in?

Then I think setting the search path as part of the function definition
(as already hinted at by Adrian) may be the easiest solution:

create function my_schema.foo (...)
    returns ...
    set search_path to my_schema, public
    as $$
        ...
    $$;

You could also do something like:

set search_path to my_schema, public;
create function foo (...)
    returns ...
    set search_path from current
    as $$
        ...
    $$;

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Вложения

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: [Beginner Question]What's the use of ResTarget?
Следующее
От: jian he
Дата:
Сообщение: now() literal in pg_input_is_valid