pg_upgrade: Fix large object COMMENTS, SECURITY LABELS
authorStephen Frost <[email protected]>
Mon, 6 Mar 2017 22:04:13 +0000 (17:04 -0500)
committerStephen Frost <[email protected]>
Mon, 6 Mar 2017 22:04:13 +0000 (17:04 -0500)
commit6be8647f7862dbbefe4d49d842566738cd753963
tree1b920fbb70de8071e44c5032ed7614281b92aa63
parent420d9ec0aebb0cd8d3198d25d6acaf07b0a576b9
pg_upgrade: Fix large object COMMENTS, SECURITY LABELS

When performing a pg_upgrade, we copy the files behind pg_largeobject
and pg_largeobject_metadata, allowing us to avoid having to dump out and
reload the actual data for large objects and their ACLs.

Unfortunately, that isn't all of the information which can be associated
with large objects.  Currently, we also support COMMENTs and SECURITY
LABELs with large objects and these were being silently dropped during a
pg_upgrade as pg_dump would skip everything having to do with a large
object and pg_upgrade only copied the tables mentioned to the new
cluster.

As the file copies happen after the catalog dump and reload, we can't
simply include the COMMENTs and SECURITY LABELs in pg_dump's binary-mode
output but we also have to include the actual large object definition as
well.  With the definition, comments, and security labels in the pg_dump
output and the file copies performed by pg_upgrade, all of the data and
metadata associated with large objects is able to be successfully pulled
forward across a pg_upgrade.

In 9.6 and master, we can simply adjust the dump bitmask to indicate
which components we don't want.  In 9.5 and earlier, we have to put
explciit checks in in dumpBlob() and dumpBlobs() to not include the ACL
or the data when in binary-upgrade mode.

Adjustments made to the privileges regression test to allow another test
(large_object.sql) to be added which explicitly leaves a large object
with a comment in place to provide coverage of that case with
pg_upgrade.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/20170221162655[email protected]
src/bin/pg_dump/pg_backup.h
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_dump.c
src/test/regress/expected/large_object.out [new file with mode: 0644]
src/test/regress/expected/privileges.out
src/test/regress/parallel_schedule
src/test/regress/serial_schedule
src/test/regress/sql/large_object.sql [new file with mode: 0644]
src/test/regress/sql/privileges.sql