#!/usr/bin/env bash # #5018: el camino de pg_upgrade que el autor dijo (2024-06-19) no haber # ejecutado nunca: "I'm not sure how to test this (even manually) ... the # upgrade code I haven't actually run." # # pg_upgrade corre el pg_dump NUEVO contra el servidor VIEJO. Asi que basta # un cluster PG18 real y el pg_dump del build parchado. # # Control: el mismo pg_dump de master (sin el patch) contra el mismo cluster. set -u BASE=$HOME/pg5018 D18=$BASE/data18 P18=55418 rm -rf "$D18" "$BASE/i-rel18/bin/initdb" -D "$D18" -U postgres --no-sync -A trust > "$BASE/initdb18.log" 2>&1 \ || { echo "initdb 18 FALLO"; tail -5 "$BASE/initdb18.log"; exit 1; } "$BASE/i-rel18/bin/pg_ctl" -D "$D18" -o "-p $P18" -l "$BASE/pg18.log" -w start > /dev/null 2>&1 \ || { echo "start 18 FALLO"; tail -5 "$BASE/pg18.log"; exit 1; } echo "== servidor viejo: $("$BASE/i-rel18/bin/psql" -p $P18 -U postgres -tAc 'select version()' | cut -c1-40)" # Una extension cualquiera, de las que trae el propio arbol. "$BASE/i-rel18/bin/psql" -p $P18 -U postgres -qc 'CREATE EXTENSION IF NOT EXISTS plpgsql' 2>/dev/null "$BASE/i-rel18/bin/psql" -p $P18 -U postgres -tAc \ "select extname from pg_extension order by 1" | sed 's/^/ extension: /' for w in master v11; do echo "== pg_dump --binary-upgrade del build '$w' contra el servidor PG18" if "$BASE/i-$w/bin/pg_dump" -p $P18 -U postgres --binary-upgrade -s -d postgres \ > "$BASE/dump_${w}_desde18.sql" 2> "$BASE/dump_${w}_desde18.err"; then echo " OK ($(wc -l < "$BASE/dump_${w}_desde18.sql") lineas)" else echo " FALLA:" sed 's/^/ /' "$BASE/dump_${w}_desde18.err" | head -5 fi done "$BASE/i-rel18/bin/pg_ctl" -D "$D18" -w stop > /dev/null 2>&1 echo "== FIN"