77# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88# Portions Copyright (c) 1994, Regents of the University of California
99#
10- # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.18 2001/09/30 22:17:51 momjian Exp $
10+ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.19 2002/01/03 06:09:02 momjian Exp $
1111#
1212# -------------------------------------------------------------------------
1313
@@ -111,7 +111,7 @@ if [ "$usage" ]; then
111111echo " $CMDNAME removes a procedural language from a database."
112112echo
113113echo " Usage:"
114- echo " $CMDNAME [options][ langname [dbname] ]"
114+ echo " $CMDNAME [options] langname [dbname]"
115115echo
116116echo " Options:"
117117echo " -h, --host=HOSTNAME Database server host"
@@ -121,14 +121,24 @@ if [ "$usage" ]; then
121121echo " -d, --dbname=DBNAME Database to remove language from"
122122echo " -l, --list Show a list of currently installed languages"
123123echo
124- echo " If 'langname' is not specified, you will be prompted interactively."
125- echo " A database name must be specified."
126- echo
127124echo " Report bugs to <pgsql-bugs@postgresql.org>."
128125exit 0
129126fi
130127
131128
129+ if [-z " $dbname " ]; then
130+ if [" $PGUSER " ]; then
131+ dbname=" $PGUSER "
132+ else
133+ dbname=` ${PATHNAME} pg_id -u -n`
134+ fi
135+ [" $? " -ne 0 ]&& exit 1
136+ fi
137+
138+
139+ # ----------
140+ # List option, doesn't need langname
141+ # ----------
132142if [" $list " ]; then
133143sqlcmd=" SELECT lanname as\" Name\" , lanpltrusted as\" Trusted?\" FROM pg_language WHERE lanispl = TRUE"
134144if [" $showsql " = yes ]; then
140150
141151
142152# ----------
143- # Check that we have a database
153+ # We can't go any farther without a langname
144154# ----------
145- if [-z " $dbname " ]; then
146- echo " $CMDNAME : missing required argumentdatabase name" 1>&2
155+ if [-z " $langname " ]; then
156+ echo " $CMDNAME : missing required argumentlanguage name" 1>&2
147157echo " Try '$CMDNAME --help' for help." 1>&2
148158exit 1
149159fi
150160
151-
152- # ----------
153- # If not given on the commandline, ask for the language
154- # ----------
155- if [-z " $langname " ]; then
156- $ECHO_N " Language to remove from database$dbname :" $ECHO_C
157- read langname
158- fi
159-
160161PSQL=" ${PATHNAME} psql -A -t -q$PSQLOPT -d$dbname -c"
161162
162163