mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
pg_upgrade: prevent automatic oid assignment
Prevent automatic oid assignment when in binary upgrade mode. Also throw an error when contrib/pg_upgrade_support functions are called when not in binary upgrade mode. This prevent automatically-assigned oids from conflicting with later pre-assigned oids coming from the old cluster. It also makes sure oids are preserved in call important cases.
This commit is contained in:
@ -38,12 +38,20 @@ PG_FUNCTION_INFO_V1(set_next_pg_authid_oid);
|
||||
|
||||
PG_FUNCTION_INFO_V1(create_empty_extension);
|
||||
|
||||
#define CHECK_IS_BINARY_UPGRADE \
|
||||
do { \
|
||||
if (!IsBinaryUpgrade) \
|
||||
ereport(ERROR, \
|
||||
(errcode(ERRCODE_CANT_CHANGE_RUNTIME_PARAM), \
|
||||
(errmsg("function can only be called when server is in binary upgrade mode")))); \
|
||||
} while (0)
|
||||
|
||||
Datum
|
||||
set_next_pg_type_oid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid typoid = PG_GETARG_OID(0);
|
||||
|
||||
CHECK_IS_BINARY_UPGRADE;
|
||||
binary_upgrade_next_pg_type_oid = typoid;
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@ -54,6 +62,7 @@ set_next_array_pg_type_oid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid typoid = PG_GETARG_OID(0);
|
||||
|
||||
CHECK_IS_BINARY_UPGRADE;
|
||||
binary_upgrade_next_array_pg_type_oid = typoid;
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@ -64,6 +73,7 @@ set_next_toast_pg_type_oid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid typoid = PG_GETARG_OID(0);
|
||||
|
||||
CHECK_IS_BINARY_UPGRADE;
|
||||
binary_upgrade_next_toast_pg_type_oid = typoid;
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@ -74,6 +84,7 @@ set_next_heap_pg_class_oid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid reloid = PG_GETARG_OID(0);
|
||||
|
||||
CHECK_IS_BINARY_UPGRADE;
|
||||
binary_upgrade_next_heap_pg_class_oid = reloid;
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@ -84,6 +95,7 @@ set_next_index_pg_class_oid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid reloid = PG_GETARG_OID(0);
|
||||
|
||||
CHECK_IS_BINARY_UPGRADE;
|
||||
binary_upgrade_next_index_pg_class_oid = reloid;
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@ -94,6 +106,7 @@ set_next_toast_pg_class_oid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid reloid = PG_GETARG_OID(0);
|
||||
|
||||
CHECK_IS_BINARY_UPGRADE;
|
||||
binary_upgrade_next_toast_pg_class_oid = reloid;
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@ -104,6 +117,7 @@ set_next_pg_enum_oid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid enumoid = PG_GETARG_OID(0);
|
||||
|
||||
CHECK_IS_BINARY_UPGRADE;
|
||||
binary_upgrade_next_pg_enum_oid = enumoid;
|
||||
|
||||
PG_RETURN_VOID();
|
||||
@ -114,6 +128,7 @@ set_next_pg_authid_oid(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Oid authoid = PG_GETARG_OID(0);
|
||||
|
||||
CHECK_IS_BINARY_UPGRADE;
|
||||
binary_upgrade_next_pg_authid_oid = authoid;
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
@ -129,6 +144,8 @@ create_empty_extension(PG_FUNCTION_ARGS)
|
||||
Datum extCondition;
|
||||
List *requiredExtensions;
|
||||
|
||||
CHECK_IS_BINARY_UPGRADE;
|
||||
|
||||
if (PG_ARGISNULL(4))
|
||||
extConfig = PointerGetDatum(NULL);
|
||||
else
|
||||
|
Reference in New Issue
Block a user