pg_dump -s -b

Started by Stephen Frostover 9 years ago3 messageshackers
Jump to latest
#1Stephen Frost
sfrost@snowman.net

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

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Stephen Frost (#1)
Re: pg_dump -s -b

Stephen Frost <sfrost@snowman.net> writes:

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.
----

Clearly, this is an oversimplification.

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.

IMO, blobs are data, so those behaviors are correct. The docs should
be fixed to match the code.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Stephen Frost
sfrost@snowman.net
In reply to: Tom Lane (#2)
Re: pg_dump -s -b

* Tom Lane (tgl@sss.pgh.pa.us) wrote:

IMO, blobs are data, so those behaviors are correct. The docs should
be fixed to match the code.

Works for me.

Thoughts on the attached?

Thanks!

Stephen

Attachments:

pg_dump_blobs_doc_fix.patchtext/x-diff; charset=us-asciiDownload+7-7