pg_dump -s -b

From: Stephen Frost <sfrost(at)snowman(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: pg_dump -s -b
Date: 2016-11-19 17:08:35
Message-ID: 20161119170835.GZ13284@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

All,

While reviewing and considering the patch to add the --no-blobs option
to pg_dump, which I entirely agree with, I came across our claim that
passing -b to pg_dump would cause blobs to be output, regardless of
other options set.

To wit, our docs specifically say:

----
Include large objects in the dump. This is the default behavior except
when --schema, --table, or --schema-only is specified, so the -b switch
is only useful to add large objects to selective dumps.
----

However, a 'pg_dump -s -b' won't include blobs, which appears to be due
to the masking performed in _tocEntryRequired() whereby we strip the
REQ_DATA out if we are in schema-only mode.

Further, though perhaps less surprising, we don't include blobs when
--section=post-data is set, and only the definition of the blob (but no
data) when --section=pre-data is used.

This appears to go back at least as far as all currently supported
branches.

We have a few options here. The documentation says 'selective dumps',
which we could infer to mean 'dumps where the user specified a table' or
similar and exclude 'schema-only' from that case. I don't believe this
was the original intent, given this comment in pg_dump.c:

/*
* Dumping blobs is now default unless we saw an inclusion switch or -s
* ... but even if we did see one of these, -b turns it back on.
*/

Given the lack of field complaints about this, I'm pretty tempted to
just adjust that comment and the documentation. Alternativly, we could
hack things up in a simimlar manner to what was done in a7e5457, and
cause blobs to be dumped even in schema-only mode if -b is passed.

Thoughts?

Thanks!

Stephen

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-11-19 17:20:07 Re: pg_dump -s -b
Previous Message Tom Lane 2016-11-19 17:04:27 Re: Mail thread references in commits