#!/bin/sh #----------------------------------------------------------------------- # pg_plug -- painless upgrade # PG 7.4 standard -> PG 7.4 with various enhancements # # 2003-10-04 mk new # 2003-10-14 mk addpatchinfo # 2003-11-01 mk VIEW pg_patchinfo # 2004-11-04 mk renamed VIEW to pg_patches; # features selectable via command line (-F) # 2004-12-14 mk freeze #----------------------------------------------------------------------- ALLFEATURES="22 27" #----------------------------------------------------------------------- abortscript(){ echo 1>&2 echo "$1" 1>&2 exit 1 } setconnectable(){ db=$1 allow=$2 $CMD template1 >/dev/null </dev/null </dev/null </dev/null <&2 exit 1 fi #----------------------------------------------------------------------- PG_OPT="-O" PG_OPT="$PG_OPT -c search_path=pg_catalog" PG_OPT="$PG_OPT -c exit_on_error=true" #PG_OPT="$PG_OPT -c enable_indexstat=false" PG_OPT="$PG_OPT -D $PGDATA" CMD="$BINDIR/postgres $PG_OPT" : ${FEATURES:=$ALLFEATURES} # Enable connections to template0 setconnectable template0 true || abortscript "cannot enable connections to template0" for db in `enumdatabases` do echo converting database $db ... for f in $FEATURES do case $f in 22) add22indexstat $db # || abortscript "cannot convert database $db" ;; 27) add27patchinfo $db # || abortscript "cannot convert database $db" ;; *) abortscript "unknown feature $f" ;; esac done freeze $db || abortscript "cannot freeze $db" done # Re-disable connections to template0 setconnectable template0 false || abortscript "cannot re-disable connections to template0"