@@ -46,6 +46,7 @@ OLD_PGVERSION=$(run_sql -A -t -c "SHOW server_version;")
46
46
47
47
POSTGRES_CONFIG_PATH=" /etc/postgresql/postgresql.conf"
48
48
PGBINOLD=" /usr/lib/postgresql/bin"
49
+ PGLIBOLD=" /usr/lib/postgresql/lib"
49
50
50
51
# If upgrading from older major PG versions, disable specific extensions
51
52
if [[ " $OLD_PGVERSION " =~ ^14.* ]]; then
@@ -247,6 +248,29 @@ function initiate_upgrade {
247
248
248
249
cp --remove-destination " $PGLIBNEW " /* .control " $PGSHARENEW /extension/"
249
250
cp --remove-destination " $PGLIBNEW " /* .sql " $PGSHARENEW /extension/"
251
+
252
+ # This is a workaround for older versions of wrappers which don't have the expected
253
+ # naming scheme, containing the version in their library's file name
254
+ # e.g. wrappers-0.1.16.so, rather than wrappers.so
255
+ # pg_upgrade errors out when it doesn't find an equivalent file in the new PG version's
256
+ # library directory, so we're making sure the new version has the expected (old version's)
257
+ # file name.
258
+ # After the upgrade completes, the new version's library file is used.
259
+ # i.e.
260
+ # - old version: wrappers-0.1.16.so
261
+ # - new version: wrappers-0.1.18.so
262
+ # - workaround to make pg_upgrade happy: copy wrappers-0.1.18.so to wrappers-0.1.16.so
263
+ if [ -d " $PGLIBOLD " ]; then
264
+ WRAPPERS_LIB_PATH=$( find " $PGLIBNEW " -name " wrappers*so" -print -quit)
265
+ if [ -f " $WRAPPERS_LIB_PATH " ]; then
266
+ OLD_WRAPPER_LIB_PATH=$( find " $PGLIBOLD " -name " wrappers*so" -print -quit)
267
+ if [ -f " $OLD_WRAPPER_LIB_PATH " ]; then
268
+ LIB_FILE_NAME=$( basename " $OLD_WRAPPER_LIB_PATH " )
269
+ cp " $WRAPPERS_LIB_PATH " " $PGLIBNEW /${LIB_FILE_NAME} "
270
+ fi
271
+ fi
272
+ fi
273
+
250
274
export LD_LIBRARY_PATH=" ${PGLIBNEW} "
251
275
252
276
echo " 8. Creating new data directory, initializing database"
0 commit comments