From 1c2257648a37187324a819c38d5f90263a34f955 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 18 Dec 1999 08:34:50 +0000 Subject: [PATCH] > > It would be nice for new users; I think it would make it easier > > for them to actually set out and do it. Many new users are > > of the not-so-knowledgable variety, and shell scripting isn't > > something they want to undertake. > > Can someone modify the vacuumdb shell script to do that? i tried it... it seems to work neko@kredit.sth.sz --- doc/src/sgml/ref/vacuumdb.sgml | 13 +++++++++++-- src/bin/scripts/vacuumdb | 13 ++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/src/sgml/ref/vacuumdb.sgml b/doc/src/sgml/ref/vacuumdb.sgml index 96a4f06d6a..a730807015 100644 --- a/doc/src/sgml/ref/vacuumdb.sgml +++ b/doc/src/sgml/ref/vacuumdb.sgml @@ -1,5 +1,5 @@ @@ -23,7 +23,7 @@ Postgres documentation 1999-12-04 -vacuumdb [ connection options ] [ --analyze | -z ] [ --verbose | -v ] +vacuumdb [ connection options ] [ --analyze | -z ] [ --alldb | -a ] [ --verbose | -v ] [ --table 'table [ ( column [,...] ) ]' ] [ [-d] dbname ] @@ -56,6 +56,15 @@ vacuumdb [ connection options ] [ - + + -a, --alldb + + + Vacuum all databases. + + + + -v, --verbose diff --git a/src/bin/scripts/vacuumdb b/src/bin/scripts/vacuumdb index 487a2c4fee..ea5fe1697e 100644 --- a/src/bin/scripts/vacuumdb +++ b/src/bin/scripts/vacuumdb @@ -11,7 +11,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.4 1999/12/16 20:10:02 momjian Exp $ +# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.5 1999/12/18 08:34:50 momjian Exp $ # #------------------------------------------------------------------------- @@ -39,6 +39,8 @@ do --host=*) PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'` ;; + --alldb|-a) + dbname="`psql $PASSWDOPT $AUTHOPT $PGHOSTOPT $PGPORTOPT -q -t -A -d template1 -c 'SELECT datname FROM pg_database'`";; --port|-p) PSQLOPT="$PSQLOPT -p $2" shift;; @@ -119,6 +121,7 @@ if [ "$usage" ]; then echo " -W, --password " echo " -d DBNAME, --database=DBNAME " echo " -z, --analyze " + echo " -a, --alldb " echo " -t TABLE[(columns)], --table=TABLE[(columns)]" echo " -v, --verbose " echo " -e, --echo " @@ -133,9 +136,13 @@ if [ -z "$dbname" ]; then exit 1 fi -psql $PSQLOPT -d "$dbname" -c "VACUUM $verbose$analyze$table" +for db in $dbname +do + psql $PASSWDOPT -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "vacuum $verbose $analyze $table" $db +done -if [ $? -ne 0 ]; then +if [ $? -ne 0 ] +then echo "$CMDNAME: Vacuum failed." exit 1 fi -- 2.40.0