(2010/02/04 17:30), KaiGai Kohei wrote: > (2010/02/04 0:20), Robert Haas wrote: >> 2010/2/1 KaiGai Kohei<kai...@ak.jp.nec.com>: >>> I again wonder whether we are on the right direction. >> >> I believe the proposed approach is to dump blob metadata if and only >> if you are also dumping blob contents, and to do all of this for data >> dumps but not schema dumps. That seems about right to me. > > In other words: > > <default> -> blob contents and metadata (owner, acl, comments) shall > be dumped > --data-only -> only blob contents shall be dumped > --schema-only -> neither blob contents and metadata are dumped. > > Can I understand correctly?
The attached patch enables not to dump "BLOB ITEM" section and corresponding metadata when --data-only is specified. In addition, it does not output both "BLOB DATA" and "BLOB ITEM" section when --schema-only is specified. When --data-only is given to pg_dump, it does not construct any DO_BLOB_ITEM entries in getBlobs(), so all the metadata (owner, acls, comment) are not dumped. And it writes legacy "BLOBS" section instead of the new "BLOB DATA" section to inform pg_restore this archive does not create large objects in "BLOB ITEM" section. If --schema-only is given, getBlobs() is simply skipped. When --data-only is given to pg_restore, it skips all the "BLOB ITEM" sections. Large objects are created in _LoadBlobs() instead of the section, like as we have done until now. The _LoadBlobs() takes the third argument which specifies whether we should create large object here, or not. Its condition is a bit modified from the previous patch. if (strcmp(te->desc, "BLOBS") == 0 || ropt->dataOnly) _LoadBlobs(AH, ropt, true); ^^^^^^^^^^^^^^^^^ else if (strcmp(te->desc, "BLOB DATA") == 0) _LoadBlobs(AH, ropt, false); When --data-only is given to pg_restore, "BLOB ITEM" secition is skipped, so we need to create large objects at _LoadBlobs() stage, even if the archive has "BLOB DATA" section. In addition, --schema-only kills all the "BLOB ITEM" section using a special condition that was added to _tocEntryRequired(). It might be a bit different from what Itagaki-san suggested, because "BLOB ITEM" section is still in SECTION_PRE_DATA section. However, it minimizes special treatments in the code, and no differences from the viewpoint of end-users. Or, is it necessary to pack them into SECTION_DATA section anyway? Thanks, -- OSS Platform Development Division, NEC KaiGai Kohei <kai...@ak.jp.nec.com>
pgsql-fix-pg_dump-blob-privs.4.patch
Description: application/octect-stream
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers