@@ -19,6 +19,7 @@ static void check_is_super_user(ClusterInfo *cluster);
19
19
static void check_for_prepared_transactions (ClusterInfo * cluster );
20
20
static void check_for_isn_and_int8_passing_mismatch (ClusterInfo * cluster );
21
21
static void check_for_reg_data_type_usage (ClusterInfo * cluster );
22
+ static void check_for_support_lib (ClusterInfo * cluster );
22
23
23
24
24
25
void
@@ -245,21 +246,7 @@ check_cluster_versions(void)
245
246
void
246
247
check_cluster_compatibility (bool live_check )
247
248
{
248
- char libfile [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 );
263
250
264
251
/* get/check pg_control data of servers */
265
252
get_control_data (& old_cluster , live_check );
@@ -730,3 +717,42 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
730
717
else
731
718
check_ok ();
732
719
}
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
+ static void
727
+ check_for_support_lib (ClusterInfo * cluster )
728
+ {
729
+ char cmd [MAXPGPATH ];
730
+ char libdir [MAX_STRING ];
731
+ char libfile [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
+ }
0 commit comments