head	1.28;
access;
symbols
	REL7_3_21:1.27
	REL7_3_20:1.27
	REL7_3_19:1.27
	REL7_3_18:1.27
	REL7_3_17:1.27
	REL7_3_16:1.27
	REL7_3_15:1.27
	REL7_3_14:1.27
	REL7_3_13:1.27
	REL7_3_12:1.27
	REL7_3_11:1.27
	REL7_2_8:1.20
	REL7_3_10:1.27
	REL7_2_7:1.20
	REL7_3_9:1.27
	REL7_3_8:1.27
	REL7_2_6:1.20
	REL7_2_5:1.20
	REL7_3_7:1.27
	REL7_3_6:1.27
	REL7_3_5:1.27
	REL7_3_4:1.27
	REL7_3_2:1.27
	REL7_2_4:1.20
	REL7_3_STABLE:1.27.0.2
	REL7_2_3:1.20
	REL7_2_STABLE:1.20.0.2
	REL7_2:1.20
	REL7_2_RC2:1.20
	REL7_2_RC1:1.20
	REL7_2_BETA5:1.20
	REL7_2_BETA4:1.18
	REL7_2_BETA3:1.18
	REL7_2_BETA2:1.18
	REL7_2_BETA1:1.18
	REL7_1_2:1.13
	REL7_1_STABLE:1.13.0.2
	REL7_1_BETA:1.11
	REL7_1_BETA3:1.11
	REL7_1_BETA2:1.11
	REL7_1:1.13
	REL7_0_PATCHES:1.7.0.2
	REL7_0:1.7;
locks; strict;
comment	@# @;


1.28
date	2003.03.18.22.19.47;	author petere;	state dead;
branches;
next	1.27;

1.27
date	2002.10.18.22.05.36;	author petere;	state Exp;
branches;
next	1.26;

1.26
date	2002.10.16.03.44.28;	author momjian;	state Exp;
branches;
next	1.25;

1.25
date	2002.10.16.03.24.09;	author momjian;	state Exp;
branches;
next	1.24;

1.24
date	2002.08.10.16.57.32;	author petere;	state Exp;
branches;
next	1.23;

1.23
date	2002.06.20.20.29.42;	author momjian;	state Exp;
branches;
next	1.22;

1.22
date	2002.04.12.09.37.11;	author momjian;	state Exp;
branches;
next	1.21;

1.21
date	2002.02.18.05.48.44;	author momjian;	state Exp;
branches;
next	1.20;

1.20
date	2002.01.03.08.53.00;	author momjian;	state Exp;
branches;
next	1.19;

1.19
date	2002.01.03.06.09.02;	author momjian;	state Exp;
branches;
next	1.18;

1.18
date	2001.09.30.22.17.51;	author momjian;	state Exp;
branches;
next	1.17;

1.17
date	2001.09.22.04.28.12;	author momjian;	state Exp;
branches;
next	1.16;

1.16
date	2001.08.13.21.34.54;	author petere;	state Exp;
branches;
next	1.15;

1.15
date	2001.05.12.01.30.30;	author petere;	state Exp;
branches;
next	1.14;

1.14
date	2001.05.09.22.08.19;	author petere;	state Exp;
branches;
next	1.13;

1.13
date	2001.02.18.18.34.01;	author momjian;	state Exp;
branches;
next	1.12;

1.12
date	2001.01.21.05.16.45;	author momjian;	state Exp;
branches;
next	1.11;

1.11
date	2000.11.25.19.05.44;	author petere;	state Exp;
branches;
next	1.10;

1.10
date	2000.11.13.23.37.53;	author momjian;	state Exp;
branches;
next	1.9;

1.9
date	2000.11.13.15.18.14;	author momjian;	state Exp;
branches;
next	1.8;

1.8
date	2000.11.11.22.59.48;	author petere;	state Exp;
branches;
next	1.7;

1.7
date	2000.02.09.20.23.26;	author momjian;	state Exp;
branches;
next	1.6;

1.6
date	2000.01.19.20.08.36;	author petere;	state Exp;
branches;
next	1.5;

1.5
date	2000.01.12.19.36.36;	author petere;	state Exp;
branches;
next	1.4;

1.4
date	99.12.16.20.10.02;	author momjian;	state Exp;
branches;
next	1.3;

1.3
date	99.12.07.22.41.44;	author momjian;	state Exp;
branches;
next	1.2;

1.2
date	99.12.05.20.52.54;	author momjian;	state Exp;
branches;
next	1.1;

1.1
date	99.12.05.20.02.48;	author momjian;	state Exp;
branches;
next	;


desc
@@


1.28
log
@Reimplement create and drop scripts in C, to reduce repetitive
connections, increase robustness, add NLS, and prepare for Windows port.
(vacuumdb and clusterdb will follow later.)
@
text
@#! /bin/sh
#-------------------------------------------------------------------------
#
# droplang --
#   Remove a procedural language from a database
#
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql-server/src/bin/scripts/droplang,v 1.27 2002/10/18 22:05:36 petere Exp $
#
#-------------------------------------------------------------------------

CMDNAME=`basename "$0"`
PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`

PSQLOPT=
dbname=
langname=
echo=
list=
showsql=

# Check for echo -n vs echo \c

if echo '\c' | grep -s c >/dev/null 2>&1
then
    ECHO_N="echo -n"
    ECHO_C=""
else
    ECHO_N="echo"
    ECHO_C='\c'
fi


# ----------
# Get options, language name and dbname
# ----------
while [ "$#" -gt 0 ]
do
    case "$1" in 
	--help|-\?)
		usage=t
                break
		;;
        --list|-l)
                list=t
                ;;
# options passed on to psql
	--host|-h)
		PSQLOPT="$PSQLOPT -h $2"
		shift;;
        -h*)
                PSQLOPT="$PSQLOPT $1"
                ;;
        --host=*)
                PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
                ;;
	--port|-p)
		PSQLOPT="$PSQLOPT -p $2"
		shift;;
        -p*)
                PSQLOPT="$PSQLOPT $1"
                ;;
        --port=*)
                PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
                ;;
	--username|-U)
		PSQLOPT="$PSQLOPT -U $2"
		shift;;
        -U*)
                PSQLOPT="$PSQLOPT $1"
                ;;
        --username=*)
                PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
                ;;
	--password|-W)
		PSQLOPT="$PSQLOPT -W"
		;;
	--dbname|-d)
		dbname="$2"
		shift;;
        -d*)
                dbname=`echo "$1" | sed 's/^-d//'`
                ;;
        --dbname=*)
                dbname=`echo "$1" | sed 's/^--dbname=//'`
                ;;
	--echo|-e)
		showsql=yes
		;;

	-*)
		echo "$CMDNAME: invalid option: $1" 1>&2
                echo "Try '$CMDNAME --help' for more information." 1>&2
		exit 1
		;;
	 *)
 		if [ "$list" != "t" ]
		then	langname="$1"
			if [ "$2" ]
			then
				shift
				dbname="$1"
			fi
		else	dbname="$1"
		fi
		if [ "$#" -ne 1 ]; then
			echo "$CMDNAME: invalid option: $2" 1>&2
	                echo "Try '$CMDNAME --help' for more information." 1>&2
			exit 1
		fi
                ;;
    esac
    shift
done


if [ "$usage" ]; then
        echo "$CMDNAME removes a procedural language from a database."
	echo
	echo "Usage:"
        echo "  $CMDNAME [OPTION]... LANGNAME [DBNAME]"
        echo
	echo "Options:"
	echo "  -d, --dbname=DBNAME       database to remove language from"
	echo "  -l, --list                show a list of currently installed languages"
	echo "  -h, --host=HOSTNAME       database server host"
	echo "  -p, --port=PORT           database server port"
	echo "  -U, --username=USERNAME   user name to connect as"
	echo "  -W, --password            prompt for password"
	echo " --help                     show this help, then exit"
        echo
	echo "Report bugs to <pgsql-bugs@@postgresql.org>."
	exit 0
fi


if [ -z "$dbname" ]; then
        if [ "$PGDATABASE" ]; then
                dbname="$PGDATABASE"
        elif [ "$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
		echo "$sqlcmd"
	fi
        ${PATHNAME}psql $PSQLOPT -d "$dbname" -P 'title=Procedural languages' -c "$sqlcmd"
        exit $?
fi


# ----------
# We can't go any farther without a langname
# ----------
if [ -z "$langname" ]; then
	echo "$CMDNAME: missing required argument language name" 1>&2
        echo "Try '$CMDNAME --help' for help." 1>&2
	exit 1
fi

PSQL="${PATHNAME}psql -A -t -q $PSQLOPT -d $dbname -c"


# ----------
# Make sure the language is installed and find the oid of the handler function
# ----------
sqlcmd="SELECT lanplcallfoid FROM pg_language WHERE lanname = '$langname' AND lanispl;"
if [ "$showsql" = yes ]; then
	echo "$sqlcmd"
fi
lanplcallfoid=`$PSQL "$sqlcmd"`
if [ "$?" -ne 0 ]; then
	echo "$CMDNAME: external error" 1>&2
	exit 1
fi
if [ -z "$lanplcallfoid" ]; then
	echo "$CMDNAME: language \"$langname\" is not installed in database $dbname" 1>&2
	exit 1
fi


# ----------
# Check that there are no functions left defined in that language
# ----------
sqlcmd="SELECT COUNT(proname) FROM pg_proc P, pg_language L WHERE P.prolang = L.oid AND L.lanname = '$langname';"
if [ "$showsql" = yes ]; then
	echo "$sqlcmd"
fi
res=`$PSQL "$sqlcmd"`
if [ "$?" -ne 0 ]; then
	echo "$CMDNAME: external error" 1>&2
	exit 1
fi
if [ "$res" -ne 0 ]; then
	echo "$CMDNAME: There are $res functions/trigger procedures declared in language" 1>&2
        echo "$langname.  Language not removed." 1>&2
	exit 1
fi

# ----------
# Check that the handler function isn't used by some other language
# ----------
sqlcmd="SELECT count(*) FROM pg_language WHERE lanplcallfoid = $lanplcallfoid AND lanname <> '$langname';"
if [ "$showsql" = yes ]; then
	echo "$sqlcmd"
fi
res=`$PSQL "$sqlcmd"`
if [ "$?" -ne 0 ]; then
	echo "$CMDNAME: external error" 1>&2
	exit 1
fi
if [ "$res" -eq 0 ]; then
	keephandler=no
else
	keephandler=yes
fi

# ----------
# Drop the language
# ----------
sqlcmd="SET autocommit TO 'on';DROP LANGUAGE \"$langname\";"
if [ "$showsql" = yes ]; then
	echo "$sqlcmd"
fi
$PSQL "$sqlcmd"
if [ "$?" -ne 0 ]; then
	echo "$CMDNAME: language removal failed" 1>&2
	exit 1
fi

# ----------
# Drop the call handler
# ----------
if [ "$keephandler" = yes ]; then
        exit 0
fi

sqlcmd="SELECT proname FROM pg_proc WHERE oid = $lanplcallfoid;"
if [ "$showsql" = yes ]; then
	echo "$sqlcmd"
fi
handler=`$PSQL "$sqlcmd"`
if [ "$?" -ne 0 ]; then
	echo "$CMDNAME: external error" 1>&2
	exit 1
fi

sqlcmd="SET autocommit TO 'on';DROP FUNCTION \"$handler\" ();"
if [ "$showsql" = yes ]; then
	echo "$sqlcmd"
fi
$PSQL "$sqlcmd"
if [ "$?" -ne 0 ]; then
	echo "$CMDNAME: language removal failed" 1>&2
	exit 1
fi

exit 0
@


1.27
log
@Improve formatting of --help output.
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql-server/src/bin/scripts/droplang,v 1.26 2002/10/16 03:44:28 momjian Exp $
@


1.26
log
@Improve appearance of SET command.
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql-server/src/bin/scripts/droplang,v 1.25 2002/10/16 03:24:09 momjian Exp $
d123 1
a123 1
        echo "  $CMDNAME [options] langname [dbname]"
d126 7
a132 6
	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 "  -l, --list                      Show a list of currently installed languages"
@


1.25
log
@Fix script to handle autocommit = 'off' by prepending autocommit 'on' to
the start of the psql commandline.  This is better than adding BEGIN/END
because it handles multiple queries well, and allows the return code for
psql to return the proper value.
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql-server/src/bin/scripts/droplang,v 1.24 2002/08/10 16:57:32 petere Exp $
d232 1
a232 1
sqlcmd="SET autocommit = 'on';DROP LANGUAGE \"$langname\";"
d259 1
a259 1
sqlcmd="SET autocommit = 'on';DROP FUNCTION \"$handler\" ();"
@


1.24
log
@Make sure all clients have the same understanding of default user name
and database.  In particular, make script wrappers understand the
PGDATABASE environment variable.
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql-server/src/bin/scripts/droplang,v 1.23 2002/06/20 20:29:42 momjian Exp $
d232 1
a232 1
sqlcmd="DROP LANGUAGE \"$langname\";"
d259 1
a259 1
sqlcmd="DROP FUNCTION \"$handler\" ();"
@


1.23
log
@Update copyright to 2002.
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql/src/bin/scripts/droplang,v 1.22 2002/04/12 09:37:11 momjian Exp $
d139 3
a141 1
        if [ "$PGUSER" ]; then
@


1.22
log
@Allow dropdb and others to use identifiers with spaces;  IFS cleanup for
pg_dumpall.
@
text
@d7 1
a7 1
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
d10 1
a10 1
# $Header: /cvsroot/pgsql/src/bin/scripts/droplang,v 1.21 2002/02/18 05:48:44 momjian Exp $
@


1.21
log
@Fix param handling of create* admin scripts as described months ago.
Properly handles default values.
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql/src/bin/scripts/droplang,v 1.20 2002/01/03 08:53:00 momjian Exp $
d15 1
a15 1
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
d57 1
a57 1
                PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
d66 1
a66 1
                PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
d75 1
a75 1
                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
@


1.20
log
@Droplang didn't have test for -l, list.  This was really broken too.
Took test from createlang.
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql/src/bin/scripts/droplang,v 1.19 2002/01/03 06:09:02 momjian Exp $
d107 5
@


1.19
log
@droplang had same problem as createlang;  default are backwards and did
not work.  Fixed to match createlang.
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql/src/bin/scripts/droplang,v 1.18 2001/09/30 22:17:51 momjian Exp $
d99 8
a106 4
 		langname="$1"
                if [ "$2" ]; then
                        shift
			dbname="$1"
@


1.18
log
@These are further fixes for double quotes missing in the various shell
scripts.

Justin Clift
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql/src/bin/scripts/droplang,v 1.17 2001/09/22 04:28:12 momjian Exp $
d114 1
a114 1
        echo "  $CMDNAME [options] [langname [dbname]]"
a123 3
        echo "If 'langname' is not specified, you will be prompted interactively."
        echo "A database name must be specified."
        echo
d129 13
d153 1
a153 1
# Check that we have a database
d155 2
a156 2
if [ -z "$dbname" ]; then
	echo "$CMDNAME: missing required argument database name" 1>&2
a158 9
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
@


1.17
log
@sbasename $0 is now basename "$0"
@
text
@d10 1
a10 1
# $Header: /cvsroot/pgsql/src/bin/scripts/droplang,v 1.16 2001/08/13 21:34:54 petere Exp $
d39 1
a39 1
while [ $# -gt 0 ]
d171 1
a171 1
if [ $? -ne 0 ]; then
d189 1
a189 1
if [ $? -ne 0 ]; then
d195 1
a195 1
        echo "$langname. Language not removed." 1>&2
d207 1
a207 1
if [ $? -ne 0 ]; then
d225 1
a225 1
if [ $? -ne 0 ]; then
d242 1
a242 1
if [ $? -ne 0 ]; then
d252 1
a252 1
if [ $? -ne 0 ]; then
@


1.16
log
@Make LANCOMPILER clause in CREATE LANGUAGE optional.  Allow "identifier"
syntax for language names (instead of 'string').

createlang now handles the case where a second language uses the same call
handler as an already installed language (e.g., plperl/plperlu).

droplang now handles the reverse case, i.e., dropping a language where
the call handler is still used by another language.  Moreover, droplang
can now be used to drop any user-defined language, not just the supplied
ones.
@
text
@d10 1
a10 1
# $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/droplang,v 1.15 2001/05/12 01:30:30 petere Exp $
d14 1
a14 1
CMDNAME=`basename $0`
@


1.15
log
@PL/Python integration:  support in create/droplang, add CVS keywords,
remove useless files, beat some sense into Makefile.  For me it builds
and sort of runs, so it's a start.
@
text
@d10 1
a10 1
# $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/droplang,v 1.14 2001/05/09 22:08:19 petere Exp $
d133 1
a133 1
	sqlcmd="SELECT lanname as \"Name\", lanpltrusted as \"Trusted?\", lancompiler as \"Compiler\" FROM pg_language WHERE lanispl = 't'"
a159 32
# ----------
# Check if supported and set related values
# ----------
case "$langname" in
	plpgsql)
                lancomp="PL/pgSQL"
		handler="plpgsql_call_handler"
                ;;
	pltcl)
		lancomp="PL/Tcl"
		handler="pltcl_call_handler"
                ;;
	pltclu)
		lancomp="PL/Tcl (untrusted)"
		handler="pltclu_call_handler"
		;;
	plperl)
		lancomp="PL/Perl"
		handler="plperl_call_handler"
                ;;
	plpython)
		lancomp="PL/Python"
		handler="plpython_call_handler"
                ;;
	*)
		echo "$CMDNAME: unsupported language '$langname'" 1>&2
		echo "Supported languages are 'plpgsql', 'pltcl', 'pltclu', 'plperl', and 'plpython'." 1>&2
		exit 1
                ;;
esac


d164 1
a164 1
# Make sure the language is installed
d166 1
a166 1
sqlcmd="SELECT oid FROM pg_language WHERE lanname = '$langname';"
d170 1
a170 1
res=`$PSQL "$sqlcmd"`
d175 2
a176 2
if [ -z "$res" ]; then
	echo "$CMDNAME: '$langname' is not installed in database $dbname" 1>&2
d195 1
a195 1
        echo "$lancomp. Language not removed." 1>&2
d200 1
a200 1
# Drop the language and the call handler function
d202 19
a220 1
sqlcmd="DROP PROCEDURAL LANGUAGE '$langname';"
d230 18
a247 1
sqlcmd="DROP FUNCTION $handler();"
@


1.14
log
@Add --echo option to createlang and droplang.
from Oliver Elphick
@
text
@d10 1
a10 1
# $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/droplang,v 1.13 2001/02/18 18:34:01 momjian Exp $
d180 4
d186 1
a186 1
		echo "Supported languages are 'plpgsql', 'pltcl', 'pltclu', and 'plperl'." 1>&2
@


1.13
log
@Add copyright mentions, per Tom Lane.
@
text
@d1 1
a1 1
#!/bin/sh
d4 2
a5 2
# createlang--
#    Remove a procedural language from a database
d10 1
a10 3
#
# IDENTIFICATION
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/droplang,v 1.12 2001/01/21 05:16:45 momjian Exp $
d22 1
d89 3
d133 5
a137 1
        ${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'"
d147 1
a147 1
        echo "Try '$CMDNAME -?' for help." 1>&2
d194 5
a198 1
res=`$PSQL "SELECT oid FROM pg_language WHERE lanname = '$langname'"`
d212 5
a216 1
res=`$PSQL "SELECT COUNT(proname) FROM pg_proc P, pg_language L WHERE P.prolang = L.oid AND L.lanname = '$langname'"`
d230 5
a234 1
$PSQL "DROP PROCEDURAL LANGUAGE '$langname'"
d239 6
a244 1
$PSQL "DROP FUNCTION $handler()"
@


1.12
log
@Put quotes around environment variables.
@
text
@d7 2
a8 1
# Copyright (c) 1994, Regents of the University of California
d12 1
a12 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/droplang,v 1.11 2000/11/25 19:05:44 petere Exp $
@


1.11
log
@Advertise --help (rather than '-?') as help option (problems with csh).
Accept --help even if no general long options support exists.
@
text
@d11 1
a11 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/droplang,v 1.10 2000/11/13 23:37:53 momjian Exp $
d84 1
a84 1
                dbname=`echo $1 | sed 's/^-d//'`
d87 1
a87 1
                dbname=`echo $1 | sed 's/^--dbname=//'`
d206 1
a206 1
if [ $res -ne 0 ]; then
@


1.10
log
@Remove -k unix socketpath option from client side, allow hostname with
leading slash to behave as a unix socket path.
@
text
@d11 1
a11 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/droplang,v 1.9 2000/11/13 15:18:14 momjian Exp $
d92 1
a92 1
                echo "Try '$CMDNAME -?' for help." 1>&2
@


1.9
log
@UUNET is looking into offering PostgreSQL as a part of a managed web
hosting product, on both shared and dedicated machines.  We currently
offer Oracle and MySQL, and it would be a nice middle-ground.
However, as shipped, PostgreSQL lacks the following features we need
that MySQL has:

1. The ability to listen only on a particular IP address.  Each
   hosting customer has their own IP address, on which all of their
   servers (http, ftp, real media, etc.) run.
2. The ability to place the Unix-domain socket in a mode 700 directory.
   This allows us to automatically create an empty database, with an
   empty DBA password, for new or upgrading customers without having
   to interactively set a DBA password and communicate it to (or from)
   the customer.  This in turn cuts down our install and upgrade times.
3. The ability to connect to the Unix-domain socket from within a
   change-rooted environment.  We run CGI programs chrooted to the
   user's home directory, which is another reason why we need to be
   able to specify where the Unix-domain socket is, instead of /tmp.
4. The ability to, if run as root, open a pid file in /var/run as
   root, and then setuid to the desired user.  (mysqld -u can almost
   do this; I had to patch it, too).

The patch below fixes problem 1-3.  I plan to address #4, also, but
haven't done so yet.  These diffs are big enough that they should give
the PG development team something to think about in the meantime :-)
Also, I'm about to leave for 2 weeks' vacation, so I thought I'd get
out what I have, which works (for the problems it tackles), now.

With these changes, we can set up and run PostgreSQL with scripts the
same way we can with apache or proftpd or mysql.

In summary, this patch makes the following enhancements:

1. Adds an environment variable PGUNIXSOCKET, analogous to MYSQL_UNIX_PORT,
   and command line options -k --unix-socket to the relevant programs.
2. Adds a -h option to postmaster to set the hostname or IP address to
   listen on instead of the default INADDR_ANY.
3. Extends some library interfaces to support the above.
4. Fixes a few memory leaks in PQconnectdb().

The default behavior is unchanged from stock 7.0.2; if you don't use
any of these new features, they don't change the operation.

David J. MacKenzie
@
text
@d11 1
a11 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/droplang,v 1.8 2000/11/11 22:59:48 petere Exp $
a67 9
	--unixsocket|-k)
		PSQLOPT="$PSQLOPT -k $2"
		shift;;
        -k*)
                PSQLOPT="$PSQLOPT $1"
                ;;
        --unixsocket=*)
                PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
                ;;
a115 1
	echo "  -k, --unixsocket=PATH           Database server Unix-domain socket name"
@


1.8
log
@Make sure shell scripts send error messages to stderr.
Improve help output.
Teach droplang to remove 'pltclu'.
@
text
@d11 1
a11 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/droplang,v 1.7 2000/02/09 20:23:26 momjian Exp $
d68 9
d125 1
@


1.7
log
@Here is the patch to add plperl to droplang.
Mark Hollomon
@
text
@d11 1
a11 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/droplang,v 1.6 2000/01/19 20:08:36 petere Exp $
d91 2
a92 2
		echo "$CMDNAME: invalid option: $1"
                echo "Try -? for help."
d121 3
d139 2
a140 2
	echo "$CMDNAME: missing required argument database name"
        echo "Try -? for help."
d165 4
d174 2
a175 2
		echo "$CMDNAME: unsupported language '$langname'"
		echo "Supported languages are 'plpgsql', 'pltcl', and 'plperl'."
d189 1
a189 1
	echo "$CMDNAME: external error"
d193 1
a193 1
	echo "$CMDNAME: '$langname' is not installed in database $dbname"
d203 1
a203 1
	echo "$CMDNAME: external error"
d207 2
a208 2
	echo "$CMDNAME: There are $res functions/trigger procedures declared in language"
        echo "$lancomp. Language not removed."
d217 1
a217 1
	echo "$CMDNAME: language removal failed"
d222 1
a222 1
	echo "$CMDNAME: language removal failed"
a225 1
echo "Ok"
@


1.6
log
@another round of user interface cleanups
removed pg_id
fixed a few bugs in the scripts
@
text
@d11 1
a11 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/droplang,v 1.5 2000/01/12 19:36:36 petere Exp $
d162 4
d168 1
a168 1
		echo "Supported languages are 'plpgsql' and 'pltcl'."
@


1.5
log
@Fixed a few "fixes" and bugs. Adjusted messages and options to GNU suggestions.
@
text
@d11 1
a11 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/droplang,v 1.4 1999/12/16 20:10:02 momjian Exp $
d16 1
d68 2
a69 2
	--user|--username|-U)
		PSQLOPT="$PSQLOPT -U '$2'"
a73 3
        --user=*)
                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
                ;;
d80 1
a80 4
	--echo|-e)
                echo=t
		;;
	--dbname|--database|-d)
a88 3
        --database=*)
                dbname=`echo $1 | sed 's/^--database=//'`
                ;;
d91 1
a91 1
		echo "$CMDNAME: unrecognized option: $1"
d108 6
a113 3
	echo ""
	echo "Usage: $CMDNAME [options] [langname [dbname]]"
	echo ""
a118 1
	echo "  -e, --echo                      Create some output about what is happening"
d120 2
d127 1
a127 1
        psql $PSQLOPT -d "$dbname" -c "SELECT lanname, lanpltrusted, lancompiler FROM pg_language WHERE lanispl = 't'"
d170 1
a170 7
if [ "$echo" ]; then
        PSQLOPT="$PSQLOPT -e"
else
        PSQLOPT="$PSQLOPT -q"
fi

PSQL="psql -A -t $PSQLOPT -d $dbname -c"
d215 1
@


1.4
log
@Hi,

I sending promised patch with:

        * getopt_long() - for pg_dump (portable)

        * and "Usage: " changes in scripts in src/bin/
          - this changes are cosmetic only, not change any
          feature ...etc.

 All PostgreSQL routines (scripts) support now long options and
help's output is alike for all scripts and all support -? or --help.

                                                Karel

Karel Zak <zakkr@@zf.jcu.cz>              http://home.zf.jcu.cz/~zakkr/
@
text
@d11 1
a11 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/droplang,v 1.3 1999/12/07 22:41:44 momjian Exp $
d43 1
d98 5
d117 1
a117 1
	echo "Usage: $CMDNAME [options] [language [dbname]]"
d119 8
a126 10
	echo "    -h HOSTNAME, --host=HOSTNAME     "
	echo "    -p PORT,     --port=PORT         "
	echo "    -u USERNAME, --username=USERNAME "
	echo "    -W,          --password          "
	echo "    -d DBNAME    --database=DBNAME   "
	echo "    -e,          --echo              "
        echo "    -q,          --quiet             "   
	echo "    -?,          --help              "
	echo ""
	exit 1
d140 2
a141 1
	echo "$CMDNAME: Missing required argument database name. Try -? for help."
d167 2
a168 2
		echo "$CMDNAME: Unsupported language '$langname'."
		echo "          Supported languages are 'plpgsql' and 'pltcl'."
d188 1
a188 1
	echo "Language removal failed."
d192 1
a192 1
	echo "The language '$langname' isn't installed in database $dbname."
d202 1
a202 1
	echo "Language removal failed."
d206 2
a207 3
	echo "There are $res functions/trigger procedures declared in language"
        echo "$lancomp."
        echo "Language not removed."
d216 1
a216 1
	echo "Language removal failed."
d221 1
a221 1
	echo "Language removal failed."
@


1.3
log
@Okay, that should put us back in sync. These two patches (src & doc) are
against the sources from one hour ago and contain all the portable and
up
to date stuff.

A few other CVS "householding" things you might want to take care of:

* Remove the src/bin/cleardbdir directory

* Remove the file src/bin/psql/sql_help.h from the repository, as it is
a derived file and is build by the release_prep.

Peter Eisentraut
@
text
@d11 1
a11 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/destroylang/destroylang.sh,v 1.1 1999/05/20 16:50:03 wieck Exp $
a42 1
		break
d110 13
a122 2
	echo "Usage: $CMDNAME [-h server] [-p port] [-U username] [-d dbname] [langname [dbname]]"
	exit 0
d124 1
@


1.2
log
@Fix echo -n and read -r in scripts.
@
text
@d11 1
a11 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/droplang,v 1.1 1999/12/05 20:02:48 momjian Exp $
d22 11
@


1.1
log
@I cleaned those out as well (the echo -n "bug" was in there ;) and moved
them into the scripts dir. I also added a --list option to show already
installed languages.

This whole moving and renaming totally confused CVS and my checked out
copy got completely fried last night. When you apply the source patch,
please make sure that all the directories src/bin/{create|destroy}* as
well as vacuumdb, cleardbdir are gone and that all the scripts (7) are
in
scripts/.

Meanwhile I am still puzzled about what happened with the docs patch.
Because I don't know what you got now, the second attachment contains
the
files

ref/allfiles.sgml
ref/commands.sgml
ref/createlang.sgml
ref/droplang.sgml
doc/src/sgml/Makefile

Peter Eisentraut                  Sernanders vg 10:115
@
text
@d11 1
a11 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/destroylang/destroylang.sh,v 1.1 1999/05/20 16:50:03 wieck Exp $
a21 11

# Check for echo -n vs echo \c

if echo '\c' | grep -s c >/dev/null 2>&1
then
    ECHO_N="echo -n"
    ECHO_C=""
else
    ECHO_N="echo"
    ECHO_C='\c'
fi
@
