Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit559b114

Browse files
committed
Adjust pg_upgrade check for pg_upgrade_support to happen after the
binary directory has been validated.Backpatch to 9.1.Dan McGee
1 parentb06ad7d commit559b114

File tree

3 files changed

+41
-61
lines changed

3 files changed

+41
-61
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static void check_is_super_user(ClusterInfo *cluster);
1919
staticvoidcheck_for_prepared_transactions(ClusterInfo*cluster);
2020
staticvoidcheck_for_isn_and_int8_passing_mismatch(ClusterInfo*cluster);
2121
staticvoidcheck_for_reg_data_type_usage(ClusterInfo*cluster);
22+
staticvoidcheck_for_support_lib(ClusterInfo*cluster);
2223

2324

2425
void
@@ -245,21 +246,7 @@ check_cluster_versions(void)
245246
void
246247
check_cluster_compatibility(boollive_check)
247248
{
248-
charlibfile[MAXPGPATH];
249-
FILE*lib_test;
250-
251-
/*
252-
* Test pg_upgrade_support.so is in the proper place. We cannot copy it
253-
* ourselves because install directories are typically root-owned.
254-
*/
255-
snprintf(libfile,sizeof(libfile),"%s/pg_upgrade_support%s",new_cluster.libpath,
256-
DLSUFFIX);
257-
258-
if ((lib_test=fopen(libfile,"r"))==NULL)
259-
pg_log(PG_FATAL,
260-
"pg_upgrade_support%s must be created and installed in %s\n",DLSUFFIX,libfile);
261-
else
262-
fclose(lib_test);
249+
check_for_support_lib(&new_cluster);
263250

264251
/* get/check pg_control data of servers */
265252
get_control_data(&old_cluster,live_check);
@@ -730,3 +717,42 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
730717
else
731718
check_ok();
732719
}
720+
721+
722+
/*
723+
* Test pg_upgrade_support.so is in the proper place. We cannot copy it
724+
* ourselves because install directories are typically root-owned.
725+
*/
726+
staticvoid
727+
check_for_support_lib(ClusterInfo*cluster)
728+
{
729+
charcmd[MAXPGPATH];
730+
charlibdir[MAX_STRING];
731+
charlibfile[MAXPGPATH];
732+
FILE*lib_test;
733+
FILE*output;
734+
735+
snprintf(cmd,sizeof(cmd),"\"%s/pg_config\" --pkglibdir",cluster->bindir);
736+
737+
if ((output=popen(cmd,"r"))==NULL)
738+
pg_log(PG_FATAL,"Could not get pkglibdir data: %s\n",
739+
getErrorText(errno));
740+
741+
fgets(libdir,sizeof(libdir),output);
742+
743+
pclose(output);
744+
745+
/* Remove trailing newline */
746+
if (strchr(libdir,'\n')!=NULL)
747+
*strchr(libdir,'\n')='\0';
748+
749+
snprintf(libfile,sizeof(libfile),"%s/pg_upgrade_support%s",libdir,
750+
DLSUFFIX);
751+
752+
if ((lib_test=fopen(libfile,"r"))==NULL)
753+
pg_log(PG_FATAL,
754+
"The pg_upgrade_support module must be created and installed in the %s cluster.\n",
755+
CLUSTER_NAME(cluster));
756+
757+
fclose(lib_test);
758+
}

‎contrib/pg_upgrade/option.c

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
staticvoidusage(void);
2020
staticvoidvalidateDirectoryOption(char**dirpath,
2121
char*envVarName,char*cmdLineOption,char*description);
22-
staticvoidget_pkglibdirs(void);
23-
staticchar*get_pkglibdir(constchar*bindir);
2422

2523

2624
UserOptsuser_opts;
@@ -213,8 +211,6 @@ parseCommandLine(int argc, char *argv[])
213211
"old cluster data resides");
214212
validateDirectoryOption(&new_cluster.pgdata,"NEWDATADIR","-D",
215213
"new cluster data resides");
216-
217-
get_pkglibdirs();
218214
}
219215

220216

@@ -314,44 +310,3 @@ validateDirectoryOption(char **dirpath, char *envVarName,
314310
#endif
315311
(*dirpath)[strlen(*dirpath)-1]=0;
316312
}
317-
318-
319-
staticvoid
320-
get_pkglibdirs(void)
321-
{
322-
/*
323-
* we do not need to know the libpath in the old cluster, and might not
324-
* have a working pg_config to ask for it anyway.
325-
*/
326-
old_cluster.libpath=NULL;
327-
new_cluster.libpath=get_pkglibdir(new_cluster.bindir);
328-
}
329-
330-
331-
staticchar*
332-
get_pkglibdir(constchar*bindir)
333-
{
334-
charcmd[MAXPGPATH];
335-
charbufin[MAX_STRING];
336-
FILE*output;
337-
inti;
338-
339-
snprintf(cmd,sizeof(cmd),"\"%s/pg_config\" --pkglibdir",bindir);
340-
341-
if ((output=popen(cmd,"r"))==NULL)
342-
pg_log(PG_FATAL,"Could not get pkglibdir data: %s\n",
343-
getErrorText(errno));
344-
345-
fgets(bufin,sizeof(bufin),output);
346-
347-
if (output)
348-
pclose(output);
349-
350-
/* Remove trailing newline */
351-
i=strlen(bufin)-1;
352-
353-
if (bufin[i]=='\n')
354-
bufin[i]='\0';
355-
356-
returnpg_strdup(bufin);
357-
}

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ typedef struct
185185
uint32major_version;/* PG_VERSION of cluster */
186186
charmajor_version_str[64];/* string PG_VERSION of cluster */
187187
Oidpg_database_oid;/* OID of pg_database relation */
188-
char*libpath;/* pathname for cluster's pkglibdir */
189188
char*tablespace_suffix;/* directory specification */
190189
}ClusterInfo;
191190

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp