diff options
Diffstat (limited to 'contrib/pg_upgrade_support/pg_upgrade_support.c')
-rw-r--r-- | contrib/pg_upgrade_support/pg_upgrade_support.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/contrib/pg_upgrade_support/pg_upgrade_support.c b/contrib/pg_upgrade_support/pg_upgrade_support.c index edd41d06ae4..beaee7611df 100644 --- a/contrib/pg_upgrade_support/pg_upgrade_support.c +++ b/contrib/pg_upgrade_support/pg_upgrade_support.c @@ -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 |