pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Julien Rouhaud <rjuju123@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Avoid useless retrieval of defaults and check constraints in pg_dump -a
Date: Mon, 14 Sep 2020 22:56:01 -0400
Message-ID: <1234545.1600138561@sss.pgh.pa.us> (raw)
In-Reply-To: <20200915023320.GI2183@paquier.xyz>
References: <20200712054850.GA92357@nol>
	<20200712142921.GA26220@telsasoft.com>
	<CAOBaU_beGQEv6nJCQ-cDnHeC6hew-WaLjFyf-Snz_-rzATyGtQ@mail.gmail.com>
	<20200915023320.GI2183@paquier.xyz>

Michael Paquier <michael@paquier.xyz> writes:
> On Tue, Jul 14, 2020 at 11:14:50AM +0200, Julien Rouhaud wrote:
>> Note that those extraneous queries were found while trying to dump
>> data out of a corrupted database.  The issue wasn't an excessive
>> runtime but corrupted catalog entries, so bypassing this code (since I
>> was only interested in the data anyway) was simpler than trying to
>> recover yet other corrupted rows.

> Yeah, I don't see actually why this argument can prevent us from doing
> a micro optimization if it proves to work correctly.

The main thing I'm wondering about is whether not fetching these objects
could lead to failing to detect an important dependency chain.  IIRC,
pg_dump simply ignores pg_depend entries that mention objects it has not
loaded, so there is a possible mechanism for that.  However, it's hard to
see how a --data-only dump could end up choosing an invalid dump order on
that basis.  It doesn't seem like safe load orders for the table data
objects could depend on what is referenced by defaults or CHECK
constraints.

But ... I've only spent a few minutes thinking about it, so maybe
I'm missing something.

(Note that we disallow sub-queries in CHECK constraints, and also
disclaim responsibility for what happens if you cheat by hiding
the subquery in a function.  So while it's certainly possible to
build CHECK constraints that only work if table X is loaded before
table Y, pg_dump already doesn't guarantee that'll work, --data-only
or otherwise.)

			regards, tom lane





view thread (11+ messages)  latest in thread

Message-ID: <1234545.1600138561@sss.pgh.pa.us>
Permalink:  ../1234545.1600138561@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1234545.1600138561@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-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, michael@paquier.xyz, rjuju123@gmail.com, pryzby@telsasoft.com
  Subject: Re: Avoid useless retrieval of defaults and check constraints in pg_dump -a
  In-Reply-To: <1234545.1600138561@sss.pgh.pa.us>
  References: <20200712054850.GA92357@nol> <20200712142921.GA26220@telsasoft.com> <CAOBaU_beGQEv6nJCQ-cDnHeC6hew-WaLjFyf-Snz_-rzATyGtQ@mail.gmail.com> <20200915023320.GI2183@paquier.xyz> <1234545.1600138561@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