Make sure shell scripts send error messages to stderr.

Improve help output.
Teach droplang to remove 'pltclu'.
This commit is contained in:
Peter Eisentraut 2000-11-11 22:59:48 +00:00
parent b9c8faedde
commit 8095924bdd
11 changed files with 141 additions and 109 deletions

View File

@ -23,7 +23,7 @@
# #
# Copyright (c) 1994, Regents of the University of California # Copyright (c) 1994, Regents of the University of California
# #
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.112 2000/11/09 11:26:00 vadim Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.113 2000/11/11 22:59:46 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -34,17 +34,17 @@
exit_nicely(){ exit_nicely(){
stty echo > /dev/null 2>&1 stty echo > /dev/null 2>&1
echo echo 1>&2
echo "$CMDNAME failed." echo "$CMDNAME failed." 1>&2
if [ "$noclean" != yes ]; then if [ "$noclean" != yes ]; then
if [ "$template_only" != yes ] && [ "$made_new_pgdata" = yes ]; then if [ "$template_only" != yes ] && [ "$made_new_pgdata" = yes ]; then
echo "Removing $PGDATA." echo "Removing $PGDATA." 1>&2
rm -rf "$PGDATA" || echo "Failed." rm -rf "$PGDATA" || echo "Failed." 1>&2
fi fi
echo "Removing temp file $TEMPFILE." echo "Removing temp file $TEMPFILE." 1>&2
rm -rf "$TEMPFILE" || echo "Failed." rm -rf "$TEMPFILE" || echo "Failed." 1>&2
else else
echo "Data directory $PGDATA will not be removed at user's request." echo "Data directory $PGDATA will not be removed at user's request." 1>&2
fi fi
exit 1 exit 1
} }
@ -117,13 +117,13 @@ elif [ -x "$bindir/postgres" ]; then
then then
PGPATH=$bindir PGPATH=$bindir
else else
echo "The program '$bindir/postgres' needed by $CMDNAME does not belong to" echo "The program '$bindir/postgres' needed by $CMDNAME does not belong to" 1>&2
echo "PostgreSQL version $VERSION. Check your installation." echo "PostgreSQL version $VERSION. Check your installation." 1>&2
exit 1 exit 1
fi fi
else else
echo "The program 'postgres' is needed by $CMDNAME but was not found in" echo "The program 'postgres' is needed by $CMDNAME but was not found in" 1>&2
echo "the directory '$bindir'. Check your installation." echo "the directory '$bindir'. Check your installation." 1>&2
exit 1 exit 1
fi fi
@ -131,29 +131,29 @@ fi
# Now we can assume that 'pg_id' belongs to the same version as the # Now we can assume that 'pg_id' belongs to the same version as the
# verified 'postgres' in the same directory. # verified 'postgres' in the same directory.
if [ ! -x "$PGPATH/pg_id" ]; then if [ ! -x "$PGPATH/pg_id" ]; then
echo "The program 'pg_id' is needed by $CMDNAME but was not found in" echo "The program 'pg_id' is needed by $CMDNAME but was not found in" 1>&2
echo "the directory '$PGPATH'. Check your installation." echo "the directory '$PGPATH'. Check your installation." 1>&2
exit 1 exit 1
fi fi
EffectiveUser=`$PGPATH/pg_id -n -u` EffectiveUser=`$PGPATH/pg_id -n -u`
if [ -z "$EffectiveUser" ]; then if [ -z "$EffectiveUser" ]; then
echo "$CMDNAME: could not determine current user name" echo "$CMDNAME: could not determine current user name" 1>&2
exit 1 exit 1
fi fi
if [ `$PGPATH/pg_id -u` -eq 0 ] if [ `$PGPATH/pg_id -u` -eq 0 ]
then then
echo "You cannot run $CMDNAME as root. Please log in (using, e.g., 'su')" echo "You cannot run $CMDNAME as root. Please log in (using, e.g., 'su')" 1>&2
echo "as the (unprivileged) user that will own the server process." echo "as the (unprivileged) user that will own the server process." 1>&2
exit 1 exit 1
fi fi
short_version=`echo $VERSION | sed -e 's!^\([0-9][0-9]*\.[0-9][0-9]*\).*!\1!'` short_version=`echo $VERSION | sed -e 's!^\([0-9][0-9]*\.[0-9][0-9]*\).*!\1!'`
if [ x"$short_version" = x"" ] ; then if [ x"$short_version" = x"" ] ; then
echo "$CMDNAME: bug: version number is out of format" echo "$CMDNAME: bug: version number has wrong format" 1>&2
exit 1 exit 1
fi fi
@ -252,7 +252,7 @@ do
;; ;;
-*) -*)
echo "$CMDNAME: invalid option: $1" echo "$CMDNAME: invalid option: $1"
echo "Try -? for help." echo "Try '$CMDNAME -?' for help."
exit 1 exit 1
;; ;;
*) *)
@ -263,20 +263,20 @@ do
done done
if [ "$usage" ]; then if [ "$usage" ]; then
echo "$CMDNAME initialized a PostgreSQL database cluster." echo "$CMDNAME initializes a PostgreSQL database cluster."
echo echo
echo "Usage:" echo "Usage:"
echo " $CMDNAME [options] datadir" echo " $CMDNAME [options] datadir"
echo echo
echo "Options:" echo "Options:"
echo " [-D, --pgdata] <datadir> Location for this database cluster" echo " [-D, --pgdata] DATADIR Location for this database cluster"
echo " -W, --pwprompt Prompt for a password for the new superuser" echo " -W, --pwprompt Prompt for a password for the new superuser"
if [ -n "$MULTIBYTE" ] ; then if [ -n "$MULTIBYTE" ] ; then
echo " -E, --encoding <encoding> Set the default multibyte encoding for new databases" echo " -E, --encoding ENCODING Set the default multibyte encoding for new databases"
fi fi
echo " -i, --sysid <sysid> Database sysid for the superuser" echo " -i, --sysid SYSID Database sysid for the superuser"
echo "Less commonly used options: " echo "Less commonly used options: "
echo " -L <directory> Where to find the input files" echo " -L DIRECTORY Where to find the input files"
echo " -t, --template Re-initialize template database only" echo " -t, --template Re-initialize template database only"
echo " -d, --debug Generate lots of debugging output" echo " -d, --debug Generate lots of debugging output"
echo " -n, --noclean Do not clean up after errors" echo " -n, --noclean Do not clean up after errors"
@ -294,15 +294,17 @@ then
MULTIBYTEID=`$PGPATH/pg_encoding $MULTIBYTE` MULTIBYTEID=`$PGPATH/pg_encoding $MULTIBYTE`
if [ "$?" -ne 0 ] if [ "$?" -ne 0 ]
then then
(
echo "$CMDNAME: pg_encoding failed" echo "$CMDNAME: pg_encoding failed"
echo echo
echo "Perhaps you did not configure PostgreSQL for multibyte support or" echo "Perhaps you did not configure PostgreSQL for multibyte support or"
echo "the program was not successfully installed." echo "the program was not successfully installed."
) 1>&2
exit 1 exit 1
fi fi
if [ -z "$MULTIBYTEID" ] if [ -z "$MULTIBYTEID" ]
then then
echo "$CMDNAME: $MULTIBYTE is not a valid encoding name" echo "$CMDNAME: $MULTIBYTE is not a valid encoding name" 1>&2
exit 1 exit 1
fi fi
fi fi
@ -314,10 +316,11 @@ fi
if [ -z "$PGDATA" ] if [ -z "$PGDATA" ]
then then
(
echo "$CMDNAME: You must identify where the the data for this database" echo "$CMDNAME: You must identify where the the data for this database"
echo "system will reside. Do this with either a -D invocation" echo "system will reside. Do this with either a -D invocation"
echo "option or a PGDATA environment variable." echo "option or a PGDATA environment variable."
echo ) 1>&2
exit 1 exit 1
fi fi
@ -353,18 +356,22 @@ fi
for PREREQ_FILE in "$TEMPLATE1_BKI" "$GLOBAL_BKI" "$PG_HBA_SAMPLE" for PREREQ_FILE in "$TEMPLATE1_BKI" "$GLOBAL_BKI" "$PG_HBA_SAMPLE"
do do
if [ ! -f "$PREREQ_FILE" ] ; then if [ ! -f "$PREREQ_FILE" ] ; then
(
echo "$CMDNAME does not find the file '$PREREQ_FILE'." echo "$CMDNAME does not find the file '$PREREQ_FILE'."
echo "This means you have a corrupted installation or identified the" echo "This means you have a corrupted installation or identified the"
echo "wrong directory with the -L invocation option." echo "wrong directory with the -L invocation option."
) 1>&2
exit 1 exit 1
fi fi
done done
for file in "$TEMPLATE1_BKI" "$GLOBAL_BKI"; do for file in "$TEMPLATE1_BKI" "$GLOBAL_BKI"; do
if [ x"`sed 1q $file`" != x"# PostgreSQL $short_version" ]; then if [ x"`sed 1q $file`" != x"# PostgreSQL $short_version" ]; then
(
echo "The input file '$file' needed by $CMDNAME does not" echo "The input file '$file' needed by $CMDNAME does not"
echo "belong to PostgreSQL $VERSION. Check your installation or specify the" echo "belong to PostgreSQL $VERSION. Check your installation or specify the"
echo "correct path using the -L option." echo "correct path using the -L option."
) 1>&2
exit 1 exit 1
fi fi
done done
@ -391,10 +398,12 @@ if [ x"$pgdata_contents" != x ]
then then
if [ "$template_only" != yes ] if [ "$template_only" != yes ]
then then
(
echo "$CMDNAME: The directory $PGDATA is exists but is not empty." echo "$CMDNAME: The directory $PGDATA is exists but is not empty."
echo "If you want to create a new database system, either remove or empty" echo "If you want to create a new database system, either remove or empty"
echo "the directory $PGDATA or run initdb with an argument" echo "the directory $PGDATA or run initdb with an argument"
echo "other than $PGDATA." echo "other than $PGDATA."
) 1>&2
exit 1 exit 1
fi fi
else else
@ -509,13 +518,13 @@ if [ "$PwPrompt" ]; then
stty echo > /dev/null 2>&1 stty echo > /dev/null 2>&1
echo echo
if [ "$FirstPw" != "$SecondPw" ]; then if [ "$FirstPw" != "$SecondPw" ]; then
echo "Passwords didn't match." echo "Passwords didn't match." 1>&2
exit_nicely exit_nicely
fi fi
echo "ALTER USER \"$POSTGRES_SUPERUSERNAME\" WITH PASSWORD '$FirstPw'" \ echo "ALTER USER \"$POSTGRES_SUPERUSERNAME\" WITH PASSWORD '$FirstPw'" \
| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
if [ ! -f $PGDATA/pg_pwd ]; then if [ ! -f $PGDATA/pg_pwd ]; then
echo "The password file wasn't generated. Please report this problem." echo "The password file wasn't generated. Please report this problem." 1>&2
exit_nicely exit_nicely
fi fi
echo "Setting password" echo "Setting password"

View File

@ -8,7 +8,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.8 2000/05/26 03:15:18 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.9 2000/11/11 22:59:46 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -50,8 +50,8 @@ do
break;; break;;
-*) -*)
echo "$CMDNAME: unrecognized option $badparm" echo "$CMDNAME: invalid option: $1" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
;; ;;
*) *)
@ -66,16 +66,18 @@ if [ "$usage" ]; then
echo "$CMDNAME initializes an alternative filesystem location for database creation." echo "$CMDNAME initializes an alternative filesystem location for database creation."
echo "" echo ""
echo "Usage:" echo "Usage:"
echo " $CMDNAME <location>" echo " $CMDNAME LOCATION"
echo "" echo
echo "Please read the description of the CREATE DATABASE command for details."
echo
echo "Report bugs to <pgsql-bugs@postgresql.org>." echo "Report bugs to <pgsql-bugs@postgresql.org>."
exit 0 exit 0
fi fi
if [ -z "$Location" ]; then if [ -z "$Location" ]; then
echo "$CMDNAME: missing required argument <location>" echo "$CMDNAME: missing required argument LOCATION" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
fi fi
@ -99,7 +101,7 @@ echo "$Location" | grep '/' >/dev/null 2>&1
if [ "$?" -ne 0 -a ! -d "$Location" ]; then if [ "$?" -ne 0 -a ! -d "$Location" ]; then
PGALTDATA=`printenv $Location 2> /dev/null` PGALTDATA=`printenv $Location 2> /dev/null`
if [ -z "$PGALTDATA" ]; then if [ -z "$PGALTDATA" ]; then
echo "$CMDNAME: environment variable $Location not set" echo "$CMDNAME: environment variable $Location not set" 1>&2
exit 1 exit 1
fi fi
haveenv=t haveenv=t
@ -126,8 +128,8 @@ if [ ! -d $PGALTDATA ]; then
echo "Creating directory $PGALTDATA" echo "Creating directory $PGALTDATA"
mkdir "$PGALTDATA" mkdir "$PGALTDATA"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: could not create $PGALTDATA" echo "$CMDNAME: could not create $PGALTDATA" 1>&2
echo "Make sure $PGALTDATA is a valid path and that you have permission to access it." echo "Make sure $PGALTDATA is a valid path and that you have permission to access it." 1>&2
exit_nicely exit_nicely
fi fi
else else
@ -140,8 +142,8 @@ if [ ! -d $PGALTDATA/base ]; then
echo "Creating directory $PGALTDATA/base" echo "Creating directory $PGALTDATA/base"
mkdir "$PGALTDATA/base" mkdir "$PGALTDATA/base"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: could not create $PGALTDATA/base" echo "$CMDNAME: could not create $PGALTDATA/base" 1>&2
echo "Make sure $PGALTDATA/base is a valid path and that you have permission to access it." echo "Make sure $PGALTDATA/base is a valid path and that you have permission to access it." 1>&2
exit_nicely exit_nicely
fi fi
else else

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.5 2000/03/25 14:44:41 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.6 2000/11/11 22:59:47 petere Exp $
# #
CMDNAME=`basename $0` CMDNAME=`basename $0`
@ -20,8 +20,10 @@ fi
if [ "$USER" = 'root' -o "$LOGNAME" = 'root' ] if [ "$USER" = 'root' -o "$LOGNAME" = 'root' ]
then then
(
echo "You cannot run $CMDNAME as root. Please log in (using, e.g., 'su')" echo "You cannot run $CMDNAME as root. Please log in (using, e.g., 'su')"
echo "as the (unprivileged) user that owned the server process." echo "as the (unprivileged) user that owned the server process."
) 1>&2
exit 1 exit 1
fi fi
@ -42,7 +44,7 @@ if [ `uname` = 'Linux' ]; then
did_anything= did_anything=
if ps x | grep -s 'postmaster' >/dev/null 2>&1 ; then if ps x | grep -s 'postmaster' >/dev/null 2>&1 ; then
echo "$CMDNAME: You still have a postmaster running." echo "$CMDNAME: You still have a postmaster running." 1>&2
exit 1 exit 1
fi fi

View File

@ -7,7 +7,7 @@
# Author: Peter Eisentraut <peter_e@gmx.net> # Author: Peter Eisentraut <peter_e@gmx.net>
# Public domain # Public domain
# $Header: /cvsroot/pgsql/src/bin/pg_config/Attic/pg_config.sh,v 1.1 2000/10/10 22:01:55 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/pg_config/Attic/pg_config.sh,v 1.2 2000/11/11 22:59:47 petere Exp $
me=`basename $0` me=`basename $0`
@ -27,18 +27,18 @@ Operation modes:
--bindir show location of user executables --bindir show location of user executables
--includedir show location of C header files --includedir show location of C header files
--libdir show location of object code libraries --libdir show location of object code libraries
--configure show options given to \`configure' script when --configure show options given to 'configure' script when
PostgreSQL was built PostgreSQL was built
--version show PostgreSQL version and exit --version show PostgreSQL version and exit
Report bugs to <pgsql-bugs@postgresql.org>." Report bugs to <pgsql-bugs@postgresql.org>."
advice="\ advice="\
Try \`$me --help' for more information." Try '$me --help' for more information."
if test $# -eq 0 ; then if test $# -eq 0 ; then
echo "$me: argument required" echo "$me: argument required" 1>&2
echo "$advice" echo "$advice" 1>&2
exit 1 exit 1
fi fi
@ -56,8 +56,8 @@ do
exit 0;; exit 0;;
--help|-\?) echo "$help" --help|-\?) echo "$help"
exit 0;; exit 0;;
*) echo "$me: invalid argument: $opt" *) echo "$me: invalid argument: $opt" 1>&2
echo "$advice" echo "$advice" 1>&2
exit 1;; exit 1;;
esac esac
done done

View File

@ -11,7 +11,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.8 2000/02/10 20:08:58 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.9 2000/11/11 22:59:48 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -88,8 +88,8 @@ do
MB=`echo $1 | sed 's/^--encoding=//'` MB=`echo $1 | sed 's/^--encoding=//'`
;; ;;
-*) -*)
echo "$CMDNAME: invalid option: $1" echo "$CMDNAME: invalid option: $1" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
;; ;;
*) *)
@ -118,6 +118,8 @@ if [ "$usage" ]; then
echo " -W, --password Prompt for password" echo " -W, --password Prompt for password"
echo " -e, --echo Show the query being sent to the backend" echo " -e, --echo Show the query being sent to the backend"
echo " -q, --quiet Don't write any messages" echo " -q, --quiet Don't write any messages"
echo
echo "By default, a database with the same name as the current user is created."
echo echo
echo "Report bugs to <pgsql-bugs@postgresql.org>." echo "Report bugs to <pgsql-bugs@postgresql.org>."
exit 0 exit 0
@ -129,7 +131,7 @@ then
mbcode=`${PATHNAME}pg_encoding "$MB"` mbcode=`${PATHNAME}pg_encoding "$MB"`
if [ -z "$mbcode" ] if [ -z "$mbcode" ]
then then
echo "$CMDNAME: \"$MB\" is not a valid encoding name" echo "$CMDNAME: \"$MB\" is not a valid encoding name" 1>&2
exit 1 exit 1
fi fi
fi fi
@ -155,7 +157,7 @@ withstring=
${PATHNAME}psql $PSQLOPT -d template1 -c "CREATE DATABASE \"$dbname\"$withstring" ${PATHNAME}psql $PSQLOPT -d template1 -c "CREATE DATABASE \"$dbname\"$withstring"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: database creation failed" echo "$CMDNAME: database creation failed" 1>&2
exit 1 exit 1
fi fi
@ -166,7 +168,7 @@ dbcomment=`echo $dbcomment | sed "s/'/\\\\\'/g"`
${PATHNAME}psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'" ${PATHNAME}psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: comment creation failed (database was created)" echo "$CMDNAME: comment creation failed (database was created)" 1>&2
exit 1 exit 1
fi fi

View File

@ -8,7 +8,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.16 2000/09/29 17:17:34 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.17 2000/11/11 22:59:48 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -98,8 +98,8 @@ do
;; ;;
-*) -*)
echo "$CMDNAME: invalid option: $1" echo "$CMDNAME: invalid option: $1" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
;; ;;
*) *)
@ -121,7 +121,7 @@ if [ "$usage" ]; then
echo "$CMDNAME installs a procedural language into a PostgreSQL database." echo "$CMDNAME installs a procedural language into a PostgreSQL database."
echo echo
echo "Usage:" echo "Usage:"
echo " $CMDNAME [options] [langname [dbname]]" echo " $CMDNAME [options] [langname] dbname"
echo echo
echo "Options:" echo "Options:"
echo " -h, --host=HOSTNAME Database server host" echo " -h, --host=HOSTNAME Database server host"
@ -132,6 +132,9 @@ if [ "$usage" ]; then
echo " -L, --pglib=DIRECTORY Find language interpreter file in DIRECTORY" echo " -L, --pglib=DIRECTORY Find language interpreter file in DIRECTORY"
echo " -l, --list Show a list of currently installed languages" echo " -l, --list Show a list of currently installed languages"
echo echo
echo "If 'langname' is not specified, you will be prompted interactively."
echo "A database name must be specified."
echo
echo "Report bugs to <pgsql-bugs@postgresql.org>." echo "Report bugs to <pgsql-bugs@postgresql.org>."
exit 0 exit 0
fi fi
@ -141,8 +144,8 @@ fi
# Check that we have a database # Check that we have a database
# ---------- # ----------
if [ -z "$dbname" ]; then if [ -z "$dbname" ]; then
echo "$CMDNAME: missing required argument database name" echo "$CMDNAME: missing required argument database name" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
fi fi
@ -200,8 +203,8 @@ case "$langname" in
object="plperl" object="plperl"
;; ;;
*) *)
echo "$CMDNAME: unsupported language '$langname'" echo "$CMDNAME: unsupported language '$langname'" 1>&2
echo "Supported languages are 'plpgsql', 'pltcl', and 'plperl'." echo "Supported languages are 'plpgsql', 'pltcl', 'pltclu', and 'plperl'." 1>&2
exit 1 exit 1
;; ;;
esac esac
@ -213,14 +216,17 @@ DLSUFFIX='@DLSUFFIX@'
# in PGLIB # in PGLIB
# ---------- # ----------
if [ ! -f "$PGLIB/$object$DLSUFFIX" ]; then if [ ! -f "$PGLIB/$object$DLSUFFIX" ]; then
echo "$CMDNAME: cannot find the file \`$PGLIB/$langname$DLSUFFIX'" (
echo "$CMDNAME: cannot find the file '$PGLIB/$langname$DLSUFFIX'"
echo "" echo ""
echo "This file contains the call handler for $lancomp. By default," echo "This file contains the call handler for $lancomp. By default,"
echo "only PL/pgSQL is built and installed; other languages must be" echo "only PL/pgSQL is built and installed; other languages must be"
echo "explicitly enabled at configure time." echo "explicitly enabled at configure time."
echo "" echo ""
echo "To install PL/Tcl, make sure the option --with-tcl is given to" echo "To install PL/Tcl, make sure the option --with-tcl is given to"
echo "configure, then recompile and install." echo "configure, then recompile and install. To install PL/Perl use"
echo "--with-perl."
) 1>&2
exit 1 exit 1
fi fi
@ -232,11 +238,11 @@ PSQL="${PATHNAME}psql -A -t -q $PSQLOPT -d $dbname -c"
# ---------- # ----------
res=`$PSQL "SELECT oid FROM pg_language WHERE lanname = '$langname'"` res=`$PSQL "SELECT oid FROM pg_language WHERE lanname = '$langname'"`
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: external error" echo "$CMDNAME: external error" 1>&2
exit 1 exit 1
fi fi
if [ "$res" ]; then if [ "$res" ]; then
echo "$CMDNAME: '$langname' is already installed in database $dbname" echo "$CMDNAME: '$langname' is already installed in database $dbname" 1>&2
# separate exit status for "already installed" # separate exit status for "already installed"
exit 2 exit 2
fi fi
@ -246,7 +252,7 @@ fi
# ---------- # ----------
res=`$PSQL "SELECT oid FROM pg_proc WHERE proname = '$handler'"` res=`$PSQL "SELECT oid FROM pg_proc WHERE proname = '$handler'"`
if [ ! -z "$res" ]; then if [ ! -z "$res" ]; then
echo "$CMDNAME: A function named '$handler' already exists. Installation aborted." echo "$CMDNAME: A function named '$handler' already exists. Installation aborted." 1>&2
exit 1 exit 1
fi fi
@ -255,13 +261,13 @@ fi
# ---------- # ----------
$PSQL "CREATE FUNCTION $handler () RETURNS OPAQUE AS '$PGLIB/${object}$DLSUFFIX' LANGUAGE 'newC'" $PSQL "CREATE FUNCTION $handler () RETURNS OPAQUE AS '$PGLIB/${object}$DLSUFFIX' LANGUAGE 'newC'"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: language installation failed" echo "$CMDNAME: language installation failed" 1>&2
exit 1 exit 1
fi fi
$PSQL "CREATE ${trusted}PROCEDURAL LANGUAGE '$langname' HANDLER $handler LANCOMPILER '$lancomp'" $PSQL "CREATE ${trusted}PROCEDURAL LANGUAGE '$langname' HANDLER $handler LANCOMPILER '$lancomp'"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: language installation failed" echo "$CMDNAME: language installation failed" 1>&2
exit 1 exit 1
fi fi

View File

@ -8,7 +8,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.11 2000/06/12 03:40:49 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.12 2000/11/11 22:59:48 petere Exp $
# #
# Note - this should NOT be setuid. # Note - this should NOT be setuid.
# #
@ -109,8 +109,8 @@ do
PwPrompt=t PwPrompt=t
;; ;;
-*) -*)
echo "$CMDNAME: invalid option: $1" echo "$CMDNAME: invalid option: $1" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
;; ;;
*) *)
@ -140,13 +140,16 @@ if [ "$usage" ]; then
echo " -e, --echo Show the query being sent to the backend" echo " -e, --echo Show the query being sent to the backend"
echo " -q, --quiet Don't write any messages" echo " -q, --quiet Don't write any messages"
echo echo
echo "If one of -d, -D, -a, -A, and 'username' is not specified, you will"
echo "be prompted interactively."
echo
echo "Report bugs to <pgsql-bugs@postgresql.org>." echo "Report bugs to <pgsql-bugs@postgresql.org>."
exit 0 exit 0
fi fi
if [ "$SysID" ]; then if [ "$SysID" ]; then
if [ "$SysID" != "`echo $SysID | sed 's/[^0-9]//g'`" ]; then if [ "$SysID" != "`echo $SysID | sed 's/[^0-9]//g'`" ]; then
echo "$CMDNAME: user sysid must be a positive number" echo "$CMDNAME: user sysid must be a positive number" 1>&2
exit 1 exit 1
fi fi
fi fi
@ -176,7 +179,7 @@ if [ "$PwPrompt" ]; then
stty echo >/dev/null 2>&1 stty echo >/dev/null 2>&1
echo echo
if [ "$FirstPw" != "$SecondPw" ]; then if [ "$FirstPw" != "$SecondPw" ]; then
echo "Passwords didn't match." echo "Passwords didn't match." 1>&2
exit 1 exit 1
fi fi
Password=$FirstPw Password=$FirstPw
@ -225,7 +228,7 @@ SUBQUERY=
${PATHNAME}psql -c "$QUERY" -d template1 $PSQLOPT ${PATHNAME}psql -c "$QUERY" -d template1 $PSQLOPT
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: creation of user \"$NewUser\" failed" echo "$CMDNAME: creation of user \"$NewUser\" failed" 1>&2
exit 1 exit 1
fi fi

View File

@ -10,7 +10,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.6 2000/01/19 20:08:36 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.7 2000/11/11 22:59:48 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -82,8 +82,8 @@ do
forcedel=f forcedel=f
;; ;;
-*) -*)
echo "$CMDNAME: invalid option: $1" echo "$CMDNAME: invalid option: $1" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
;; ;;
*) *)
@ -114,8 +114,8 @@ if [ "$usage" ]; then
fi fi
if [ -z "$dbname" ]; then if [ -z "$dbname" ]; then
echo "$CMDNAME: missing required argument database name" echo "$CMDNAME: missing required argument database name" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
fi fi
@ -134,7 +134,7 @@ dbname=`echo $dbname | sed 's/\"/\\\"/g'`
${PATHNAME}psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\"" ${PATHNAME}psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\""
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: database removal failed" echo "$CMDNAME: database removal failed" 1>&2
exit 1 exit 1
fi fi

View File

@ -8,7 +8,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.7 2000/02/09 20:23:26 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.8 2000/11/11 22:59:48 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -88,8 +88,8 @@ do
;; ;;
-*) -*)
echo "$CMDNAME: invalid option: $1" echo "$CMDNAME: invalid option: $1" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
;; ;;
*) *)
@ -118,6 +118,9 @@ if [ "$usage" ]; then
echo " -d, --dbname=DBNAME Database to remove language from" echo " -d, --dbname=DBNAME Database to remove language from"
echo " -l, --list Show a list of currently installed languages" echo " -l, --list Show a list of currently installed languages"
echo echo
echo "If 'langname' is not specified, you will be prompted interactively."
echo "A database name must be specified."
echo
echo "Report bugs to <pgsql-bugs@postgresql.org>." echo "Report bugs to <pgsql-bugs@postgresql.org>."
exit 0 exit 0
fi fi
@ -133,8 +136,8 @@ fi
# Check that we have a database # Check that we have a database
# ---------- # ----------
if [ -z "$dbname" ]; then if [ -z "$dbname" ]; then
echo "$CMDNAME: missing required argument database name" echo "$CMDNAME: missing required argument database name" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
fi fi
@ -159,13 +162,17 @@ case "$langname" in
lancomp="PL/Tcl" lancomp="PL/Tcl"
handler="pltcl_call_handler" handler="pltcl_call_handler"
;; ;;
pltclu)
lancomp="PL/Tcl (untrusted)"
handler="pltclu_call_handler"
;;
plperl) plperl)
lancomp="PL/Perl" lancomp="PL/Perl"
handler="plperl_call_handler" handler="plperl_call_handler"
;; ;;
*) *)
echo "$CMDNAME: unsupported language '$langname'" echo "$CMDNAME: unsupported language '$langname'" 1>&2
echo "Supported languages are 'plpgsql', 'pltcl', and 'plperl'." echo "Supported languages are 'plpgsql', 'pltcl', 'pltclu', and 'plperl'." 1>&2
exit 1 exit 1
;; ;;
esac esac
@ -179,11 +186,11 @@ PSQL="${PATHNAME}psql -A -t -q $PSQLOPT -d $dbname -c"
# ---------- # ----------
res=`$PSQL "SELECT oid FROM pg_language WHERE lanname = '$langname'"` res=`$PSQL "SELECT oid FROM pg_language WHERE lanname = '$langname'"`
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: external error" echo "$CMDNAME: external error" 1>&2
exit 1 exit 1
fi fi
if [ -z "$res" ]; then if [ -z "$res" ]; then
echo "$CMDNAME: '$langname' is not installed in database $dbname" echo "$CMDNAME: '$langname' is not installed in database $dbname" 1>&2
exit 1 exit 1
fi fi
@ -193,12 +200,12 @@ fi
# ---------- # ----------
res=`$PSQL "SELECT COUNT(proname) FROM pg_proc P, pg_language L WHERE P.prolang = L.oid AND L.lanname = '$langname'"` res=`$PSQL "SELECT COUNT(proname) FROM pg_proc P, pg_language L WHERE P.prolang = L.oid AND L.lanname = '$langname'"`
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: external error" echo "$CMDNAME: external error" 1>&2
exit 1 exit 1
fi fi
if [ $res -ne 0 ]; then if [ $res -ne 0 ]; then
echo "$CMDNAME: There are $res functions/trigger procedures declared in language" echo "$CMDNAME: There are $res functions/trigger procedures declared in language" 1>&2
echo "$lancomp. Language not removed." echo "$lancomp. Language not removed." 1>&2
exit 1 exit 1
fi fi
@ -207,14 +214,13 @@ fi
# ---------- # ----------
$PSQL "DROP PROCEDURAL LANGUAGE '$langname'" $PSQL "DROP PROCEDURAL LANGUAGE '$langname'"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: language removal failed" echo "$CMDNAME: language removal failed" 1>&2
exit 1 exit 1
fi fi
$PSQL "DROP FUNCTION $handler()" $PSQL "DROP FUNCTION $handler()"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: language removal failed" echo "$CMDNAME: language removal failed" 1>&2
exit 1 exit 1
fi fi
echo "Ok"
exit 0 exit 0

View File

@ -8,7 +8,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.6 2000/01/19 20:08:36 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.7 2000/11/11 22:59:48 petere Exp $
# #
# Note - this should NOT be setuid. # Note - this should NOT be setuid.
# #
@ -84,8 +84,8 @@ do
forcedel=f forcedel=f
;; ;;
-*) -*)
echo "$CMDNAME: invalid option: $1" echo "$CMDNAME: invalid option: $1" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
;; ;;
*) *)
@ -139,7 +139,7 @@ DelUser=`echo $DelUser | sed 's/\"/\\\"/g'`
${PATHNAME}psql $PSQLOPT -d template1 -c "DROP USER \"$DelUser\"" ${PATHNAME}psql $PSQLOPT -d template1 -c "DROP USER \"$DelUser\""
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: deletion of user \"$DelUser\" failed" echo "$CMDNAME: deletion of user \"$DelUser\" failed" 1>&2
exit 1 exit 1
fi fi

View File

@ -11,7 +11,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.9 2000/01/19 20:08:36 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.10 2000/11/11 22:59:48 petere Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -101,8 +101,8 @@ do
;; ;;
-*) -*)
echo "$CMDNAME: invalid option: $1" echo "$CMDNAME: invalid option: $1" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
;; ;;
*) *)
@ -131,20 +131,22 @@ if [ "$usage" ]; then
echo " -e, --echo Show the command being sent to the backend" echo " -e, --echo Show the command being sent to the backend"
echo " -q, --quiet Don't write any output" echo " -q, --quiet Don't write any output"
echo echo
echo "Read the description of the SQL command VACUUM for details."
echo
echo "Report bugs to <pgsql-bugs@postgresql.org>." echo "Report bugs to <pgsql-bugs@postgresql.org>."
exit 0 exit 0
fi fi
if [ "$alldb" ]; then if [ "$alldb" ]; then
if [ "$dbname" -o "$table" ]; then if [ "$dbname" -o "$table" ]; then
echo "$CMDNAME: cannot vacuum all databases and a specific one at the same time" echo "$CMDNAME: cannot vacuum all databases and a specific one at the same time" 1>&2
exit 1 exit 1
fi fi
dbname=`${PATHNAME}psql $PSQLOPT -q -t -A -d template1 -c 'SELECT datname FROM pg_database'` dbname=`${PATHNAME}psql $PSQLOPT -q -t -A -d template1 -c 'SELECT datname FROM pg_database'`
elif [ -z "$dbname" ]; then elif [ -z "$dbname" ]; then
echo "$CMDNAME: missing required argument database name" echo "$CMDNAME: missing required argument database name" 1>&2
echo "Try -? for help." echo "Try '$CMDNAME -?' for help." 1>&2
exit 1 exit 1
fi fi
@ -155,7 +157,7 @@ do
done done
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: vacuum failed" echo "$CMDNAME: vacuum failed" 1>&2
exit 1 exit 1
fi fi