]> granicus.if.org Git - postgresql/commitdiff
another round of user interface cleanups
authorPeter Eisentraut <peter_e@gmx.net>
Wed, 19 Jan 2000 20:08:36 +0000 (20:08 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Wed, 19 Jan 2000 20:08:36 +0000 (20:08 +0000)
removed pg_id
fixed a few bugs in the scripts

19 files changed:
doc/src/sgml/ref/createlang.sgml
doc/src/sgml/ref/droplang.sgml
src/bin/Makefile
src/bin/initdb/initdb.sh
src/bin/initlocation/initlocation.sh
src/bin/ipcclean/ipcclean.sh
src/bin/pg_dump/pg_dump.c
src/bin/pg_id/Makefile [deleted file]
src/bin/pg_id/pg_id.c [deleted file]
src/bin/psql/common.c
src/bin/psql/help.c
src/bin/psql/startup.c
src/bin/scripts/createdb
src/bin/scripts/createlang.sh
src/bin/scripts/createuser
src/bin/scripts/dropdb
src/bin/scripts/droplang
src/bin/scripts/dropuser
src/bin/scripts/vacuumdb

index 309a80266df19c791558f7e40142c410f7047336..71de0268840cc59f69893679a56b1ce325fc1185 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/createlang.sgml,v 1.3 1999/12/05 20:02:42 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/createlang.sgml,v 1.4 2000/01/19 20:08:22 petere Exp $
 Postgres documentation
 -->
 
@@ -114,16 +114,6 @@ createlang [ <replaceable class="parameter">connection options</replaceable> ] -
       </listitem>
      </varlistentry>
 
-     <varlistentry>
-      <term>-e, --echo</term>
-      <listitem>
-       <para>
-        Echo the commands that <application>createlang</application> generates
-       and sends to the backend.
-       </para>
-      </listitem>
-     </varlistentry>
-
     </variablelist>
    </para>
   </refsect2>
@@ -142,9 +132,6 @@ createlang [ <replaceable class="parameter">connection options</replaceable> ] -
     for details. Check also under <xref linkend="APP-PSQL" endterm="APP-PSQL-title">
     for more possibilities.
    </para>
-   <para>
-    No output is generated if <application>createlang</application> succeeds.
-   </para>
   </refsect2>
  </refsynopsisdiv>
  
index e367ed254c73414a297ccfdc221d7a935ddc70a7..65b2cea8bd47b2dc6fdff2c0cf5a8b549e9da70b 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/droplang.sgml,v 1.1 1999/12/05 20:04:39 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/droplang.sgml,v 1.2 2000/01/19 20:08:22 petere Exp $
 Postgres documentation
 -->
 
@@ -114,16 +114,6 @@ droplang [ <replaceable class="parameter">connection options</replaceable> ] --l
       </listitem>
      </varlistentry>
 
-     <varlistentry>
-      <term>-e, --echo</term>
-      <listitem>
-       <para>
-        Echo the commands that <application>droplang</application> generates
-       and sends to the backend.
-       </para>
-      </listitem>
-     </varlistentry>
-
     </variablelist>
    </para>
   </refsect2>
@@ -142,9 +132,6 @@ droplang [ <replaceable class="parameter">connection options</replaceable> ] --l
     for details. Check also under <xref linkend="APP-PSQL" endterm="APP-PSQL-title">
     for more possibilities.
    </para>
-   <para>
-    No output is generated if <application>droplang</application> succeeds.
-   </para>
   </refsect2>
  </refsynopsisdiv>
  
index a845b6148ccd69c35f7be265fd5de5c05031af09..451fab4bff3382ba598e4be089e272f5bc03d4bf 100644 (file)
@@ -1,13 +1,13 @@
 #-------------------------------------------------------------------------
 #
 # Makefile
-#    Makefile for src/bin (utility programs)
+#    Makefile for src/bin (client programs)
 #
 # Copyright (c) 1994, Regents of the University of California
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.23 2000/01/19 02:58:59 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.24 2000/01/19 20:08:23 petere Exp $
 #
 #-------------------------------------------------------------------------
 
index 02818be924f9d071ad6ef1181a57f77f1d365aa6..6db416e1c1a4586cd247a85dcbfa3cae34ecad36 100644 (file)
@@ -26,7 +26,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.80 2000/01/18 00:03:35 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.81 2000/01/19 20:08:24 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -235,7 +235,7 @@ if [ "$usage" ]; then
         echo "  -d, --debug                 Generate lots of debugging output"
         echo "  -n, --noclean               Do not clean up after errors"
        echo     
-        echo "Report bugs to <bugs@postgresql.org>."
+        echo "Report bugs to <pgsql-bugs@postgresql.org>."
        exit 0
 fi
 
index 07b9ed69e2ae148336b54750f92eeb5a29f1e2d7..277d6cbf2b48aa9bf4c81f8349b4a6639b6714b5 100644 (file)
@@ -8,7 +8,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.4 2000/01/18 00:03:36 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/initlocation/Attic/initlocation.sh,v 1.5 2000/01/19 20:08:25 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -68,7 +68,7 @@ if [ "$usage" ]; then
        echo "Usage:"
         echo "  $CMDNAME <location>"
        echo ""
-        echo "Report bugs to <bugs@postgresql.org>."
+        echo "Report bugs to <pgsql-bugs@postgresql.org>."
        exit 0
 fi
 
index 616ec3c96415f60e9c840dae3f6caa2ad6349a18..87acbecc8ab1add07e236407d6050488a912cfeb 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.3 2000/01/18 00:03:36 petere Exp $
+# $Header: /cvsroot/pgsql/src/bin/ipcclean/Attic/ipcclean.sh,v 1.4 2000/01/19 20:08:27 petere Exp $
 #
 
 CMDNAME=`basename $0`
@@ -13,7 +13,7 @@ if [ "$1" = '-?' -o "$1" = "--help" ]; then
     echo
     echo "Note: Since the utilities underlying this script are very different"
     echo "from platform to platform, chances are that it might not work on"
-    echo "yours. If that is the case, please write to <bugs@postgresql.org>"
+    echo "yours. If that is the case, please write to <pgsql-bugs@postgresql.org>"
     echo "so that your platform can be supported in the future."
     exit 0
 fi
index 157aba864d256b8cd1796657f398bce68c60d398..e2ebcbcb0c87bf8295cab5df419c2db9ace5a443 100644 (file)
@@ -21,7 +21,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.136 2000/01/19 02:58:59 petere Exp $
+ *       $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.137 2000/01/19 20:08:30 petere Exp $
  *
  * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
  *
@@ -167,7 +167,7 @@ help(const char *progname)
         );
 #endif
     puts("If no database name is not supplied, then the PGDATABASE environment\nvariable value is used.\n");
-    puts("Report bugs to <bugs@postgresql.org>.");
+    puts("Report bugs to <pgsql-bugs@postgresql.org>.");
 }
 
 
diff --git a/src/bin/pg_id/Makefile b/src/bin/pg_id/Makefile
deleted file mode 100644 (file)
index 0919f2f..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#-------------------------------------------------------------------------
-#
-# Makefile.inc--
-#    Makefile for bin/pg_id
-#
-# Copyright (c) 1994, Regents of the University of California
-#
-#
-# IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/Makefile,v 1.12 1999/01/17 06:19:10 momjian Exp $
-#
-#-------------------------------------------------------------------------
-
-SRCDIR= ../..
-include ../../Makefile.global
-
-OBJS= pg_id.o
-
-#
-# And where libpq goes, so goes the authentication stuff...
-#
-ifdef KRBVERS
-LDFLAGS+= $(KRBLIBS)
-CFLAGS+= $(KRBFLAGS)
-endif
-
-all: pg_id
-
-pg_id: $(OBJS) $(LIBPQDIR)/libpq.a
-       $(CC) -o pg_id -L$(LIBPQDIR) $(OBJS) -lpq $(LDFLAGS)
-
-$(LIBPQDIR)/libpq.a:
-       $(MAKE) -C $(LIBPQDIR) libpq.a
-
-install: pg_id
-       $(INSTALL) $(INSTL_EXE_OPTS) pg_id$(X) $(BINDIR)/pg_id$(X)
-
-depend dep:
-       $(CC) -MM $(CFLAGS) *.c >depend
-
-clean: 
-       rm -f pg_id$(X) $(OBJS) 
-
-ifeq (depend,$(wildcard depend))
-include depend
-endif
diff --git a/src/bin/pg_id/pg_id.c b/src/bin/pg_id/pg_id.c
deleted file mode 100644 (file)
index 70da5f5..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * pg_id.c
- *       Print the user ID for the login name passed as argument,
- *       or the real user ID of the caller if no argument.  If the
- *       login name doesn't exist, print "NOUSER" and exit 1.
- *
- * Copyright (c) 1994, Regents of the University of California
- *
- *
- * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.9 1999/07/19 02:27:09 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <pwd.h>
-
-#include "postgres.h"
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
-
-int
-main(int argc, char **argv)
-{
-       struct passwd *pw;
-       int                     ch;
-       extern int      optind;
-
-       while ((ch = getopt(argc, argv, "")) != EOF)
-               switch (ch)
-               {
-                       case '?':
-                       default:
-                               fprintf(stderr, "usage: pg_id [login]\n");
-                               exit(1);
-               }
-       argc -= optind;
-       argv += optind;
-
-       if (argc > 0)
-       {
-               if (argc > 1)
-               {
-                       fprintf(stderr, "usage: pg_id [login]\n");
-                       exit(1);
-               }
-               if ((pw = getpwnam(argv[0])) == NULL)
-               {
-                       printf("NOUSER\n");
-                       exit(1);
-               }
-               printf("%ld\n", (long) pw->pw_uid);
-       }
-       else
-               printf("%ld\n", (long) getuid());
-
-       exit(0);
-}
index 0565d0cac21d9064395e8883875fd83bf80c5822..c5a2e78af7dcced5bac8ec641f22468d61a10c4a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Team
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.9 2000/01/18 23:30:23 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.10 2000/01/19 20:08:33 petere Exp $
  */
 #include <c.h>
 #include "common.h"
@@ -146,7 +146,7 @@ psql_error(const char *fmt, ...)
         fflush(pset.queryFout);
 
     if (pset.inputfile)
-        fprintf(stderr, "%s:%u: ", pset.inputfile ? pset.inputfile : pset.progname, pset.lineno);
+        fprintf(stderr, "%s:%s:%u: ", pset.progname, pset.inputfile, pset.lineno);
     va_start(ap, fmt);
     vfprintf(stderr, fmt, ap);
     va_end(ap);
index 04690a1303c4084ae65148d7a227dd21b1a18ecf..7b1ce4945859b14fd3f262fd2e6c6230852f3fa7 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Team
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.11 2000/01/18 23:30:23 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.12 2000/01/19 20:08:34 petere Exp $
  */
 #include <c.h>
 #include "help.h"
@@ -129,7 +129,7 @@ usage(void)
     puts(  "(for SQL commands) from within psql, or consult the psql section in");
     puts(  "the PostgreSQL manual, which accompanies the distribution and is also");
     puts(  "available at <http://www.postgresql.org>.");
-    puts(  "Report bugs to <bugs@postgresql.org>.");
+    puts(  "Report bugs to <pgsql-bugs@postgresql.org>.");
 
 #ifndef WIN32
        if (pw)
index 1c31cb4756390df4dcdc095aa2895ff0e1cec825..4c16dae9d7ed4f556c8e609847312659d054d6b8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Team
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.16 2000/01/18 23:30:24 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/startup.c,v 1.17 2000/01/19 20:08:34 petere Exp $
  */
 #include <c.h>
 
@@ -205,10 +205,18 @@ main(int argc, char **argv)
                successResult = process_file(options.action_string) ? 0 : 1;
        /* process slash command if one was given to -c */
        else if (options.action == ACT_SINGLE_SLASH)
+    {
+        if (GetVariable(pset.vars, "ECHO") && strcmp(GetVariable(pset.vars, "ECHO"), "full")==0)
+            puts(options.action_string);
                successResult = HandleSlashCmds(options.action_string, NULL, NULL) != CMD_ERROR ? 0 : 1;
+    }
        /* If the query given to -c was a normal one, send it */
        else if (options.action == ACT_SINGLE_QUERY)
+    {
+        if (GetVariable(pset.vars, "ECHO") && strcmp(GetVariable(pset.vars, "ECHO"), "full")==0)
+            puts(options.action_string);
                successResult = SendQuery( options.action_string) ? 0 : 1;
+    }
        /* or otherwise enter interactive main loop */
        else
     {
index 490edb196e522876b9dbfe816e4a13d4c5a6bebb..3fba2ae0e59626e0600efdd44aeb7f9dd9f58c64 100644 (file)
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.6 2000/01/12 19:36:36 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.7 2000/01/19 20:08:35 petere Exp $
 #
 #-------------------------------------------------------------------------
 
 CMDNAME=`basename $0`
+PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
 
 MB=
 PSQLOPT=
@@ -49,15 +50,12 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --user|--username|-U)
-               PSQLOPT="$PSQLOPT -U '$2'"
+       --username|-U)
+               PSQLOPT="$PSQLOPT -U $2"
                shift;;
         -U*)
                 PSQLOPT="$PSQLOPT $1"
                 ;;
-        --user=*)
-                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
-                ;;
         --username=*)
                 PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
                 ;;
@@ -90,7 +88,7 @@ do
                 MB=`echo $1 | sed 's/^--encoding=//'`
                 ;;
        -*)
-               echo "$CMDNAME: unrecognized option: $1"
+               echo "$CMDNAME: invalid option: $1"
                 echo "Try -? for help."
                exit 1
                ;;
@@ -106,16 +104,22 @@ do
 done
 
 if [ "$usage" ]; then
-       echo "Usage: $CMDNAME [options] dbname [description]"
-       echo ""
+        echo "$CMDNAME creates a PostgreSQL database."
+        echo
+       echo "Usage:"
+        echo "  $CMDNAME [options] dbname [description]"
+        echo
+       echo "Options:"
        echo "  -D, --location=PATH             Alternative place to store the database"
        echo "  -E, --encoding=ENCODING         Multibyte encoding for the database"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
        echo "  -U, --username=USERNAME         Username to connect as"
        echo "  -W, --password                  Prompt for password"
-#???   echo "  -e,          --echo             "
-        echo "  -q,          --quiet            Don't write any messages"
+       echo "  -e, --echo                      Show the query being sent to the backend"
+        echo "  -q, --quiet                     Don't write any messages"
+       echo
+       echo "Report bugs to <pgsql-bugs@postgresql.org>."
        exit 0
 fi
 
@@ -146,7 +150,7 @@ withstring=
 [ "$MB" ] &&         withstring="$withstring ENCODING = '$MB'"
 [ "$withstring" ] && withstring=" WITH$withstring"
 
-psql $PSQLOPT -d template1 -c "CREATE DATABASE \"$dbname\"$withstring"
+${PATHNAME}psql $PSQLOPT -d template1 -c "CREATE DATABASE \"$dbname\"$withstring"
 if [ $? -ne 0 ]; then
        echo "$CMDNAME: database creation failed"
        exit 1
@@ -157,7 +161,7 @@ fi
 
 dbcomment=`echo $dbcomment | sed "s/'/\\\\\'/g"`
 
-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
        echo "$CMDNAME: comment creation failed (database was created)"
        exit 1
index 404a8bd53a7d58a38effa8bee84ac15b78fcf532..b789196652fac6f4d3621247832e86ac57f5c26d 100644 (file)
@@ -8,16 +8,16 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.5 2000/01/12 19:36:36 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.6 2000/01/19 20:08:35 petere Exp $
 #
 #-------------------------------------------------------------------------
 
 CMDNAME=`basename $0`
+PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
 
 PSQLOPT=
 dbname=
 langname=
-echo=
 list=
 
 # Check for echo -n vs echo \c
@@ -65,25 +65,19 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --user|--username|-U)
-               PSQLOPT="$PSQLOPT -U '$2'"
+       --username|-U)
+               PSQLOPT="$PSQLOPT -U $2"
                shift;;
         -U*)
                 PSQLOPT="$PSQLOPT $1"
                 ;;
-        --user=*)
-                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
-                ;;
         --username=*)
                 PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
                 ;;
        --password|-W)
                PSQLOPT="$PSQLOPT -W"
                ;;
-       --echo|-e)
-                echo=t
-               ;;
-       --dbname|--database|-d)
+       --dbname|-d)
                dbname="$2"
                shift;;
         -d*)
@@ -92,9 +86,6 @@ do
         --dbname=*)
                 dbname=`echo $1 | sed 's/^--dbname=//'`
                 ;;
-        --database=*)
-                dbname=`echo $1 | sed 's/^--database=//'`
-                ;;
 # misc options
        --pglib|-L)
                 PGLIB="$2"
@@ -107,7 +98,7 @@ do
                 ;;
 
        -*)
-               echo "$CMDNAME: unrecognized option: $1"
+               echo "$CMDNAME: invalid option: $1"
                 echo "Try -? for help."
                exit 1
                ;;
@@ -123,25 +114,24 @@ do
 done
 
 if [ "$usage" ]; then  
-       echo ""
-       echo "Usage: $CMDNAME [options] [langname [dbname]]"
-       echo ""
+        echo "$CMDNAME installs a procedural language into a PostgreSQL database."
+       echo
+       echo "Usage:"
+        echo "  $CMDNAME [options] [langname [dbname]]"
+        echo
+       echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
        echo "  -U, --username=USERNAME         Username to connect as"
        echo "  -W, --password                  Prompt for password"
        echo "  -d, --dbname=DBNAME             Database to install language in"
-       echo "  -e, --echo                      Create some output about what is happening"
        echo "  -L, --pglib=PGLIB               Find language interpreter in directory PGLIB"
        echo "  -l, --list                      Show a list of currently installed languages"
+        echo
+       echo "Report bugs to <pgsql-bugs@postgresql.org>."
        exit 0
 fi
 
-if [ "$list" ]; then
-        psql $PSQLOPT -d "$dbname" -c "SELECT lanname, lanpltrusted, lancompiler FROM pg_language WHERE lanispl = 't'"
-        exit $?
-fi
-
 
 # ----------
 # Check that we have a database
@@ -153,6 +143,15 @@ if [ -z "$dbname" ]; then
 fi
 
 
+# ----------
+# List option
+# ----------
+if [ "$list" ]; then
+        ${PATHNAME}psql $PSQLOPT -d "$dbname" -P 'title=Procedural languages' -c "SELECT lanname as \"Name\", lanpltrusted as \"Trusted?\", lancompiler as \"Compiler\" FROM pg_language WHERE lanispl = 't'"
+        exit $?
+fi
+
+
 # ----------
 # Check that we have PGLIB
 # ----------
@@ -210,13 +209,7 @@ if [ ! -f $PGLIB/${langname}__DLSUFFIX__ ]; then
 fi
 
 
-if [ "$echo" ]; then
-        PSQLOPT="$PSQLOPT -e"
-else
-        PSQLOPT="$PSQLOPT -q"
-fi
-
-PSQL="psql -A -t $PSQLOPT -d $dbname -c"
+PSQL="${PATHNAME}psql -A -t -q $PSQLOPT -d $dbname -c"
 
 # ----------
 # Make sure the language isn't already installed
@@ -254,4 +247,5 @@ if [ $? -ne 0 ]; then
        exit 1
 fi
 
+echo "Ok"
 exit 0
index bb1aabba3ef1cc4bcf9a4ad91aa829e8931d7c12..4f717c8cb63594270618d26349978e562f1b88de 100644 (file)
@@ -8,13 +8,14 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.7 2000/01/19 02:59:01 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.8 2000/01/19 20:08:36 petere Exp $
 #
 # Note - this should NOT be setuid.
 #
 #-------------------------------------------------------------------------
 
 CMDNAME=`basename $0`
+PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
 
 NewUser=
 SysID=
@@ -64,15 +65,12 @@ do
                 ;;
 # Note: These two specify the user to connect as (like in psql),
 #       not the user you're creating.
-       --user|--username|-U)
-               PSQLOPT="$PSQLOPT -U '$2'"
+       --username|-U)
+               PSQLOPT="$PSQLOPT -U $2"
                shift;;
         -U*)
                 PSQLOPT="$PSQLOPT $1"
                 ;;
-        --user=*)
-                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
-                ;;
         --username=*)
                 PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
                 ;;
@@ -111,7 +109,7 @@ do
                PwPrompt=t
                ;;
        -*)
-               echo "$CMDNAME: unrecognized option: $1"
+               echo "$CMDNAME: invalid option: $1"
                 echo "Try -? for help."
                exit 1
                ;;
@@ -123,8 +121,12 @@ do
 done
 
 if [ "$usage" ]; then  
-       echo "Usage: $CMDNAME [options] [username]"
-       echo ""
+        echo "$CMDNAME creates a new PostgreSQL user."
+        echo
+       echo "Usage:"
+        echo "  $CMDNAME [options] [username]"
+        echo
+       echo "Options:"
        echo "  -d, --createdb                  User can create new databases"
        echo "  -D, --no-createdb               User cannot create databases"
        echo "  -a, --adduser                   User can add new users"
@@ -135,8 +137,10 @@ if [ "$usage" ]; then
        echo "  -p, --port=PORT                 Database server port"
        echo "  -U, --username=USERNAME         Username to connect as (not the one to create)"
        echo "  -W, --password                  Prompt for password to connect"
-#???   echo "  -e,          --echo             "
-        echo "  -q,          --quiet            Don't write any messages"
+       echo "  -e, --echo                      Show the query being sent to the backend"
+        echo "  -q, --quiet                     Don't write any messages"
+       echo
+       echo "Report bugs to <pgsql-bugs@postgresql.org>."
        exit 0
 fi
 
@@ -219,7 +223,7 @@ SUBQUERY=
 [ "$CanAddUser" = t ] &&  QUERY="$QUERY CREATEUSER"
 [ "$CanAddUser" = f ] &&  QUERY="$QUERY NOCREATEUSER"
 
-psql $PSQLOPT -d template1 -c "$QUERY"
+${PATHNAME}psql -c "$QUERY" -d template1 $PSQLOPT
 if [ $? -ne 0 ]; then
        echo "$CMDNAME: creation of user \"$NewUser\" failed"
        exit 1
index a839610317024d32b37a8f53e5af48cfaae1cf01..65c8542e8973c81b1ebbb5b6d26f43ce6d5618f7 100644 (file)
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.5 2000/01/12 19:36:36 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.6 2000/01/19 20:08:36 petere Exp $
 #
 #-------------------------------------------------------------------------
 
 CMDNAME=`basename $0`
+PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
 
 PSQLOPT=
 dbname=
@@ -58,15 +59,12 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --user|--username|-U)
-               PSQLOPT="$PSQLOPT -U '$2'"
+       --username|-U)
+               PSQLOPT="$PSQLOPT -U $2"
                shift;;
         -U*)
                 PSQLOPT="$PSQLOPT $1"
                 ;;
-        --user=*)
-                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
-                ;;
         --username=*)
                 PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
                 ;;
@@ -84,7 +82,8 @@ do
                forcedel=f
                ;;
        -*)
-               echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
+               echo "$CMDNAME: invalid option: $1"
+                echo "Try -? for help."
                exit 1
                ;;
         *)
@@ -96,15 +95,21 @@ done
 
 
 if [ "$usage" ]; then
-       echo "Usage: $CMDNAME [options] dbname"
-       echo ""
+        echo "$CMDNAME removes a PostgreSQL database."
+        echo
+       echo "Usage:"
+        echo "  $CMDNAME [options] dbname"
+        echo
+       echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
        echo "  -U, --username=USERNAME         Username to connect as"
        echo "  -W, --password                  Prompt for password"
        echo "  -i, --interactive               Prompt before deleting anything"
-#???   echo "  -e,          --echo             "
-        echo "  -q,          --quiet            Don't write any messages"
+       echo "  -e, --echo                      Show the query being sent to the backend"
+        echo "  -q, --quiet                     Don't write any messages"
+       echo
+       echo "Report bugs to <pgsql-bugs@postgresql.org>."
        exit 0
 fi
 
@@ -127,7 +132,7 @@ fi
 
 dbname=`echo $dbname | sed 's/\"/\\\"/g'`
 
-psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\""
+${PATHNAME}psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\""
 if [ $? -ne 0 ]; then
        echo "$CMDNAME: database removal failed"
        exit 1
index a6b6efd36319f792f3b7212c94aae51cdb21ae6f..cd6563aeef333906c9fd6890b4a61de9ed5b4e6c 100644 (file)
@@ -8,11 +8,12 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.5 2000/01/12 19:36:36 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.6 2000/01/19 20:08:36 petere Exp $
 #
 #-------------------------------------------------------------------------
 
 CMDNAME=`basename $0`
+PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
 
 PSQLOPT=
 dbname=
@@ -64,25 +65,19 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --user|--username|-U)
-               PSQLOPT="$PSQLOPT -U '$2'"
+       --username|-U)
+               PSQLOPT="$PSQLOPT -U $2"
                shift;;
         -U*)
                 PSQLOPT="$PSQLOPT $1"
                 ;;
-        --user=*)
-                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
-                ;;
         --username=*)
                 PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
                 ;;
        --password|-W)
                PSQLOPT="$PSQLOPT -W"
                ;;
-       --echo|-e)
-                echo=t
-               ;;
-       --dbname|--database|-d)
+       --dbname|-d)
                dbname="$2"
                shift;;
         -d*)
@@ -91,12 +86,9 @@ do
         --dbname=*)
                 dbname=`echo $1 | sed 's/^--dbname=//'`
                 ;;
-        --database=*)
-                dbname=`echo $1 | sed 's/^--database=//'`
-                ;;
 
        -*)
-               echo "$CMDNAME: unrecognized option: $1"
+               echo "$CMDNAME: invalid option: $1"
                 echo "Try -? for help."
                exit 1
                ;;
@@ -113,22 +105,26 @@ done
 
 
 if [ "$usage" ]; then
-       echo ""
-       echo "Usage: $CMDNAME [options] [langname [dbname]]"
-       echo ""
+        echo "$CMDNAME removes a procedural language from a database."
+       echo
+       echo "Usage:"
+        echo "  $CMDNAME [options] [langname [dbname]]"
+        echo
+       echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
        echo "  -U, --username=USERNAME         Username to connect as"
        echo "  -W, --password                  Prompt for password"
        echo "  -d, --dbname=DBNAME             Database to remove language from"
-       echo "  -e, --echo                      Create some output about what is happening"
        echo "  -l, --list                      Show a list of currently installed languages"
+        echo
+       echo "Report bugs to <pgsql-bugs@postgresql.org>."
        exit 0
 fi
 
 
 if [ "$list" ]; then
-        psql $PSQLOPT -d "$dbname" -c "SELECT lanname, lanpltrusted, lancompiler FROM pg_language WHERE lanispl = 't'"
+        ${PATHNAME}psql $PSQLOPT -d "$dbname" -P 'title=Procedural languages' -c "SELECT lanname as \"Name\", lanpltrusted as \"Trusted?\", lancompiler as \"Compiler\" FROM pg_language WHERE lanispl = 't'"
         exit $?
 fi
 
@@ -171,13 +167,7 @@ case "$langname" in
 esac
 
 
-if [ "$echo" ]; then
-        PSQLOPT="$PSQLOPT -e"
-else
-        PSQLOPT="$PSQLOPT -q"
-fi
-
-PSQL="psql -A -t $PSQLOPT -d $dbname -c"
+PSQL="${PATHNAME}psql -A -t -q $PSQLOPT -d $dbname -c"
 
 
 # ----------
@@ -222,4 +212,5 @@ if [ $? -ne 0 ]; then
        exit 1
 fi
 
+echo "Ok"
 exit 0
index add007290b0d7a381072f0d7d41783458ed52af8..3a33c1f9cdea0580aa07a640fd62c8c3431e7dc5 100644 (file)
@@ -8,13 +8,15 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.5 2000/01/12 19:36:36 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.6 2000/01/19 20:08:36 petere Exp $
 #
 # Note - this should NOT be setuid.
 #
 #-------------------------------------------------------------------------
 
 CMDNAME=`basename $0`
+PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
+
 PSQLOPT=
 forcedel=t
 DelUser=
@@ -59,15 +61,12 @@ do
                 ;;
 # Note: These two specify the user to connect as (like in psql),
 #       not the user you're dropping.
-       --user|--username|-U)
-               PSQLOPT="$PSQLOPT -U '$2'"
+       --username|-U)
+               PSQLOPT="$PSQLOPT -U $2"
                shift;;
         -U*)
                 PSQLOPT="$PSQLOPT $1"
                 ;;
-        --user=*)
-                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
-                ;;
         --username=*)
                 PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
                 ;;
@@ -85,7 +84,8 @@ do
                forcedel=f
                ;;
        -*)
-               echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
+               echo "$CMDNAME: invalid option: $1"
+                echo "Try -? for help."
                exit 1
                ;;
          *)
@@ -97,16 +97,21 @@ done
 
 
 if [ "$usage" ]; then
-       echo ""
-       echo "Usage: $CMDNAME [options] [username]"
-       echo ""
+       echo "$CMDNAME removes a PostgreSQL user."
+        echo
+       echo "Usage:"
+        echo "  $CMDNAME [options] [username]"
+        echo
+       echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
        echo "  -U, --username=USERNAME         Username to connect as (not the one to drop)"
        echo "  -W, --password                  Prompt for password to connect"
        echo "  -i, --interactive               Prompt before deleting anything"
-#???   echo "  -e,          --echo             "
-        echo "  -q,          --quiet            Don't write any messages"
+        echo "  -e, --echo                      Show the query being sent to the backend"
+        echo "  -q, --quiet                     Don't write any messages"
+       echo
+       echo "Report bugs to <pgsql-bugs@postgresql.org>."
        exit 0
 fi
 
@@ -120,7 +125,7 @@ fi
 
 
 if [ "$forcedel" = f ]; then
-       echo "User \"$DelUser\" and any owned databases will be permanently deleted."
+       echo "User \"$DelUser\" will be permanently deleted."
        $ECHO_N "Are you sure? (y/n) "$ECHO_C
        read REPLY
 
@@ -131,7 +136,7 @@ fi
 
 DelUser=`echo $DelUser | sed 's/\"/\\\"/g'`
 
-psql $PSQLOPT -d template1 -c "DROP USER \"$DelUser\""
+${PATHNAME}psql $PSQLOPT -d template1 -c "DROP USER \"$DelUser\""
 
 if [ $? -ne 0 ]; then
        echo "$CMDNAME: deletion of user \"$DelUser\" failed"
index 92c0ce9cc94b303b3c5d8d909e150030fdbbe774..fcf6d4513cec25bfe70017979e35b6e07d62d3f4 100644 (file)
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.8 2000/01/12 19:36:36 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.9 2000/01/19 20:08:36 petere Exp $
 #
 #-------------------------------------------------------------------------
 
 CMDNAME=`basename $0`
+PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
 
 PSQLOPT=
 verbose=
@@ -23,6 +24,7 @@ analyze=
 table=
 dbname=
 alldb=
+quiet=0
 
 while [ $# -gt 0 ]
 do
@@ -50,15 +52,12 @@ do
         --port=*)
                 PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
                 ;;
-       --user|--username|-U)
-               PSQLOPT="$PSQLOPT -U '$2'"
+       --username|-U)
+               PSQLOPT="$PSQLOPT -U $2"
                shift;;
         -U*)
                 PSQLOPT="$PSQLOPT $1"
                 ;;
-        --user=*)
-                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
-                ;;
         --username=*)
                 PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
                 ;;
@@ -66,12 +65,13 @@ do
                PSQLOPT="$PSQLOPT -W"
                ;;
        --echo|-e)
-               PSQLOPT="$PSQLOPT -e"
+               ECHOOPT="-e"
                ;;
        --quiet|-q)
-               PSQLOPT="$PSQLOPT -o /dev/null"
+               ECHOOPT="$ECHOOPT -o /dev/null"
+                quiet=1
                ;;
-       --dbname|--database|-d)
+       --dbname|-d)
                dbname="$2"
                shift;;
         -d*)
@@ -80,12 +80,9 @@ do
         --dbname=*)
                 dbname=`echo $1 | sed 's/^--dbname=//'`
                 ;;
-        --database=*)
-                dbname=`echo $1 | sed 's/^--database=//'`
-                ;;
 # options converted into SQL command
        --analyze|-z)
-               analyze="ANALYZE "
+               analyze="ANALYZE"
                ;;
        --all|-a)
                alldb=Y
@@ -100,11 +97,11 @@ do
                 table=`echo $1 | sed 's/^--table=//'`
                 ;;
        --verbose|-v)
-               verbose="VERBOSE "
+               verbose="VERBOSE"
                ;;
 
        -*)
-               echo "$CMDNAME: unrecognized option: $1"
+               echo "$CMDNAME: invalid option: $1"
                 echo "Try -? for help."
                exit 1
                ;;
@@ -116,8 +113,12 @@ do
 done
 
 if [ "$usage" ]; then  
-       echo "Usage: $CMDNAME [options] [dbname]"
-       echo ""
+        echo "$CMDNAME cleans and analyzes a PostgreSQL database."
+        echo
+       echo "Usage:"
+        echo "  $CMDNAME [options] [dbname]"
+       echo
+        echo "Options:"
        echo "  -h, --host=HOSTNAME             Database server host"
        echo "  -p, --port=PORT                 Database server port"
        echo "  -U, --username=USERNAME         Username to connect as"
@@ -127,8 +128,10 @@ if [ "$usage" ]; then
        echo "  -z, --analyze                   Update optimizer hints"
        echo "  -t, --table='TABLE[(columns)]'  Vacuum specific table only"
        echo "  -v, --verbose                   Write a lot of output"
-#???   echo "  -e, --echo                      "
+       echo "  -e, --echo                      Show the command being sent to the backend"
         echo "  -q, --quiet                     Don't write any output"
+        echo
+       echo "Report bugs to <pgsql-bugs@postgresql.org>."
        exit 0
 fi
 
@@ -137,10 +140,9 @@ if [ "$alldb" ]; then
                 echo "$CMDNAME: cannot vacuum all databases and a specific one at the same time"
                 exit 1
         fi
-       dbname="`psql $PSQLOPT -q -t -A -d template1 -c 'SELECT datname FROM pg_database'`"
-fi
+       dbname=`${PATHNAME}psql $PSQLOPT -q -t -A -d template1 -c 'SELECT datname FROM pg_database'`
 
-if [ -z "$dbname" ]; then
+elif [ -z "$dbname" ]; then
        echo "$CMDNAME: missing required argument database name"
         echo "Try -? for help."
        exit 1
@@ -148,7 +150,8 @@ fi
 
 for db in $dbname
 do
-       psql $PSQLOPT -c "vacuum $verbose $analyze $table" -d $dbname
+        [ "$alldb" -a "$quiet" -ne 1 ] && echo "Vacuuming $db"
+       ${PATHNAME}psql $PSQLOPT $ECHOOPT -c "VACUUM $verbose $analyze $table" -d $db
 done
 
 if [ $? -ne 0 ]; then