mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
pg_upgrade: Preserve relfilenodes and tablespace OIDs.
Currently, database OIDs, relfilenodes, and tablespace OIDs can all change when a cluster is upgraded using pg_upgrade. It seems better to preserve them, because (1) it makes troubleshooting pg_upgrade easier, since you don't have to do a lot of work to match up files in the old and new clusters, (2) it allows 'rsync' to save bandwidth when used to re-sync a cluster after an upgrade, and (3) if we ever encrypt or sign blocks, we would likely want to use a nonce that depends on these values. This patch only arranges to preserve relfilenodes and tablespace OIDs. The task of preserving database OIDs is left for another patch, since it involves some complexities that don't exist in these cases. Database OIDs have a similar issue, but there are some tricky points in that case that do not apply to these cases, so that problem is left for another patch. Shruthi KC, based on an earlier patch from Antonin Houska, reviewed and with some adjustments by me. Discussion: http://postgr.es/m/CA+TgmoYgTwYcUmB=e8+hRHOFA0kkS6Kde85+UNdon6q7bt1niQ@mail.gmail.com
This commit is contained in:
@ -89,6 +89,7 @@ char *default_tablespace = NULL;
|
||||
char *temp_tablespaces = NULL;
|
||||
bool allow_in_place_tablespaces = false;
|
||||
|
||||
Oid binary_upgrade_next_pg_tablespace_oid = InvalidOid;
|
||||
|
||||
static void create_tablespace_directories(const char *location,
|
||||
const Oid tablespaceoid);
|
||||
@ -340,8 +341,20 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
|
||||
|
||||
MemSet(nulls, false, sizeof(nulls));
|
||||
|
||||
tablespaceoid = GetNewOidWithIndex(rel, TablespaceOidIndexId,
|
||||
Anum_pg_tablespace_oid);
|
||||
if (IsBinaryUpgrade)
|
||||
{
|
||||
/* Use binary-upgrade override for tablespace oid */
|
||||
if (!OidIsValid(binary_upgrade_next_pg_tablespace_oid))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("pg_tablespace OID value not set when in binary upgrade mode")));
|
||||
|
||||
tablespaceoid = binary_upgrade_next_pg_tablespace_oid;
|
||||
binary_upgrade_next_pg_tablespace_oid = InvalidOid;
|
||||
}
|
||||
else
|
||||
tablespaceoid = GetNewOidWithIndex(rel, TablespaceOidIndexId,
|
||||
Anum_pg_tablespace_oid);
|
||||
values[Anum_pg_tablespace_oid - 1] = ObjectIdGetDatum(tablespaceoid);
|
||||
values[Anum_pg_tablespace_spcname - 1] =
|
||||
DirectFunctionCall1(namein, CStringGetDatum(stmt->tablespacename));
|
||||
|
Reference in New Issue
Block a user