summaryrefslogtreecommitdiff
path: root/contrib/pg_upgrade/function.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2015-03-10 22:33:25 -0400
committerPeter Eisentraut <peter_e@gmx.net>2015-04-14 19:26:37 -0400
commit30982be4e5019684e1772dd9170aaa53f5a8e894 (patch)
treeee83c2fa412fb58cfb12c0a74211fb76b8b5eed7 /contrib/pg_upgrade/function.c
parent936546dcbc24ad1f2b3d33e73aa5c5fde4d2be84 (diff)
downloadpostgresql-30982be4e5019684e1772dd9170aaa53f5a8e894.tar.gz
Integrate pg_upgrade_support module into backend
Previously, these functions were created in a schema "binary_upgrade", which was deleted after pg_upgrade was finished. Because we don't want to keep that schema around permanently, move them to pg_catalog but rename them with a binary_upgrade_... prefix. The provided functions are only small wrappers around global variables that were added specifically for pg_upgrade use, so keeping the module separate does not create any modularity. The functions still check that they are only called in binary upgrade mode, so it is not possible to call these during normal operation. Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
Diffstat (limited to 'contrib/pg_upgrade/function.c')
-rw-r--r--contrib/pg_upgrade/function.c113
1 files changed, 0 insertions, 113 deletions
diff --git a/contrib/pg_upgrade/function.c b/contrib/pg_upgrade/function.c
index deffe04647..d8009d195d 100644
--- a/contrib/pg_upgrade/function.c
+++ b/contrib/pg_upgrade/function.c
@@ -13,112 +13,6 @@
#include "access/transam.h"
-#define PG_UPGRADE_SUPPORT "$libdir/pg_upgrade_support"
-
-/*
- * install_support_functions_in_new_db()
- *
- * pg_upgrade requires some support functions that enable it to modify
- * backend behavior.
- */
-void
-install_support_functions_in_new_db(const char *db_name)
-{
- PGconn *conn = connectToServer(&new_cluster, db_name);
-
- /* suppress NOTICE of dropped objects */
- PQclear(executeQueryOrDie(conn,
- "SET client_min_messages = warning;"));
- PQclear(executeQueryOrDie(conn,
- "DROP SCHEMA IF EXISTS binary_upgrade CASCADE;"));
- PQclear(executeQueryOrDie(conn,
- "RESET client_min_messages;"));
-
- PQclear(executeQueryOrDie(conn,
- "CREATE SCHEMA binary_upgrade;"));
-
- PQclear(executeQueryOrDie(conn,
- "CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_pg_type_oid(OID) "
- "RETURNS VOID "
- "AS '$libdir/pg_upgrade_support' "
- "LANGUAGE C STRICT;"));
- PQclear(executeQueryOrDie(conn,
- "CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_array_pg_type_oid(OID) "
- "RETURNS VOID "
- "AS '$libdir/pg_upgrade_support' "
- "LANGUAGE C STRICT;"));
- PQclear(executeQueryOrDie(conn,
- "CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_toast_pg_type_oid(OID) "
- "RETURNS VOID "
- "AS '$libdir/pg_upgrade_support' "
- "LANGUAGE C STRICT;"));
- PQclear(executeQueryOrDie(conn,
- "CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_heap_pg_class_oid(OID) "
- "RETURNS VOID "
- "AS '$libdir/pg_upgrade_support' "
- "LANGUAGE C STRICT;"));
- PQclear(executeQueryOrDie(conn,
- "CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_index_pg_class_oid(OID) "
- "RETURNS VOID "
- "AS '$libdir/pg_upgrade_support' "
- "LANGUAGE C STRICT;"));
- PQclear(executeQueryOrDie(conn,
- "CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_toast_pg_class_oid(OID) "
- "RETURNS VOID "
- "AS '$libdir/pg_upgrade_support' "
- "LANGUAGE C STRICT;"));
- PQclear(executeQueryOrDie(conn,
- "CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_pg_enum_oid(OID) "
- "RETURNS VOID "
- "AS '$libdir/pg_upgrade_support' "
- "LANGUAGE C STRICT;"));
- PQclear(executeQueryOrDie(conn,
- "CREATE OR REPLACE FUNCTION "
- "binary_upgrade.set_next_pg_authid_oid(OID) "
- "RETURNS VOID "
- "AS '$libdir/pg_upgrade_support' "
- "LANGUAGE C STRICT;"));
- PQclear(executeQueryOrDie(conn,
- "CREATE OR REPLACE FUNCTION "
- "binary_upgrade.create_empty_extension(text, text, bool, text, oid[], text[], text[]) "
- "RETURNS VOID "
- "AS '$libdir/pg_upgrade_support' "
- "LANGUAGE C;"));
- PQfinish(conn);
-}
-
-
-void
-uninstall_support_functions_from_new_cluster(void)
-{
- int dbnum;
-
- prep_status("Removing support functions from new cluster");
-
- for (dbnum = 0; dbnum < new_cluster.dbarr.ndbs; dbnum++)
- {
- DbInfo *new_db = &new_cluster.dbarr.dbs[dbnum];
- PGconn *conn = connectToServer(&new_cluster, new_db->db_name);
-
- /* suppress NOTICE of dropped objects */
- PQclear(executeQueryOrDie(conn,
- "SET client_min_messages = warning;"));
- PQclear(executeQueryOrDie(conn,
- "DROP SCHEMA binary_upgrade CASCADE;"));
- PQclear(executeQueryOrDie(conn,
- "RESET client_min_messages;"));
- PQfinish(conn);
- }
- check_ok();
-}
-
/*
* get_loadable_libraries()
@@ -218,8 +112,6 @@ get_loadable_libraries(void)
if (found_public_plpython_handler)
pg_fatal("Remove the problem functions from the old cluster to continue.\n");
- totaltups++; /* reserve for pg_upgrade_support */
-
/* Allocate what's certainly enough space */
os_info.libraries = (char **) pg_malloc(totaltups * sizeof(char *));
@@ -228,7 +120,6 @@ get_loadable_libraries(void)
* there probably aren't enough entries to matter.
*/
totaltups = 0;
- os_info.libraries[totaltups++] = pg_strdup(PG_UPGRADE_SUPPORT);
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
{
@@ -321,10 +212,6 @@ check_loadable_libraries(void)
{
found = true;
- /* exit and report missing support library with special message */
- if (strcmp(lib, PG_UPGRADE_SUPPORT) == 0)
- pg_fatal("The pg_upgrade_support module must be created and installed in the new cluster.\n");
-
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
pg_fatal("Could not open file \"%s\": %s\n",
output_path, getErrorText(errno));