Skip to content

Commit a4ee277

Browse files
committed
droplang had same problem as createlang; default are backwards and did
not work. Fixed to match createlang.
1 parent f9b792c commit a4ee277

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

doc/src/sgml/ref/droplang.sgml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/droplang.sgml,v 1.15 2001/12/08 03:24:36 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/droplang.sgml,v 1.16 2002/01/03 06:09:01 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -23,8 +23,8 @@ PostgreSQL documentation
2323
<cmdsynopsis>
2424
<command>droplang</command>
2525
<arg rep="repeat"><replaceable>connection-options</replaceable></arg>
26-
<arg><replaceable>langname</replaceable></arg>
27-
<arg choice="plain"><replaceable>dbname</replaceable></arg>
26+
<arg choice="plain"><replaceable>langname</replaceable></arg>
27+
<arg><replaceable>dbname</replaceable></arg>
2828
<sbr>
2929
<command>droplang</command>
3030
<arg rep="repeat"><replaceable>connection-options</replaceable></arg>
@@ -45,9 +45,6 @@ PostgreSQL documentation
4545
<listitem>
4646
<para>
4747
Specifies the name of the backend programming language to be removed.
48-
<application>droplang</application> will prompt for
49-
<replaceable class="parameter">langname</replaceable>
50-
if it is not specified on the command line.
5148
</para>
5249
</listitem>
5350
</varlistentry>
@@ -57,6 +54,8 @@ PostgreSQL documentation
5754
<listitem>
5855
<para>
5956
Specifies from which database the language should be removed.
57+
The default is to create a database with the same name as the
58+
current system user.
6059
</para>
6160
</listitem>
6261
</varlistentry>

src/bin/scripts/droplang

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
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
111111
echo "$CMDNAME removes a procedural language from a database."
112112
echo
113113
echo "Usage:"
114-
echo " $CMDNAME [options] [langname [dbname]]"
114+
echo " $CMDNAME [options] langname [dbname]"
115115
echo
116116
echo "Options:"
117117
echo " -h, --host=HOSTNAME Database server host"
@@ -121,14 +121,24 @@ if [ "$usage" ]; then
121121
echo " -d, --dbname=DBNAME Database to remove language from"
122122
echo " -l, --list Show a list of currently installed languages"
123123
echo
124-
echo "If 'langname' is not specified, you will be prompted interactively."
125-
echo "A database name must be specified."
126-
echo
127124
echo "Report bugs to <pgsql-bugs@postgresql.org>."
128125
exit 0
129126
fi
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+
# ----------
132142
if [ "$list" ]; then
133143
sqlcmd="SELECT lanname as \"Name\", lanpltrusted as \"Trusted?\" FROM pg_language WHERE lanispl = TRUE"
134144
if [ "$showsql" = yes ]; then
@@ -140,23 +150,14 @@ fi
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 argument database name" 1>&2
155+
if [ -z "$langname" ]; then
156+
echo "$CMDNAME: missing required argument language name" 1>&2
147157
echo "Try '$CMDNAME --help' for help." 1>&2
148158
exit 1
149159
fi
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-
160161
PSQL="${PATHNAME}psql -A -t -q $PSQLOPT -d $dbname -c"
161162

162163

0 commit comments

Comments
 (0)