pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ken Tanzer <ken.tanzer@gmail.com>
Cc: Rob Sargent <robjsargent@gmail.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Error with pg_dump (of data), with --role
Date: Fri, 19 Feb 2021 18:22:10 -0500
Message-ID: <3123724.1613776930@sss.pgh.pa.us> (raw)
In-Reply-To: <CAD3a31W-UfrDMeqqgYqPmeUqMcmKQKw7dX40um3Dm+VPe7KdVQ@mail.gmail.com>
References: <CAD3a31XywdXfeLeSH0NTptRR4iQyiC7CsO_kkMBF6qTNhGC5zw@mail.gmail.com>
	<296ae0e1-8f2c-fc11-d184-f98dba3d0cd5@gmail.com>
	<CAD3a31Xgm7_BQdmmA_KZ7KfcRBOeriHNvf215Ru5UQa1BtBQZA@mail.gmail.com>
	<2996155.1613709876@sss.pgh.pa.us>
	<CAD3a31W-UfrDMeqqgYqPmeUqMcmKQKw7dX40um3Dm+VPe7KdVQ@mail.gmail.com>

Ken Tanzer <ken.tanzer@gmail.com> writes:
> On Thu, Feb 18, 2021 at 8:44 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> There was a security change to pg_dump a few years ago to make it
>> put "set search_path = pg_catalog" into the dump script.  This
>> basically means that any user-defined function in indexes, check
>> constraints, etc is on its own to be sure that it schema-qualifies
>> non-system names, or has a "SET search_path" clause to do that
>> for it.

> Thank you Tom for that explanation.  To follow on, I tried adding:
> SET search_path = public;
> to the functions, but that prevents my function from working at all:

No, the way to do it is with a SET function property, like

create or replace function myfunc(...) returns ... language ...
  as $$body here$$
  SET search_path = whatever
  ... other function properties ...
;

That takes care of restoring the old value on the way out of the
function, so it's okay to use in an immutable function.

I think you can plaster this property onto an existing function
with ALTER FUNCTION, which should be less error-prone than
repeating the whole CREATE.

			regards, tom lane





view thread (10+ messages)  latest in thread

Message-ID: <3123724.1613776930@sss.pgh.pa.us>
Permalink:  ../3123724.1613776930@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3123724.1613776930@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ken.tanzer@gmail.com, robjsargent@gmail.com
  Subject: Re: Error with pg_dump (of data), with --role
  In-Reply-To: <3123724.1613776930@sss.pgh.pa.us>
  References: <CAD3a31XywdXfeLeSH0NTptRR4iQyiC7CsO_kkMBF6qTNhGC5zw@mail.gmail.com> <296ae0e1-8f2c-fc11-d184-f98dba3d0cd5@gmail.com> <CAD3a31Xgm7_BQdmmA_KZ7KfcRBOeriHNvf215Ru5UQa1BtBQZA@mail.gmail.com> <2996155.1613709876@sss.pgh.pa.us> <CAD3a31W-UfrDMeqqgYqPmeUqMcmKQKw7dX40um3Dm+VPe7KdVQ@mail.gmail.com> <3123724.1613776930@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox