pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: wilma.wantren@web.de
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18249: pg_dump/pg_restore single schema with function1 calling function2
Date: Fri, 15 Dec 2023 14:03:43 +0100
Message-ID: <a5b6415b5d1f45e79600b8ad4d369fecd9c9f8d2.camel@cybertec.at> (raw)
In-Reply-To: <18249-630edb096ed98a50@postgresql.org>
References: <18249-630edb096ed98a50@postgresql.org>

On Fri, 2023-12-15 at 09:09 +0000, PG Bug reporting form wrote:
> [...] pg_dump/pg_restore [...]
> 
> But there is one problem: we have a database function function1, which calls
> another function function2. The call is made without a schema prefix because
> these are just two functions that we make available to the customers and we
> don't think an extra schema for these two functions is worthwhile. However,
> function1 is used in an index and the restore of the index fails if there is
> data in the corresponding table column. This is because pg_dump/pg_restore
> set the search_path to '' when restoring, which means that function1 cannot
> find the function2.
> Is there any way to solve this?

This is a bug, but not a PostgreSQL bug.  The bug is in your object definition.
Relying on "search_path" like that is a security risk, particularly in
functions used in an index definition.  If a privileged user inserts a value
in an environment where somebody else can manipulate "search_path", anything
can happen.

The best fix is to

  ALTER FUNCTION ... SET search_path = only, safe, schemas;

Yours,
Laurenz Albe





view thread (4+ messages)  latest in thread

Message-ID: <a5b6415b5d1f45e79600b8ad4d369fecd9c9f8d2.camel@cybertec.at>
Permalink:  ../a5b6415b5d1f45e79600b8ad4d369fecd9c9f8d2.camel@cybertec.at/
Also on:    postgresql.org/message-id/a5b6415b5d1f45e79600b8ad4d369fecd9c9f8d2.camel@cybertec.at

 · 

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-bugs@postgresql.org
  Cc: laurenz.albe@cybertec.at, wilma.wantren@web.de
  Subject: Re: BUG #18249: pg_dump/pg_restore single schema with function1 calling function2
  In-Reply-To: <a5b6415b5d1f45e79600b8ad4d369fecd9c9f8d2.camel@cybertec.at>
  References: <18249-630edb096ed98a50@postgresql.org> <a5b6415b5d1f45e79600b8ad4d369fecd9c9f8d2.camel@cybertec.at>

* 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