head	1.29;
access;
symbols
	REL7_3_21:1.28.2.1
	REL7_3_20:1.28.2.1
	REL7_3_19:1.28.2.1
	REL7_3_18:1.28.2.1
	REL7_3_17:1.28.2.1
	REL7_3_16:1.28.2.1
	REL7_3_15:1.28.2.1
	REL7_3_14:1.28
	REL7_3_13:1.28
	REL7_3_12:1.28
	REL7_3_11:1.28
	REL7_2_8:1.18
	REL7_3_10:1.28
	REL7_2_7:1.18
	REL7_3_9:1.28
	REL7_3_8:1.28
	REL7_2_6:1.18
	REL7_2_5:1.18
	REL7_3_7:1.28
	REL7_3_6:1.28
	REL7_3_5:1.28
	REL7_3_4:1.28
	REL7_3_2:1.28
	REL7_2_4:1.18
	REL7_3_STABLE:1.28.0.2
	REL7_2_3:1.18
	REL7_2_STABLE:1.18.0.2
	REL7_2:1.18
	REL7_2_RC2:1.18
	REL7_2_RC1:1.18
	REL7_2_BETA5:1.18
	REL7_2_BETA4:1.18
	REL7_2_BETA3:1.18
	REL7_2_BETA2:1.18
	REL7_2_BETA1:1.18
	REL7_1_2:1.15
	REL7_1_STABLE:1.15.0.2
	REL7_1_BETA:1.12
	REL7_1_BETA3:1.12
	REL7_1_BETA2:1.12
	REL7_1:1.15
	REL7_0_PATCHES:1.8.0.2
	REL7_0:1.8;
locks; strict;
comment	@# @;


1.29
date	2003.03.18.22.19.46;	author petere;	state dead;
branches;
next	1.28;

1.28
date	2002.10.18.22.05.36;	author petere;	state Exp;
branches
	1.28.2.1;
next	1.27;

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

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

1.25
date	2002.09.03.21.45.43;	author petere;	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.06.11.22.21.01;	author momjian;	state Exp;
branches;
next	1.21;

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

1.20
date	2002.02.24.23.27.58;	author tgl;	state Exp;
branches;
next	1.19;

1.19
date	2002.02.18.05.48.44;	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.09.06.04.57.29;	author ishii;	state Exp;
branches;
next	1.15;

1.15
date	2001.03.27.05.47.13;	author ishii;	state Exp;
branches;
next	1.14;

1.14
date	2001.02.18.17.53.54;	author tgl;	state Exp;
branches;
next	1.13;

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

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

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

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

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

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

1.7
date	2000.01.19.20.08.35;	author petere;	state Exp;
branches;
next	1.6;

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

1.5
date	2000.01.12.13.08.55;	author ishii;	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.08.10.29.55;	author momjian;	state Exp;
branches;
next	1.2;

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

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

1.28.2.1
date	2006.05.21.19.56.41;	author momjian;	state Exp;
branches;
next	;


desc
@@


1.29
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
#-------------------------------------------------------------------------
#
# createdb--
#    create a postgres database
#
#    This program runs psql with the "-c" option to create
#    the requested database.
#
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
#
# IDENTIFICATION
#    $Header: /cvsroot/pgsql-server/src/bin/scripts/createdb,v 1.28 2002/10/18 22:05:36 petere Exp $
#
#-------------------------------------------------------------------------

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

MB=
TEMPLATE=
PSQLOPT=
dbname=
dbowner=
dbcomment=
dbpath=

while [ "$#" -gt 0 ]
do
    case "$1" in
	--help|-\?)
		usage=t
                break
		;;
# 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"
		;;
	--echo|-e)
		PSQLOPT="$PSQLOPT -e"
		;;
	--quiet|-q)
		PSQLOPT="$PSQLOPT -o /dev/null"
		;;
# options converted into SQL command
	--owner|-O)
		dbowner="$2"
		shift;;
        -O*)
                dbowner=`echo "$1" | sed 's/^-O//'`
                ;;
        --owner=*)
                dbowner=`echo "$1" | sed 's/^--owner=//'`
                ;;
	--location|-D)
		dbpath="$2"
		shift;;
        -D*)
                dbpath=`echo "$1" | sed 's/^-D//'`
                ;;
        --location=*)
                dbpath=`echo "$1" | sed 's/^--location=//'`
                ;;
	--template|-T)
		TEMPLATE="$2"
		shift;;
        -T*)
                TEMPLATE=`echo "$1" | sed 's/^-T//'`
                ;;
        --template=*)
                TEMPLATE=`echo "$1" | sed 's/^--template=//'`
                ;;
	--encoding|-E)
		MB="$2"
		shift;;
        -E*)
                MB=`echo "$1" | sed 's/^-E//'`
                ;;
        --encoding=*)
                MB=`echo "$1" | sed 's/^--encoding=//'`
                ;;
	-*)
		echo "$CMDNAME: invalid option: $1" 1>&2
                echo "Try '$CMDNAME --help' for more information." 1>&2
		exit 1
		;;
	*)
		dbname="$1"
		if [ "$2" ]
		then
			shift
			dbcomment="$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 creates a PostgreSQL database."
        echo
	echo "Usage:"
        echo "  $CMDNAME [OPTION]... [DBNAME] [DESCRIPTION]"
        echo
	echo "Options:"
	echo "  -D, --location=PATH       alternative place to store the database"
	echo "  -E, --encoding=ENCODING   encoding for the database"
	echo "  -O, --owner=OWNER         database user to own the new database"
	echo "  -T, --template=TEMPLATE   template database to copy"
	echo "  -e, --echo                show the query being sent to the backend"
        echo "  -q, --quiet               don't write any messages"
	echo "  --help                    show this help, then exit"
	echo
	echo "Connection options:"
	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
        echo "By default, a database with the same name as the current user is created."
	echo
	echo "Report bugs to <pgsql-bugs@@postgresql.org>."
	exit 0
fi


if [ -n "$MB" ]
then
        mbcode=`${PATHNAME}pg_encoding "$MB"`
        if [ -z "$mbcode" ]
	then
		echo "$CMDNAME: \"$MB\" is not a valid encoding name" 1>&2
		exit 1
	fi
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


# escape the quotes
dbpath=`echo "$dbpath" | sed "s/'/\\\\\'/g"`
dbname=`echo "$dbname" | sed 's/\"/\\\"/g'`
TEMPLATE=`echo "$TEMPLATE" | sed 's/\"/\"\"/g'`

withstring=
[ "$dbowner" ] &&    withstring="$withstring OWNER = \"$dbowner\""
[ "$dbpath" ] &&     withstring="$withstring LOCATION = '$dbpath'"
[ "$MB" ] &&         withstring="$withstring ENCODING = '$MB'"
[ "$TEMPLATE" ] &&   withstring="$withstring TEMPLATE = \"$TEMPLATE\""
[ "$withstring" ] && withstring=" WITH$withstring"

${PATHNAME}psql $PSQLOPT -d template1 -c "SET autocommit TO 'on';CREATE DATABASE \"$dbname\"$withstring"
if [ "$?" -ne 0 ]; then
	echo "$CMDNAME: database creation failed" 1>&2
	exit 1
fi

# Insert comment as well, if requested
[ -z "$dbcomment" ] && exit 0

dbcomment=`echo "$dbcomment" | sed "s/'/\\\\\'/g"`

${PATHNAME}psql $PSQLOPT -d "$dbname" -c "SET autocommit TO 'on';COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
if [ "$?" -ne 0 ]; then
	echo "$CMDNAME: comment creation failed (database was created)" 1>&2
	exit 1
fi

exit 0
@


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


1.28.2.1
log
@Change \' to '', for SQL standards compliance.  Backpatch to 7.3, 7.4,
and 8.0.  Later releases already patched.
@
text
@d15 1
a15 1
#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.28 2002/10/18 22:05:36 petere Exp $
d184 1
a184 1
dbpath=`echo "$dbpath" | sed "s/'/\'\'/g"`
d204 1
a204 1
dbcomment=`echo "$dbcomment" | sed "s/'/\'\'/g"`
@


1.27
log
@Improve appearance of SET command.
@
text
@d15 1
a15 1
#    $Header: /cvsroot/pgsql-server/src/bin/scripts/createdb,v 1.26 2002/10/16 03:24:09 momjian Exp $
d137 1
a137 1
        echo "  $CMDNAME [options] [dbname] [description]"
d140 13
a152 10
	echo "  -O, --owner=OWNER               Database user to own the new database"
	echo "  -D, --location=PATH             Alternative place to store the database"
	echo "  -T, --template=TEMPLATE         Template database to copy"
	echo "  -E, --encoding=ENCODING         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                      Show the query being sent to the backend"
        echo "  -q, --quiet                     Don't write any messages"
@


1.26
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
@d15 1
a15 1
#    $Header: /cvsroot/pgsql-server/src/bin/scripts/createdb,v 1.25 2002/09/03 21:45:43 petere Exp $
d192 1
a192 1
${PATHNAME}psql $PSQLOPT -d template1 -c "SET autocommit = 'on';CREATE DATABASE \"$dbname\"$withstring"
d203 1
a203 1
${PATHNAME}psql $PSQLOPT -d "$dbname" -c "SET autocommit = 'on';COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
@


1.25
log
@Remove all traces of multibyte and locale options.  Clean up comments
referring to "multibyte" where it really means character encoding.
@
text
@d15 1
a15 1
#    $Header: /cvsroot/pgsql-server/src/bin/scripts/createdb,v 1.24 2002/08/10 16:57:32 petere Exp $
d192 1
a192 1
${PATHNAME}psql $PSQLOPT -d template1 -c "CREATE DATABASE \"$dbname\"$withstring"
d203 1
a203 1
${PATHNAME}psql $PSQLOPT -d "$dbname" -c "COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
@


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
@d15 1
a15 1
#    $Header: /cvsroot/pgsql-server/src/bin/scripts/createdb,v 1.23 2002/06/20 20:29:42 momjian Exp $
d143 1
a143 1
	echo "  -E, --encoding=ENCODING         Multibyte encoding for the database"
@


1.23
log
@Update copyright to 2002.
@
text
@d15 1
a15 1
#    $Header: /cvsroot/pgsql/src/bin/scripts/createdb,v 1.22 2002/06/11 22:21:01 momjian Exp $
d169 3
a171 1
        if [ "$PGUSER" ]; then
@


1.22
log
@Allow createdb to create comments in current db, not template1.
@
text
@d10 1
a10 1
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
d15 1
a15 1
#    $Header: /cvsroot/pgsql/src/bin/scripts/createdb,v 1.21 2002/04/12 09:37:10 momjian Exp $
@


1.21
log
@Allow dropdb and others to use identifiers with spaces;  IFS cleanup for
pg_dumpall.
@
text
@d15 1
a15 1
#    $Header: /cvsroot/pgsql/src/bin/scripts/createdb,v 1.20 2002/02/24 23:27:58 tgl Exp $
d201 1
a201 1
${PATHNAME}psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
@


1.20
log
@Add -O/--owner switch to createdb script, in support of new OWNER option
for CREATE DATABASE.
@
text
@d15 1
a15 1
#    $Header: /cvsroot/pgsql/src/bin/scripts/createdb,v 1.19 2002/02/18 05:48:44 momjian Exp $
d20 1
a20 1
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
d45 1
a45 1
                PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
d54 1
a54 1
                PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
d63 1
a63 1
                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
@


1.19
log
@Fix param handling of create* admin scripts as described months ago.
Properly handles default values.
@
text
@d15 1
a15 1
#    $Header: /cvsroot/pgsql/src/bin/scripts/createdb,v 1.18 2001/09/30 22:17:51 momjian Exp $
d26 1
d75 9
d140 1
d184 1
@


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

Justin Clift
@
text
@d15 1
a15 1
#    $Header: /cvsroot/pgsql/src/bin/scripts/createdb,v 1.17 2001/09/22 04:28:12 momjian Exp $
d107 4
a110 3
		if [ -z "$dbname" ]; then
			dbname="$1"
		else
d113 5
d127 1
a127 1
        echo "  $CMDNAME [options] dbname [description]"
@


1.17
log
@sbasename $0 is now basename "$0"
@
text
@d15 1
a15 1
#    $Header: /cvsroot/pgsql/src/bin/scripts/createdb,v 1.16 2001/09/06 04:57:29 ishii Exp $
d29 1
a29 1
while [ $# -gt 0 ]
d157 1
a157 1
        [ $? -ne 0 ] && exit 1
d173 1
a173 1
if [ $? -ne 0 ]; then
d184 1
a184 1
if [ $? -ne 0 ]; then
@


1.16
log
@Commit Karel's patch.

-------------------------------------------------------------------
Subject: Re: [PATCHES] encoding names
From: Karel Zak <zakkr@@zf.jcu.cz>
To: Peter Eisentraut <peter_e@@gmx.net>
Cc: pgsql-patches <pgsql-patches@@postgresql.org>
Date: Fri, 31 Aug 2001 17:24:38 +0200

On Thu, Aug 30, 2001 at 01:30:40AM +0200, Peter Eisentraut wrote:
> > 		- convert encoding 'name' to 'id'
>
> I thought we decided not to add functions returning "new" names until we
> know exactly what the new names should be, and pending schema

 Ok, the patch not to add functions.

> better
>
>     ...(): encoding name too long

 Fixed.

 I found new bug in command/variable.c in parse_client_encoding(), nobody
probably never see this error:

if (pg_set_client_encoding(encoding))
{
	elog(ERROR, "Conversion between %s and %s is not supported",
                     value, GetDatabaseEncodingName());
}

because pg_set_client_encoding() returns -1 for error and 0 as true.
It's fixed too.

 IMHO it can be apply.

		Karel
PS:

    * following files are renamed:

src/utils/mb/Unicode/KOI8_to_utf8.map  -->
        src/utils/mb/Unicode/koi8r_to_utf8.map

src/utils/mb/Unicode/WIN_to_utf8.map  -->
        src/utils/mb/Unicode/win1251_to_utf8.map

src/utils/mb/Unicode/utf8_to_KOI8.map -->
        src/utils/mb/Unicode/utf8_to_koi8r.map

src/utils/mb/Unicode/utf8_to_WIN.map -->
        src/utils/mb/Unicode/utf8_to_win1251.map

   * new file:

src/utils/mb/encname.c

   * removed file:

src/utils/mb/common.c

--
 Karel Zak  <zakkr@@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/

 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
@
text
@d15 1
a15 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/createdb,v 1.15 2001/03/27 05:47:13 ishii Exp $
d19 1
a19 1
CMDNAME=`basename $0`
@


1.15
log
@Add checking for valid database encoding.
@
text
@d15 1
a15 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/createdb,v 1.14 2001/02/18 17:53:54 tgl Exp $
a146 4
		exit 1
	elif [ $mbcode -gt 31 ]
	then
		echo "$CMDNAME: $MB cannot be used as a database encoding" 1>&2
@


1.14
log
@Add --template option to createdb script to allow access to WITH TEMPLATE
option of CREATE DATABASE.  In pg_regress, create regression database
from template0 to ensure that any installation-local cruft in template1
will not mess up the tests.
@
text
@d15 1
a15 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/createdb,v 1.13 2001/01/21 05:16:45 momjian Exp $
d147 4
@


1.13
log
@Put quotes around environment variables.
@
text
@d10 2
a11 1
# Copyright (c) 1994, Regents of the University of California
d15 1
a15 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/createdb,v 1.12 2000/11/25 19:05:44 petere Exp $
d23 1
d83 9
d125 1
d164 1
d169 1
@


1.12
log
@Advertise --help (rather than '-?') as help option (problems with csh).
Accept --help even if no general long options support exists.
@
text
@d14 1
a14 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/createdb,v 1.11 2000/11/13 23:37:53 momjian Exp $
d76 1
a76 1
                dbpath=`echo $1 | sed 's/^-D//'`
d79 1
a79 1
                dbpath=`echo $1 | sed 's/^--location=//'`
d82 1
a82 1
		MB=$2
d85 1
a85 1
                MB=`echo $1 | sed 's/^-E//'`
d88 1
a88 1
                MB=`echo $1 | sed 's/^--encoding=//'`
d141 1
a141 1
                dbname=$PGUSER
d150 2
a151 2
dbpath=`echo $dbpath | sed "s/'/\\\\\'/g"`
dbname=`echo $dbname | sed 's/\"/\\\"/g'`
d167 1
a167 1
dbcomment=`echo $dbcomment | sed "s/'/\\\\\'/g"`
@


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


1.10
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
@d14 1
a14 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/createdb,v 1.9 2000/11/11 22:59:48 petere Exp $
a52 9
	--unixsocket|-k)
		PSQLOPT="$PSQLOPT -k $2"
		shift;;
        -k*)
                PSQLOPT="$PSQLOPT $1"
                ;;
        --unixsocket=*)
                PSQLOPT="$PSQLOPT -k "`echo $1 | sed 's/^--unixsocket=//'`
                ;;
a116 1
	echo "  -k, --unixsocket=PATH           Database server Unix-domain socket name"
@


1.9
log
@Make sure shell scripts send error messages to stderr.
Improve help output.
Teach droplang to remove 'pltclu'.
@
text
@d14 1
a14 1
#    $Header: /home/projects/pgsql/cvsroot/pgsql/src/bin/scripts/createdb,v 1.8 2000/02/10 20:08:58 petere Exp $
d53 9
d126 1
@


1.8
log
@Default argument for createdb
Changed EXIT_ON_ERROR to ON_ERROR_STOP in psql
@
text
@d14 1
a14 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/createdb,v 1.7 2000/01/19 20:08:35 petere Exp $
d91 2
a92 2
		echo "$CMDNAME: invalid option: $1"
                echo "Try -? for help."
d121 2
d134 1
a134 1
		echo "$CMDNAME: \"$MB\" is not a valid encoding name"
d160 1
a160 1
	echo "$CMDNAME: database creation failed"
d171 1
a171 1
	echo "$CMDNAME: comment creation failed (database was created)"
@


1.7
log
@another round of user interface cleanups
removed pg_id
fixed a few bugs in the scripts
@
text
@d14 1
a14 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/createdb,v 1.6 2000/01/12 19:36:36 petere Exp $
d129 1
a129 1
        mbcode=`pg_encoding "$MB"`
d138 6
a143 3
	echo "$CMDNAME: missing required argument database name"
        echo "Try -? for help."
	exit 1
@


1.6
log
@Fixed a few "fixes" and bugs. Adjusted messages and options to GNU suggestions.
@
text
@d14 1
a14 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/createdb,v 1.5 2000/01/12 13:08:55 ishii Exp $
d19 1
d53 2
a54 2
	--user|--username|-U)
		PSQLOPT="$PSQLOPT -U '$2'"
a58 3
        --user=*)
                PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'`
                ;;
d91 1
a91 1
		echo "$CMDNAME: unrecognized option: $1"
d107 6
a112 2
	echo "Usage: $CMDNAME [options] dbname [description]"
	echo ""
d119 4
a122 2
#???	echo "  -e,          --echo             "
        echo "  -q,          --quiet            Don't write any messages"
d153 1
a153 1
psql $PSQLOPT -d template1 -c "CREATE DATABASE \"$dbname\"$withstring"
d164 1
a164 1
psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'"
@


1.5
log
@Multi-byte case fix by Oliver Elphick (olly@@lfix.co.uk)
@
text
@d14 1
a14 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/createdb,v 1.4 1999/12/16 20:10:02 momjian Exp $
d31 1
d93 2
a94 1
		echo "$CMDNAME: Unrecognized option: $1. Try -? for help."
a108 1
	echo ""
d111 9
a119 11
	echo "    -h HOSTNAME, --host=HOSTNAME     "
	echo "    -p PORT,     --port=PORT         "
	echo "    -U USERNAME, --username=USERNAME "
	echo "    -W,          --password          "
	echo "    -e,          --echo              "
        echo "    -q,          --quiet             "   
	echo "    -D PATH,     --location=PATH     "     
	echo "    -E ENCODING  --encoding=ENCODING "
	echo "    -?,          --help              "
	echo ""
	exit 1
d128 1
a128 1
		echo "$CMDNAME: \"$MB\" is not a valid encoding name."
d134 2
a135 1
	echo "$CMDNAME: Missing required argument database name. Try -? for help."
d140 1
d151 1
a151 1
	echo "$CMDNAME: Database creation failed."
d162 1
a162 1
	echo "$CMDNAME: Comment creation failed. (Database was created.)"
@


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
@d14 1
a14 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/createdb,v 1.3 1999/12/08 10:29:55 momjian Exp $
d124 4
a127 2
if [ "$MB" ]
then	if [ -z "`pg_encoding '$MB'`" ]
@


1.3
log
@Change $< to $+ in scripts Makefile, and clean up pg_encoding if logic.
@
text
@d14 1
a14 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/scripts/createdb,v 1.2 1999/12/07 22:41:44 momjian Exp $
a30 1
		break
a105 1

d107 14
a120 3
	echo "Usage: $CMDNAME [-h server] [-p port] [-D path] \\"
	echo "       [-E encoding] [-U username] dbname [description]"
	exit 0
@


1.2
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
@d14 1
a14 1
#    $Header: /usr/local/cvsroot/pgsql/src/bin/createdb/createdb.sh,v 1.11 1998/09/03 02:12:14 momjian Exp $
d115 6
a120 3
if [ "$MB" -a -z "`pg_encoding '$MB'`" ]; then
	echo "$CMDNAME: \"$MB\" is not a valid encoding name."
	exit 1
@


1.1
log
@New scripts for create/drop user/db from Peter Eisentraut
@
text
@d4 1
a4 1
# createdb.sh--
d24 1
d37 6
d46 6
d53 1
a53 1
		PSQLOPT="$PSQLOPT -U $2"
d55 9
d74 1
a74 1
	--dbpath|-D)
d77 6
d85 7
a91 7
		shift
		if [ -z `pg_encoding $MB` ]; then
			echo "$CMDNAME: $MB is not a valid encoding name"
			exit 1
		fi
		;;

d109 2
a110 2
	echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-D <path>] \\"
	echo "       [-E <encoding>] [-U <username>] [-W] dbname [description]"
d114 6
d126 3
d143 3
a145 1
psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS \'$dbcomment\'"
d147 1
a147 1
	echo "$CMDNAME: Comment creation failed."
d151 1
a151 1
exit 0@
