Skip to content

Commit

Permalink
Stop postupgrade when encountering an error
Browse files Browse the repository at this point in the history
This is to provoke an error with our `REINDEX` command on older PG versions.
  • Loading branch information
andyundso committed Nov 19, 2024
1 parent 6f61729 commit 33a5be7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pgautoupgrade-postupgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ if [ $RUNNING -ne 0 ]; then
fi

# Get the list of databases in the database cluster
DB_LIST=$(echo 'SELECT datname FROM pg_catalog.pg_database WHERE datistemplate IS FALSE' | psql --username="${POSTGRES_USER}" -1t --csv "${POSTGRES_DB}")
DB_LIST=$(echo 'SELECT datname FROM pg_catalog.pg_database WHERE datistemplate IS FALSE' | psql -v ON_ERROR_STOP=1 --username="${POSTGRES_USER}" -1t --csv "${POSTGRES_DB}")

# Update query planner statistics
echo "----------------------------"
echo "Updating query planner stats"
echo "----------------------------"

for DATABASE in ${DB_LIST}; do
echo "VACUUM (ANALYZE, VERBOSE, INDEX_CLEANUP FALSE)" | psql --username="${POSTGRES_USER}" -t --csv "${DATABASE}"
echo "VACUUM (ANALYZE, VERBOSE, INDEX_CLEANUP FALSE)" | psql -v ON_ERROR_STOP=1 --username="${POSTGRES_USER}" -t --csv "${DATABASE}"
done

echo "-------------------------------------"
Expand All @@ -65,7 +65,7 @@ if [ "x${PGAUTO_REINDEX}" != "xno" ]; then
echo "Starting reindex of ${DATABASE}"
echo "-------------------------------"

echo 'REINDEX DATABASE CONCURRENTLY' | psql --username="${POSTGRES_USER}" -t --csv "${DATABASE}"
echo 'REINDEX DATABASE CONCURRENTLY' | psql -v ON_ERROR_STOP=1 --username="${POSTGRES_USER}" -t --csv "${DATABASE}"

echo "-------------------------------"
echo "Finished reindex of ${DATABASE}"
Expand Down

0 comments on commit 33a5be7

Please sign in to comment.