mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
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.GE9812@tamriel.snowman.net
This commit is contained in:
@@ -730,7 +730,15 @@ main(int argc, char **argv)
|
||||
getTableDataFKConstraints();
|
||||
}
|
||||
|
||||
if (outputBlobs)
|
||||
/*
|
||||
* In binary-upgrade mode, we do not have to worry about the actual blob
|
||||
* data or the associated metadata that resides in the pg_largeobject and
|
||||
* pg_largeobject_metadata tables, respectivly.
|
||||
*
|
||||
* However, we do need to collect blob information as there may be
|
||||
* comments or other information on blobs that we do need to dump out.
|
||||
*/
|
||||
if (outputBlobs || binary_upgrade)
|
||||
getBlobs(fout);
|
||||
|
||||
/*
|
||||
@@ -799,6 +807,7 @@ main(int argc, char **argv)
|
||||
ropt->noTablespace = outputNoTablespaces;
|
||||
ropt->disable_triggers = disable_triggers;
|
||||
ropt->use_setsessauth = use_setsessauth;
|
||||
ropt->binary_upgrade = binary_upgrade;
|
||||
|
||||
if (compressLevel == -1)
|
||||
ropt->compression = 0;
|
||||
@@ -2423,8 +2432,14 @@ dumpBlob(Archive *fout, BlobInfo *binfo)
|
||||
NULL, binfo->rolname,
|
||||
binfo->dobj.catId, 0, binfo->dobj.dumpId);
|
||||
|
||||
/* Dump ACL if any */
|
||||
if (binfo->blobacl)
|
||||
/*
|
||||
* Dump ACL if any
|
||||
*
|
||||
* Do not dump the ACL in binary-upgrade mode, however, as the ACL will be
|
||||
* copied over by pg_upgrade as it is part of the pg_largeobject_metadata
|
||||
* table.
|
||||
*/
|
||||
if (binfo->blobacl && !binary_upgrade)
|
||||
dumpACL(fout, binfo->dobj.catId, binfo->dobj.dumpId, "LARGE OBJECT",
|
||||
binfo->dobj.name, NULL, cquery->data,
|
||||
NULL, binfo->rolname, binfo->blobacl);
|
||||
@@ -2449,6 +2464,13 @@ dumpBlobs(Archive *fout, void *arg)
|
||||
int i;
|
||||
int cnt;
|
||||
|
||||
/*
|
||||
* Do not dump out blob data in binary-upgrade mode, pg_upgrade will copy
|
||||
* the pg_largeobject table over entirely from the old cluster.
|
||||
*/
|
||||
if (binary_upgrade)
|
||||
return 1;
|
||||
|
||||
if (g_verbose)
|
||||
write_msg(NULL, "saving large objects\n");
|
||||
|
||||
@@ -7001,7 +7023,8 @@ dumpComment(Archive *fout, const char *target,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (schemaOnly)
|
||||
/* We do dump blob comments in binary-upgrade mode */
|
||||
if (schemaOnly && !binary_upgrade)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -11985,7 +12008,8 @@ dumpSecLabel(Archive *fout, const char *target,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (schemaOnly)
|
||||
/* We do dump blob security labels in binary-upgrade mode */
|
||||
if (schemaOnly && !binary_upgrade)
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user