Re:Re: pg_dump without setting search_path

From: gzh <gzhcoder(at)126(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re:Re: pg_dump without setting search_path
Date: 2022-08-25 03:39:13
Message-ID: 7146ecd6.2920.182d3152247.Coremail.gzhcoder@126.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Tom,

Thank you for your prompt response.

When I use pg_dump to export schema from an older version of PostgreSQL 8.2.3 , it adds the following line at the beginning:

SET search_path = public, pg_catalog;

Is it possible set an option where pg_dump will add this line in PostgreSQL 12.5?

At 2022-08-25 11:07:46, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>gzh <gzhcoder(at)126(dot)com> writes:
>> When I use pg_dump to export schema from a database, it adds the following line at the beginning:
>> SELECT pg_catalog.set_config('search_path', '', false);
>> Is it possible set an option where pg_dump will not add this line?
>
>No. It's a security precaution.
>
>> It is causing issues later when I try to execute other SQL commands, without the schema qualifier.
>
>That probably means you have some user-defined functions that are
>not sufficiently careful about search_path. You want to either
>schema-qualify every reference in the function body, or attach a
>"SET search_path" clause to remove the function's context dependency.
>
>(If you're using SQL-language functions in v14 or later, another
>option is to use the SQL-standard syntax instead of writing the
>body as a string literal. Then the object references in the function
>are parsed at definition time.)
>
> regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-08-25 03:54:21 Re: pg_dump without setting search_path
Previous Message Tom Lane 2022-08-25 03:07:46 Re: pg_dump without setting search_path