From: | Arthur Bazin <arthurbazin(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | pg_dump/pg_restore and the magic of the search_path |
Date: | 2023-08-31 15:08:00 |
Message-ID: | CABjE6y3A-4NZEQLiy3tNM0VjVJcCOVHv0-pbWfp2RWycwfduuw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi everyone !
I have a good question on pg_dump/pg_restore and the search_path.
Consider that we have a function in the public schema witch is named
my_function_in_public.
In PG11 this table :
CREATE TABLE public.test_dump (
id TEXT DEFAULT my_function_in_public()
);
When you dump this table with the pg11 binaries, you obtain this script :
CREATE TABLE public.test_dump (
id TEXT DEFAULT public.my_function_in_public()
);
=> the schema prefix have been added to the function by pg_dump.
In PG13, the same table :
CREATE TABLE public.test_dump (
id TEXT DEFAULT my_function_in_public()
);
When you dump this table with the pg13 binaries, you obtain this script :
CREATE TABLE public.test_dump (
id TEXT DEFAULT my_function_in_public()
);
=> the schema prefix have not been added.
Ok I understand that there is some modifications on how the dump is
generated.
Now, if you try to restore the dump :
- PG11 to PG11 no problem
- PG11 (exported with dump from PG11) to PG13 : no problem
- PG11 (exported with dump from PG13) to PG13 : no problem
- PG13 to PG13 : no problem
=> But PG13 to PG11 : problem : the function is not find because it is not
prefixed. Seems legit.
What I don't understand is why PG13 to PG13 works ? If I look in this dump,
we can see the search path is set to '' (empty) and the function isn't
prefixed.
So how can it find where the function is ?
Does PG13 consider that when there is no prefix, we need to use "public" ?
Thank you for your lights on this.
Arthur Bazin
From | Date | Subject | |
---|---|---|---|
Next Message | Luca Ferrari | 2023-08-31 15:12:22 | Re: pg_visible_in_snapshot clarification |
Previous Message | Marc Millas | 2023-08-31 11:54:42 | Re: event trigger clarification |