commit cc306db88c5edfe74e9290796c0bfa8749c86d29 Author: Anton A. Melnikov Date: Sat Jun 4 12:24:16 2022 +0300 Fix test for pg_upgrade from 10x and earlier versions. diff --git a/src/bin/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh index 9f6fb3e018..4fc6e6657c 100644 --- a/src/bin/pg_upgrade/test.sh +++ b/src/bin/pg_upgrade/test.sh @@ -24,7 +24,13 @@ standard_initdb() { # without increasing test runtime, run these tests with a custom setting. # Also, specify "-A trust" explicitly to suppress initdb's warning. # --allow-group-access and --wal-segsize have been added in v11. - "$1" -N --wal-segsize 1 --allow-group-access -A trust + initdbopt="-N -A trust" + if [ $OLD_PG_VERSION_NUM -ge 110000 ]; then + initdbopt="$initdbopt --wal-segsize 1 --allow-group-access" + fi + + "$1" $initdbopt + if [ -n "$TEMP_CONFIG" -a -r "$TEMP_CONFIG" ] then cat "$TEMP_CONFIG" >> "$PGDATA/postgresql.conf" @@ -131,6 +137,7 @@ PGHOSTADDR=""; unset PGHOSTADDR # Select a non-conflicting port number, similarly to pg_regress.c PG_VERSION_NUM=`grep '#define PG_VERSION_NUM' "$newsrc"/src/include/pg_config.h | awk '{print $3}'` +OLD_PG_VERSION_NUM=`grep '#define PG_VERSION_NUM' "$oldsrc"/src/include/pg_config.h | awk '{print $3}'` PGPORT=`expr $PG_VERSION_NUM % 16384 + 49152` export PGPORT @@ -235,18 +242,26 @@ pg_upgrade $PG_UPGRADE_OPTS -d "${PGDATA}.old" -D "$PGDATA" -b "$oldbindir" -p " # make sure all directories and files have group permissions, on Unix hosts # Windows hosts don't support Unix-y permissions. +if [ $OLD_PG_VERSION_NUM -lt 110000 ]; then + NEW_DIR_PERM=700 + NEW_FILE_PERM=600 +else + NEW_DIR_PERM=750 + NEW_FILE_PERM=640 +fi + case $testhost in MINGW*) ;; - *) if [ `find "$PGDATA" -type f ! -perm 640 | wc -l` -ne 0 ]; then - echo "files in PGDATA with permission != 640"; + *) if [ `find "$PGDATA" -type f ! -perm $NEW_FILE_PERM | wc -l` -ne 0 ]; then + echo "files in PGDATA with permission != $NEW_FILE_PERM"; exit 1; fi ;; esac case $testhost in MINGW*) ;; - *) if [ `find "$PGDATA" -type d ! -perm 750 | wc -l` -ne 0 ]; then - echo "directories in PGDATA with permission != 750"; + *) if [ `find "$PGDATA" -type d ! -perm $NEW_DIR_PERM | wc -l` -ne 0 ]; then + echo "directories in PGDATA with permission != $NEW_DIR_PERM"; exit 1; fi ;; esac