another round of user interface cleanups

removed pg_id
fixed a few bugs in the scripts
This commit is contained in:
Peter Eisentraut 2000-01-19 20:08:36 +00:00
parent ea1f6e00e6
commit 65e0051843
19 changed files with 161 additions and 282 deletions

View 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>

View 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>

View 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 $
#
#-------------------------------------------------------------------------

View 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

View 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

View 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

View 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>.");
}

View File

@ -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

View File

@ -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);
}

View 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);

View 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)

View 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
{

View File

@ -11,11 +11,12 @@
#
#
# 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

View 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

View 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

View File

@ -10,11 +10,12 @@
#
#
# 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

View 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

View 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"

View File

@ -11,11 +11,12 @@
#
#
# 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