pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Popov <pavel.popov@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Backup/restore problem
Date: Tue, 29 Oct 2019 10:39:43 -0400
Message-ID: <13340.1572359983@sss.pgh.pa.us> (raw)
In-Reply-To: <CAC_LnDcSmwy6Zr6FCoTHEX_S=tcvXtrkXZA9PvzF_JKT1Oxohw@mail.gmail.com>
References: <CAC_LnDcSmwy6Zr6FCoTHEX_S=tcvXtrkXZA9PvzF_JKT1Oxohw@mail.gmail.com>

Pavel Popov <pavel.popov@gmail.com> writes:
> The problem occurs when we make backup of a db on server version 11 or 12
> and restore on the same server version. When we restore on server version
> 12 a backup made on server version 9.6 this problem DOES NOT occur.

I think it would happen if you tried to dump/restore with a *current* 9.6
release.  The problem looks to be that this function is not safe
against search_path changes:

> CREATE FUNCTION chk_f_part_pricetar(_customer integer, _pricetar integer)
> RETURNS boolean
>     LANGUAGE plpgsql
>     AS $$
> BEGIN
>   RETURN EXISTS(SELECT * FROM customers c JOIN nom.firms f ON c.invoiced_by = f.id
>                                           JOIN prices.pricetar t ON f.id = t.firm
>                 WHERE c.id = _customer AND t.id = _pricetar) OR _pricetar IS NULL;
> END;$$;

and recent releases of pg_dump insist on running the script with a
restrictive search_path for security reasons.

It might be enough to schema-qualify the function's reference to
"customers", although a safer solution would be to attach a
"SET search_path" clause to the function to enforce the search
path it's expecting.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <13340.1572359983@sss.pgh.pa.us>
Permalink:  ../13340.1572359983@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/13340.1572359983@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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pavel.popov@gmail.com
  Subject: Re: Backup/restore problem
  In-Reply-To: <13340.1572359983@sss.pgh.pa.us>
  References: <CAC_LnDcSmwy6Zr6FCoTHEX_S=tcvXtrkXZA9PvzF_JKT1Oxohw@mail.gmail.com> <13340.1572359983@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