mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
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
This commit is contained in:
parent
e3fc4a97bc
commit
02b183acb4
@ -20,7 +20,6 @@ static void check_is_super_user(ClusterInfo *cluster);
|
|||||||
static void check_for_prepared_transactions(ClusterInfo *cluster);
|
static void check_for_prepared_transactions(ClusterInfo *cluster);
|
||||||
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
|
static void check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster);
|
||||||
static void check_for_reg_data_type_usage(ClusterInfo *cluster);
|
static void check_for_reg_data_type_usage(ClusterInfo *cluster);
|
||||||
static void check_for_support_lib(ClusterInfo *cluster);
|
|
||||||
static void get_bin_version(ClusterInfo *cluster);
|
static void get_bin_version(ClusterInfo *cluster);
|
||||||
|
|
||||||
|
|
||||||
@ -265,8 +264,6 @@ check_cluster_versions(void)
|
|||||||
void
|
void
|
||||||
check_cluster_compatibility(bool live_check)
|
check_cluster_compatibility(bool live_check)
|
||||||
{
|
{
|
||||||
check_for_support_lib(&new_cluster);
|
|
||||||
|
|
||||||
/* get/check pg_control data of servers */
|
/* get/check pg_control data of servers */
|
||||||
get_control_data(&old_cluster, live_check);
|
get_control_data(&old_cluster, live_check);
|
||||||
get_control_data(&new_cluster, false);
|
get_control_data(&new_cluster, false);
|
||||||
@ -836,45 +833,6 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Test pg_upgrade_support.so is in the proper place. We cannot copy it
|
|
||||||
* ourselves because install directories are typically root-owned.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
check_for_support_lib(ClusterInfo *cluster)
|
|
||||||
{
|
|
||||||
char cmd[MAXPGPATH];
|
|
||||||
char libdir[MAX_STRING];
|
|
||||||
char libfile[MAXPGPATH];
|
|
||||||
FILE *lib_test;
|
|
||||||
FILE *output;
|
|
||||||
|
|
||||||
snprintf(cmd, sizeof(cmd), "\"%s/pg_config\" --pkglibdir", cluster->bindir);
|
|
||||||
|
|
||||||
if ((output = popen(cmd, "r")) == NULL ||
|
|
||||||
fgets(libdir, sizeof(libdir), output) == NULL)
|
|
||||||
pg_log(PG_FATAL, "Could not get pkglibdir data using %s: %s\n",
|
|
||||||
cmd, getErrorText(errno));
|
|
||||||
|
|
||||||
|
|
||||||
pclose(output);
|
|
||||||
|
|
||||||
/* Remove trailing newline */
|
|
||||||
if (strchr(libdir, '\n') != NULL)
|
|
||||||
*strchr(libdir, '\n') = '\0';
|
|
||||||
|
|
||||||
snprintf(libfile, sizeof(libfile), "%s/pg_upgrade_support%s", libdir,
|
|
||||||
DLSUFFIX);
|
|
||||||
|
|
||||||
if ((lib_test = fopen(libfile, "r")) == NULL)
|
|
||||||
pg_log(PG_FATAL,
|
|
||||||
"The pg_upgrade_support module must be created and installed in the %s cluster.\n",
|
|
||||||
CLUSTER_NAME(cluster));
|
|
||||||
|
|
||||||
fclose(lib_test);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_bin_version(ClusterInfo *cluster)
|
get_bin_version(ClusterInfo *cluster)
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "access/transam.h"
|
#include "access/transam.h"
|
||||||
|
|
||||||
|
#define PG_UPGRADE_SUPPORT "$libdir/pg_upgrade_support"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* install_support_functions_in_new_db()
|
* install_support_functions_in_new_db()
|
||||||
@ -154,17 +155,17 @@ get_loadable_libraries(void)
|
|||||||
PQfinish(conn);
|
PQfinish(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
totaltups++; /* reserve for pg_upgrade_support */
|
||||||
|
|
||||||
/* Allocate what's certainly enough space */
|
/* Allocate what's certainly enough space */
|
||||||
if (totaltups > 0)
|
os_info.libraries = (char **) pg_malloc(totaltups * sizeof(char *));
|
||||||
os_info.libraries = (char **) pg_malloc(totaltups * sizeof(char *));
|
|
||||||
else
|
|
||||||
os_info.libraries = NULL;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Now remove duplicates across DBs. This is pretty inefficient code, but
|
* Now remove duplicates across DBs. This is pretty inefficient code, but
|
||||||
* there probably aren't enough entries to matter.
|
* there probably aren't enough entries to matter.
|
||||||
*/
|
*/
|
||||||
totaltups = 0;
|
totaltups = 0;
|
||||||
|
os_info.libraries[totaltups++] = pg_strdup(PG_UPGRADE_SUPPORT);
|
||||||
|
|
||||||
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
|
for (dbnum = 0; dbnum < old_cluster.dbarr.ndbs; dbnum++)
|
||||||
{
|
{
|
||||||
@ -256,6 +257,12 @@ check_loadable_libraries(void)
|
|||||||
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (PQresultStatus(res) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
|
/* exit and report missing support library with special message */
|
||||||
|
if (strcmp(lib, PG_UPGRADE_SUPPORT) == 0)
|
||||||
|
pg_log(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)
|
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
|
||||||
pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
|
pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
|
||||||
output_path, getErrorText(errno));
|
output_path, getErrorText(errno));
|
||||||
|
Loading…
Reference in New Issue
Block a user