Skip to content

Commit 02b183a

Browse files
committed
In pg_upgrade, remove dependency on pg_config, as that might not be in
the non-development install. Instead, use the LOAD mechanism to check for the pg_upgrade_support shared object, like we do for other shared object checks. Backpatch to 9.1. Report from Àlvaro
1 parent e3fc4a9 commit 02b183a

File tree

2 files changed

+11
-46
lines changed

2 files changed

+11
-46
lines changed

contrib/pg_upgrade/check.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ static void check_is_super_user(ClusterInfo *cluster);
2020
static void check_for_prepared_transactions(ClusterInfo *cluster);
2121
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
2222
static void check_for_reg_data_type_usage(ClusterInfo *cluster);
23-
static void check_for_support_lib(ClusterInfo *cluster);
2423
static void get_bin_version(ClusterInfo *cluster);
2524

2625

@@ -265,8 +264,6 @@ check_cluster_versions(void)
265264
void
266265
check_cluster_compatibility(bool live_check)
267266
{
268-
check_for_support_lib(&new_cluster);
269-
270267
/* get/check pg_control data of servers */
271268
get_control_data(&old_cluster, live_check);
272269
get_control_data(&new_cluster, false);
@@ -836,45 +833,6 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
836833
}
837834

838835

839-
/*
840-
* Test pg_upgrade_support.so is in the proper place. We cannot copy it
841-
* ourselves because install directories are typically root-owned.
842-
*/
843-
static void
844-
check_for_support_lib(ClusterInfo *cluster)
845-
{
846-
char cmd[MAXPGPATH];
847-
char libdir[MAX_STRING];
848-
char libfile[MAXPGPATH];
849-
FILE *lib_test;
850-
FILE *output;
851-
852-
snprintf(cmd, sizeof(cmd), "\"%s/pg_config\" --pkglibdir", cluster->bindir);
853-
854-
if ((output = popen(cmd, "r")) == NULL ||
855-
fgets(libdir, sizeof(libdir), output) == NULL)
856-
pg_log(PG_FATAL, "Could not get pkglibdir data using %s: %s\n",
857-
cmd, getErrorText(errno));
858-
859-
860-
pclose(output);
861-
862-
/* Remove trailing newline */
863-
if (strchr(libdir, '\n') != NULL)
864-
*strchr(libdir, '\n') = '\0';
865-
866-
snprintf(libfile, sizeof(libfile), "%s/pg_upgrade_support%s", libdir,
867-
DLSUFFIX);
868-
869-
if ((lib_test = fopen(libfile, "r")) == NULL)
870-
pg_log(PG_FATAL,
871-
"The pg_upgrade_support module must be created and installed in the %s cluster.\n",
872-
CLUSTER_NAME(cluster));
873-
874-
fclose(lib_test);
875-
}
876-
877-
878836
static void
879837
get_bin_version(ClusterInfo *cluster)
880838
{

contrib/pg_upgrade/function.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "access/transam.h"
1515

16+
#define PG_UPGRADE_SUPPORT "$libdir/pg_upgrade_support"
1617

1718
/*
1819
* install_support_functions_in_new_db()
@@ -154,17 +155,17 @@ get_loadable_libraries(void)
154155
PQfinish(conn);
155156
}
156157

158+
totaltups++; /* reserve for pg_upgrade_support */
159+
157160
/* Allocate what's certainly enough space */
158-
if (totaltups > 0)
159-
os_info.libraries = (char **) pg_malloc(totaltups * sizeof(char *));
160-
else
161-
os_info.libraries = NULL;
161+
os_info.libraries = (char **) pg_malloc(totaltups * sizeof(char *));
162162

163163
/*
164164
* Now remove duplicates across DBs. This is pretty inefficient code, but
165165
* there probably aren't enough entries to matter.
166166
*/
167167
totaltups = 0;
168+
os_info.libraries[totaltups++] = pg_strdup(PG_UPGRADE_SUPPORT);
168169

169170
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
170171
{
@@ -256,6 +257,12 @@ check_loadable_libraries(void)
256257
if (PQresultStatus(res) != PGRES_COMMAND_OK)
257258
{
258259
found = true;
260+
261+
/* exit and report missing support library with special message */
262+
if (strcmp(lib, PG_UPGRADE_SUPPORT) == 0)
263+
pg_log(PG_FATAL,
264+
"The pg_upgrade_support module must be created and installed in the new cluster.\n");
265+
259266
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
260267
pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
261268
output_path, getErrorText(errno));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy