Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2815574

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 ed79edd commit 2815574

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
@@ -19,7 +19,6 @@ static void check_is_super_user(ClusterInfo *cluster);
1919
static void check_for_prepared_transactions(ClusterInfo *cluster);
2020
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
2121
static void check_for_reg_data_type_usage(ClusterInfo *cluster);
22-
static void check_for_support_lib(ClusterInfo *cluster);
2322
static void get_bin_version(ClusterInfo *cluster);
2423

2524

@@ -266,8 +265,6 @@ check_cluster_versions(void)
266265
void
267266
check_cluster_compatibility(bool live_check)
268267
{
269-
check_for_support_lib(&new_cluster);
270-
271268
/* get/check pg_control data of servers */
272269
get_control_data(&old_cluster, live_check);
273270
get_control_data(&new_cluster, false);
@@ -739,45 +736,6 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
739736
}
740737

741738

742-
/*
743-
* Test pg_upgrade_support.so is in the proper place. We cannot copy it
744-
* ourselves because install directories are typically root-owned.
745-
*/
746-
static void
747-
check_for_support_lib(ClusterInfo *cluster)
748-
{
749-
char cmd[MAXPGPATH];
750-
char libdir[MAX_STRING];
751-
char libfile[MAXPGPATH];
752-
FILE *lib_test;
753-
FILE *output;
754-
755-
snprintf(cmd, sizeof(cmd), "\"%s/pg_config\" --pkglibdir", cluster->bindir);
756-
757-
if ((output = popen(cmd, "r")) == NULL)
758-
pg_log(PG_FATAL, "Could not get pkglibdir data: %s\n",
759-
getErrorText(errno));
760-
761-
fgets(libdir, sizeof(libdir), output);
762-
763-
pclose(output);
764-
765-
/* Remove trailing newline */
766-
if (strchr(libdir, '\n') != NULL)
767-
*strchr(libdir, '\n') = '\0';
768-
769-
snprintf(libfile, sizeof(libfile), "%s/pg_upgrade_support%s", libdir,
770-
DLSUFFIX);
771-
772-
if ((lib_test = fopen(libfile, "r")) == NULL)
773-
pg_log(PG_FATAL,
774-
"The pg_upgrade_support module must be created and installed in the %s cluster.\n",
775-
CLUSTER_NAME(cluster));
776-
777-
fclose(lib_test);
778-
}
779-
780-
781739
static void
782740
get_bin_version(ClusterInfo *cluster)
783741
{

contrib/pg_upgrade/function.c

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

1212
#include "access/transam.h"
1313

14+
#define PG_UPGRADE_SUPPORT "$libdir/pg_upgrade_support"
1415

1516
/*
1617
* install_support_functions_in_new_db()
@@ -153,17 +154,17 @@ get_loadable_libraries(void)
153154
PQfinish(conn);
154155
}
155156

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

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

168169
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
169170
{
@@ -252,6 +253,12 @@ check_loadable_libraries(void)
252253
if (PQresultStatus(res) != PGRES_COMMAND_OK)
253254
{
254255
found = true;
256+
257+
/* exit and report missing support library with special message */
258+
if (strcmp(lib, PG_UPGRADE_SUPPORT) == 0)
259+
pg_log(PG_FATAL,
260+
"The pg_upgrade_support module must be created and installed in the new cluster.\n");
261+
255262
if (script == NULL && (script = fopen(output_path, "w")) == NULL)
256263
pg_log(PG_FATAL, "Could not create necessary file: %s\n",
257264
output_path);

0 commit comments

Comments
 (0)