From 96e953a7bed3a255373b3829195da2472d62e8db Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Mon, 19 Jun 2017 21:44:54 +0300 Subject: [PATCH] Fix bugs in pg_upgrade_support functions, for GPDB 5 -> GPDB 5 ugprade. These patches were written by Daniel Gustafsson, I just squashed and rebased them. * Add missing 5.0 object procedure declarations Commit 7ec831198a43bd98 implemented support for 5.0 objects in binary upgrade, but missed adding the procedure declarations to pg_upgrade due to a mismerge. * Fix opclass Oid preassignment function The function was erroneously pulling the wrong argument for the namespace Oid resulting in failed Oid lookups during synchronization. * Add support functions for pg_amop tuples --- contrib/pg_upgrade/function.c | 42 +++++++++++++++++++ .../pg_upgrade_support/pg_upgrade_support.c | 24 ++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/contrib/pg_upgrade/function.c b/contrib/pg_upgrade/function.c index f0f741ee58..8ee0aec36f 100644 --- a/contrib/pg_upgrade/function.c +++ b/contrib/pg_upgrade/function.c @@ -153,6 +153,48 @@ install_system_functions_internal(migratorContext *ctx, char *dbname) "RETURNS VOID " "AS '$libdir/pg_upgrade_support' " "LANGUAGE C STRICT;")); + PQclear(executeQueryOrDie(ctx, conn, + "CREATE OR REPLACE FUNCTION " + "binary_upgrade.preassign_tsparser_oid(OID, OID, TEXT) " + "RETURNS VOID " + "AS '$libdir/pg_upgrade_support' " + "LANGUAGE C STRICT;")); + PQclear(executeQueryOrDie(ctx, conn, + "CREATE OR REPLACE FUNCTION " + "binary_upgrade.preassign_tsdict_oid(OID, OID, TEXT) " + "RETURNS VOID " + "AS '$libdir/pg_upgrade_support' " + "LANGUAGE C STRICT;")); + PQclear(executeQueryOrDie(ctx, conn, + "CREATE OR REPLACE FUNCTION " + "binary_upgrade.preassign_tstemplate_oid(OID, OID, TEXT) " + "RETURNS VOID " + "AS '$libdir/pg_upgrade_support' " + "LANGUAGE C STRICT;")); + PQclear(executeQueryOrDie(ctx, conn, + "CREATE OR REPLACE FUNCTION " + "binary_upgrade.preassign_tsconfig_oid(OID, OID, TEXT) " + "RETURNS VOID " + "AS '$libdir/pg_upgrade_support' " + "LANGUAGE C STRICT;")); + PQclear(executeQueryOrDie(ctx, conn, + "CREATE OR REPLACE FUNCTION " + "binary_upgrade.preassign_extension_oid(OID, OID, TEXT) " + "RETURNS VOID " + "AS '$libdir/pg_upgrade_support' " + "LANGUAGE C STRICT;")); + PQclear(executeQueryOrDie(ctx, conn, + "CREATE OR REPLACE FUNCTION " + "binary_upgrade.preassign_enum_oid(OID, OID, TEXT) " + "RETURNS VOID " + "AS '$libdir/pg_upgrade_support' " + "LANGUAGE C STRICT;")); + PQclear(executeQueryOrDie(ctx, conn, + "CREATE OR REPLACE FUNCTION " + "binary_upgrade.preassign_amop_oid(OID, OID) " + "RETURNS VOID " + "AS '$libdir/pg_upgrade_support' " + "LANGUAGE C STRICT;")); PQfinish(conn); } diff --git a/contrib/pg_upgrade_support/pg_upgrade_support.c b/contrib/pg_upgrade_support/pg_upgrade_support.c index a60ee0e7e5..784bf40ec6 100644 --- a/contrib/pg_upgrade_support/pg_upgrade_support.c +++ b/contrib/pg_upgrade_support/pg_upgrade_support.c @@ -13,6 +13,7 @@ #include "fmgr.h" #include "catalog/dependency.h" #include "catalog/oid_dispatch.h" +#include "catalog/pg_amop.h" #include "catalog/pg_attrdef.h" #include "catalog/pg_authid.h" #include "catalog/pg_cast.h" @@ -86,6 +87,7 @@ Datum preassign_tstemplate_oid(PG_FUNCTION_ARGS); Datum preassign_tsconfig_oid(PG_FUNCTION_ARGS); Datum preassign_extension_oid(PG_FUNCTION_ARGS); Datum preassign_enum_oid(PG_FUNCTION_ARGS); +Datum preassign_amop_oid(PG_FUNCTION_ARGS); PG_FUNCTION_INFO_V1(preassign_type_oid); PG_FUNCTION_INFO_V1(preassign_arraytype_oid); @@ -114,6 +116,7 @@ PG_FUNCTION_INFO_V1(preassign_tstemplate_oid); PG_FUNCTION_INFO_V1(preassign_tsconfig_oid); PG_FUNCTION_INFO_V1(preassign_extension_oid); PG_FUNCTION_INFO_V1(preassign_enum_oid); +PG_FUNCTION_INFO_V1(preassign_amop_oid); Datum preassign_type_oid(PG_FUNCTION_ARGS) @@ -200,7 +203,7 @@ preassign_opclass_oid(PG_FUNCTION_ARGS) { Oid opcoid = PG_GETARG_OID(0); char *objname = GET_STR(PG_GETARG_TEXT_P(1)); - Oid opcnamespace = PG_GETARG_OID(1); + Oid opcnamespace = PG_GETARG_OID(2); if (Gp_role == GP_ROLE_UTILITY) { @@ -548,3 +551,22 @@ preassign_enum_oid(PG_FUNCTION_ARGS) PG_RETURN_VOID(); } + +Datum +preassign_amop_oid(PG_FUNCTION_ARGS) +{ + Oid amopoid = PG_GETARG_OID(0); + Oid amopmethod = PG_GETARG_OID(1); + + if (Gp_role == GP_ROLE_UTILITY) + { + AddPreassignedOidFromBinaryUpgrade(amopoid, + AccessMethodOperatorRelationId, + NULL, + InvalidOid, + amopmethod, + InvalidOid); + } + + PG_RETURN_VOID(); +} -- GitLab