|
181 | 181 | done
|
182 | 182 | }
|
183 | 183 |
|
184 |
| -function patch_wrappers { |
185 |
| - local IS_NIX_UPGRADE=$1 |
186 |
| - |
187 |
| - WRAPPERS_ENABLED=$(run_sql -A -t -c "SELECT EXISTS(SELECT 1 FROM pg_extension WHERE extname = 'wrappers');") |
188 |
| - if [ "$WRAPPERS_ENABLED" = "f" ]; then |
189 |
| - echo "Wrappers extension not enabled. Skipping." |
190 |
| - return |
191 |
| - fi |
192 |
| - |
193 |
| - # This is a workaround for older versions of wrappers which don't have the expected |
194 |
| - # naming scheme, containing the version in their library's file name |
195 |
| - # e.g. wrappers-0.1.16.so, rather than wrappers.so |
196 |
| - # pg_upgrade errors out when it doesn't find an equivalent file in the new PG version's |
197 |
| - # library directory, so we're making sure the new version has the expected (old version's) |
198 |
| - # file name. |
199 |
| - # After the upgrade completes, the new version's library file is used. |
200 |
| - # i.e. |
201 |
| - # - old version: wrappers-0.1.16.so |
202 |
| - # - new version: wrappers-0.1.18.so |
203 |
| - # - workaround to make pg_upgrade happy: copy wrappers-0.1.18.so to wrappers-0.1.16.so |
204 |
| - if [ "$IS_NIX_UPGRADE" = "true" ]; then |
205 |
| - if [ -d "$PGLIBOLD" ]; then |
206 |
| - OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit) |
207 |
| - OLD_LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH") |
208 |
| - |
209 |
| - find /nix/store/ -name "wrappers*so" -print0 | while read -r -d $'\0' WRAPPERS_LIB_PATH; do |
210 |
| - if [ -f "$WRAPPERS_LIB_PATH" ]; then |
211 |
| - WRAPPERS_LIB_PATH_DIR=$(dirname "$WRAPPERS_LIB_PATH") |
212 |
| - if [ "$WRAPPERS_LIB_PATH" != "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" ]; then |
213 |
| - echo "Copying $WRAPPERS_LIB_PATH to $WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" |
214 |
| - cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" || true |
215 |
| - fi |
216 |
| - fi |
217 |
| - done |
218 |
| - fi |
219 |
| - else |
220 |
| - if [ -d "$PGLIBOLD" ]; then |
221 |
| - WRAPPERS_LIB_PATH=$(find "$PGLIBNEW" -name "wrappers*so" -print -quit) |
222 |
| - if [ -f "$WRAPPERS_LIB_PATH" ]; then |
223 |
| - OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit) |
224 |
| - if [ -f "$OLD_WRAPPER_LIB_PATH" ]; then |
225 |
| - LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH") |
226 |
| - if [ "$WRAPPERS_LIB_PATH" != "$PGLIBNEW/${LIB_FILE_NAME}" ]; then |
227 |
| - echo "Copying $WRAPPERS_LIB_PATH to $PGLIBNEW/${LIB_FILE_NAME}" |
228 |
| - cp "$WRAPPERS_LIB_PATH" "$PGLIBNEW/${LIB_FILE_NAME}" || true |
229 |
| - fi |
230 |
| - fi |
231 |
| - fi |
232 |
| - fi |
233 |
| - fi |
234 |
| -} |
235 |
| - |
236 | 184 | function initiate_upgrade {
|
237 | 185 | mkdir -p "$MOUNT_POINT"
|
238 | 186 | SHARED_PRELOAD_LIBRARIES=$(cat "$POSTGRES_CONFIG_PATH" | grep shared_preload_libraries | sed "s/shared_preload_libraries =\s\{0,1\}'\(.*\)'.*/\1/")
|
@@ -409,8 +357,6 @@ function initiate_upgrade {
|
409 | 357 | export LD_LIBRARY_PATH="${PGLIBNEW}"
|
410 | 358 | fi
|
411 | 359 |
|
412 |
| - patch_wrappers "$IS_NIX_UPGRADE" |
413 |
| - |
414 | 360 | echo "9. Creating new data directory, initializing database"
|
415 | 361 | chown -R postgres:postgres "$MOUNT_POINT/"
|
416 | 362 | rm -rf "${PGDATANEW:?}/"
|
|
0 commit comments