On Thu, Aug 22, 2019 at 11:21:21AM -0500, Justin Pryzby wrote:
> And, you could do:
> PGPREVMAJORVERSION=$((PGMAJORVERSION-1))
I take that back; PGPREVMAJORVERSION is used for the upgrade path (which I've
never used).
The prior version could be anything since 8.4, since it's allowed to pg_upgrade
to "skip across" major versions (like from 9.6 to 11).
So it should either be configurable, with a default, like:
# Assign previous major version from current version if not set in environment:
: ${PGPREVMAJORVERSION:=$((PGMAJORVERSION-1))}
Or otherwise it should be detected, perhaps like:
# Should run as user: postgres
psql postgres -Atc "SELECT current_setting('server_version')"
12beta2
Also, I noticed in the upgrade case the initscript says "su" instead of $SU.
Justin