droplang had same problem as createlang; default are backwards and did
authorBruce Momjian <[email protected]>
Thu, 3 Jan 2002 06:09:02 +0000 (06:09 +0000)
committerBruce Momjian <[email protected]>
Thu, 3 Jan 2002 06:09:02 +0000 (06:09 +0000)
not work.  Fixed to match createlang.

doc/src/sgml/ref/droplang.sgml
src/bin/scripts/droplang

index 0d1a1254afdad6cd8a2a152c2e70158c5414b3a3..e5dcebf9a07d8f3753834966d4878d6ecb78ceb8 100644 (file)
@@ -23,8 +23,8 @@ PostgreSQL documentation
   <cmdsynopsis>
    <command>droplang</command>
    <arg rep="repeat"><replaceable>connection-options</replaceable></arg>
-   <arg><replaceable>langname</replaceable></arg>
-   <arg choice="plain"><replaceable>dbname</replaceable></arg>
+   <arg choice="plain"><replaceable>langname</replaceable></arg>
+   <arg><replaceable>dbname</replaceable></arg>
    <sbr>
    <command>droplang</command>
    <arg rep="repeat"><replaceable>connection-options</replaceable></arg>
@@ -45,9 +45,6 @@ PostgreSQL documentation
       <listitem>
        <para>
        Specifies the name of the backend programming language to be removed.
-       <application>droplang</application> will prompt for
-       <replaceable class="parameter">langname</replaceable>
-       if it is not specified on the command line.
        </para>
       </listitem>
      </varlistentry>
@@ -57,6 +54,8 @@ PostgreSQL documentation
       <listitem>
        <para>
        Specifies from which database the language should be removed.
+        The default is to create a database with the same name as the
+        current system user.
        </para>
       </listitem>
      </varlistentry>
index af931f19287aa818aa4dd2b9a378410128d3f295..4d41145ea19ee9aaaa1d50da58d6c781561dd3db 100644 (file)
@@ -111,7 +111,7 @@ if [ "$usage" ]; then
         echo "$CMDNAME removes a procedural language from a database."
        echo
        echo "Usage:"
-        echo "  $CMDNAME [options] [langname [dbname]]"
+        echo "  $CMDNAME [options] langname [dbname]"
         echo
        echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
@@ -121,14 +121,24 @@ if [ "$usage" ]; then
        echo "  -d, --dbname=DBNAME             Database to remove language from"
        echo "  -l, --list                      Show a list of currently installed languages"
         echo
-        echo "If 'langname' is not specified, you will be prompted interactively."
-        echo "A database name must be specified."
-        echo
        echo "Report bugs to <[email protected]>."
        exit 0
 fi
 
 
+if [ -z "$dbname" ]; then
+        if [ "$PGUSER" ]; then
+                dbname="$PGUSER"
+        else
+                dbname=`${PATHNAME}pg_id -u -n`
+        fi
+        [ "$?" -ne 0 ] && exit 1
+fi
+
+
+# ----------
+# List option, doesn't need langname
+# ----------
 if [ "$list" ]; then
        sqlcmd="SELECT lanname as \"Name\", lanpltrusted as \"Trusted?\" FROM pg_language WHERE lanispl = TRUE"
        if [ "$showsql" = yes ]; then
@@ -140,23 +150,14 @@ fi
 
 
 # ----------
-# Check that we have a database
+# We can't go any farther without a langname
 # ----------
-if [ -z "$dbname" ]; then
-       echo "$CMDNAME: missing required argument database name" 1>&2
+if [ -z "$langname" ]; then
+       echo "$CMDNAME: missing required argument language name" 1>&2
         echo "Try '$CMDNAME --help' for help." 1>&2
        exit 1
 fi
 
-
-# ----------
-# If not given on the commandline, ask for the language
-# ----------
-if [ -z "$langname" ]; then
-       $ECHO_N "Language to remove from database $dbname: "$ECHO_C
-       read langname
-fi
-
 PSQL="${PATHNAME}psql -A -t -q $PSQLOPT -d $dbname -c"