diff options
| author | Peter Eisentraut | 2000-01-15 18:30:35 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2000-01-15 18:30:35 +0000 |
| commit | 2a1bfbce24c5a34a9fbe82d3569b96459cb898cf (patch) | |
| tree | f96839a43babadb9fc3370392058eb775007efa3 /src/bin | |
| parent | a765db409b4b0e0b5298ec31f66894b1c9f0eca5 (diff) | |
- Allow array on int8
- Prevent permissions on indexes
- Instituted --enable-multibyte option and tweaked the MB build process where necessary
- initdb prompts for superuser password
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/initdb/Makefile | 4 | ||||
| -rw-r--r-- | src/bin/initdb/initdb.sh | 134 | ||||
| -rw-r--r-- | src/bin/pg_encoding/Makefile | 17 | ||||
| -rw-r--r-- | src/bin/pg_encoding/pg_encoding.c | 4 |
4 files changed, 93 insertions, 66 deletions
diff --git a/src/bin/initdb/Makefile b/src/bin/initdb/Makefile index 7cfb0479fae..f9249f12dbf 100644 --- a/src/bin/initdb/Makefile +++ b/src/bin/initdb/Makefile @@ -7,7 +7,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/bin/initdb/Makefile,v 1.15 1999/12/18 02:48:53 momjian Exp $ +# $Header: /cvsroot/pgsql/src/bin/initdb/Makefile,v 1.16 2000/01/15 18:30:31 petere Exp $ # #------------------------------------------------------------------------- @@ -17,7 +17,7 @@ include ../../Makefile.global all: initdb initdb: initdb.sh - sed -e 's/__MULTIBYTE__/$(MULTIBYTE)/' initdb.sh > initdb + sed -e 's/__MULTIBYTE__/$(MULTIBYTE)/g' < initdb.sh > initdb install: initdb $(INSTALL) $(INSTL_EXE_OPTS) $+ $(BINDIR) diff --git a/src/bin/initdb/initdb.sh b/src/bin/initdb/initdb.sh index c73b2cd0b1a..14fd35ebcd3 100644 --- a/src/bin/initdb/initdb.sh +++ b/src/bin/initdb/initdb.sh @@ -26,11 +26,12 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.78 2000/01/13 18:22:10 petere Exp $ +# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.79 2000/01/15 18:30:31 petere Exp $ # #------------------------------------------------------------------------- exit_nicely(){ + stty echo >& /dev/null echo echo "$CMDNAME failed." if [ "$noclean" -eq 0 ]; then @@ -60,6 +61,18 @@ else TEMPFILE="/tmp/initdb.$$" fi + +# 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 + + # # Find out where we're located # @@ -98,7 +111,7 @@ done # 0 is the default (non-)encoding MULTIBYTEID=0 -# This is placed here by configure --with-mb=XXX. +# This is placed here by configure --enable-multibyte[=XXX]. MULTIBYTE=__MULTIBYTE__ # Set defaults: @@ -118,8 +131,6 @@ template_only=0 POSTGRES_SUPERUSERNAME="$EffectiveUser" POSTGRES_SUPERUSERID="`id -u 2>/dev/null || echo 0`" -Password='_null_' - while [ "$#" -gt 0 ] do case "$1" in @@ -160,14 +171,9 @@ do POSTGRES_SUPERUSERID=`echo $1 | sed 's/^-i//'` ;; # The default password of the database superuser. - --password|-W) - Password="$2" - shift;; - --password=*) - Password=`echo $1 | sed 's/^--password=//'` - ;; - -W*) - Password=`echo $1 | sed 's/^-W//'` +# Make initdb prompt for the default password of the database superuser. + --pwprompt|-W) + PwPrompt=1 ;; # Directory where to install the data. No default, unless the environment # variable PGDATA is set. @@ -193,43 +199,43 @@ do ;; # The encoding of the template1 database. Defaults to what you chose # at configure time. (see above) - --pgencoding|-e) + --encoding|-e) MULTIBYTE="$2" shift;; - --pgencoding=*) - MULTIBYTE=`echo $1 | sed 's/^--pgencoding=//'` + --encoding=*) + MULTIBYTE=`echo $1 | sed 's/^--encoding=//'` ;; -e*) MULTIBYTE=`echo $1 | sed 's/^-e//'` ;; *) - echo "Unrecognized option '$1'. Try -? for help." - exit 1 + PGDATA=$1 ;; esac shift done -if [ "$usage" ] -then - echo "" - echo "Usage: $CMDNAME [options]" - echo "" - echo " -t, --template " - echo " -d, --debug " - echo " -n, --noclean " - echo " -i SYSID, --sysid=SYSID " - echo " -W PASSWORD, --password=PASSWORD " - echo " -u SUPERUSER, --username=SUPERUSER " - echo " -D DATADIR, --pgdata=DATADIR " - echo " -L LIBDIR, --pglib=LIBDIR " - +if [ "$usage" ]; then + echo "initdb initialized a PostgreSQL database." + echo + echo "Usage:" + echo " $CMDNAME [options] datadir" + echo + echo "Options:" + echo " [-D, --pgdata] <datadir> Location for this database" + echo " -W, --pwprompt Prompt for a password for the new superuser's" if [ -n "$MULTIBYTE" ] then - echo " -e ENCODING, --pgencoding=ENCODING" + echo " -e, --encoding <encoding> Set the default multibyte encoding for new databases" fi - echo " -?, --help " - echo "" + echo " -i, --sysid <sysid> Database sysid for the superuser" + echo "Less commonly used options: " + echo " -L, --pglib <libdir> Where to find the input files (should happend automatically" + echo " -t, --template Re-initialize template database only" + 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>." exit 0 fi @@ -239,17 +245,18 @@ fi if [ "$MULTIBYTE" ] then - MULTIBYTEID=`$PGPATH/pg_encoding $MULTIBYTE` + MULTIBYTEID=`$PGPATH/pg_encoding $MULTIBYTE 2> /dev/null` if [ "$?" -ne 0 ] then - echo "The program pg_encoding failed. Perhaps you did not configure" - echo "PostgreSQL for multibyte support or the program was not success-" - echo "fully installed." + echo "$CMDNAME: pg_encoding failed" + echo + echo "Perhaps you did not configure PostgreSQL for multibyte support or" + echo "the program was not successfully installed." exit 1 fi if [ -z "$MULTIBYTEID" ] then - echo "$CMDNAME: $MULTIBYTE is not a valid encoding name." + echo "$CMDNAME: $MULTIBYTE is not a valid encoding name" exit 1 fi fi @@ -273,7 +280,7 @@ fi if ! echo "$PGDATA" | grep '^/' > /dev/null 2>&1 then - echo "$CMDNAME: The data path must be specified as an absolute path." + echo "$CMDNAME: data path must be specified as an absolute path" exit 1 fi @@ -284,8 +291,7 @@ fi # This means they have neither 'id' nor 'whoami'! if [ -z "$POSTGRES_SUPERUSERNAME" ] then - echo "$CMDNAME: Could not determine what the name of the database" - echo "superuser should be. Please use the --username option." + echo "$CMDNAME: Could not the determine current username. Please use the -u option." exit 1 fi @@ -431,7 +437,6 @@ then cat "$GLOBAL" \ | sed -e "s/POSTGRES/$POSTGRES_SUPERUSERNAME/g" \ -e "s/PGUID/$POSTGRES_SUPERUSERID/g" \ - -e "s/PASSWORD/$Password/g" \ | "$PGPATH"/postgres $BACKENDARGS template1 \ || exit_nicely @@ -470,17 +475,35 @@ echo "CREATE TRIGGER pg_sync_pg_pwd AFTER INSERT OR UPDATE OR DELETE ON pg_shado "FOR EACH ROW EXECUTE PROCEDURE update_pg_pwd()" \ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely -# Create the initial pg_pwd (flat-file copy of pg_shadow) -echo "Writing password file." -echo "COPY pg_shadow TO '$PGDATA/pg_pwd' USING DELIMITERS '\\t'" \ +# needs to be done before alter user +echo "REVOKE ALL on pg_shadow FROM public" \ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely -# An ordinary COPY will leave the file too loosely protected. -# Note: If you lied above and specified a --username different from the one -# you really are, this will manifest itself in this command failing because -# of a missing file, since the COPY command above failed. It would perhaps -# be better if postgres returned an error code. -chmod go-rw "$PGDATA"/pg_pwd || exit_nicely +# set up password +if [ "$PwPrompt" ]; then + $ECHO_N "Enter new superuser password: "$ECHO_C + stty -echo >& /dev/null + read FirstPw + stty echo >& /dev/null + echo + $ECHO_N "Enter it again: "$ECHO_C + stty -echo >& /dev/null + read SecondPw + stty echo >& /dev/null + echo + if [ "$FirstPw" != "$SecondPw" ]; then + echo "Passwords didn't match." + exit_nicely + fi + echo "ALTER USER \"$POSTGRES_SUPERUSERNAME\" WITH PASSWORD '$FirstPw'" \ + | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely + if [ ! -f $PGDATA/pg_pwd ]; then + echo "The password file wasn't generated. Please report this problem." + exit_nicely + fi + echo "Setting password" +fi + echo "Creating view pg_user." echo "CREATE VIEW pg_user AS \ @@ -496,9 +519,6 @@ echo "CREATE VIEW pg_user AS \ FROM pg_shadow" \ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely -echo "REVOKE ALL on pg_shadow FROM public" \ - | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely - echo "Creating view pg_rules." echo "CREATE VIEW pg_rules AS \ SELECT \ @@ -569,9 +589,9 @@ echo "VACUUM ANALYZE" \ echo echo "$CMDNAME completed successfully. You can now start the database server." -echo "($PGPATH/postmaster -D $PGDATA)" +echo " $PGPATH/postmaster -D $PGDATA" echo "or" -echo "($PGPATH/pg_ctl -D $PGDATA start)" +echo " $PGPATH/pg_ctl -D $PGDATA start" echo exit 0 diff --git a/src/bin/pg_encoding/Makefile b/src/bin/pg_encoding/Makefile index 29e33af26f9..ddad3ecb281 100644 --- a/src/bin/pg_encoding/Makefile +++ b/src/bin/pg_encoding/Makefile @@ -6,21 +6,28 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/Makefile,v 1.3 1999/06/05 10:27:31 ishii Exp $ +# $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/Makefile,v 1.4 2000/01/15 18:30:32 petere Exp $ # #------------------------------------------------------------------------- SRCDIR= ../.. include ../../Makefile.global +# This is a bit of hackery here: pg_encoding uses backend includes and the +# frontend library. + OBJS= pg_encoding.o +CFLAGS:= -I$(SRCDIR)/include $(CFLAGS) + +all: submake pg_encoding -CFLAGS+= $(MBFLAGS) -I$(SRCDIR)/include +pg_encoding: $(OBJS) + $(CC) -o pg_encoding $(OBJS) -L$(LIBPQDIR) -lpq $(LDFLAGS) $(CFLAGS) -all: pg_encoding +.PHONY: submake -pg_encoding: $(OBJS) $(LIBPQDIR)/libpq.a - $(CC) -o pg_encoding $(OBJS) -L$(LIBPQDIR) -lpq $(LDFLAGS) +submake: + $(MAKE) -C $(LIBPQDIR) libpq.a install: pg_encoding $(INSTALL) $(INSTL_EXE_OPTS) pg_encoding$(X) $(BINDIR)/pg_encoding$(X) diff --git a/src/bin/pg_encoding/pg_encoding.c b/src/bin/pg_encoding/pg_encoding.c index ce5a8d87270..905495a37f7 100644 --- a/src/bin/pg_encoding/pg_encoding.c +++ b/src/bin/pg_encoding/pg_encoding.c @@ -7,11 +7,11 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.5 1999/12/16 20:10:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.6 2000/01/15 18:30:32 petere Exp $ * *------------------------------------------------------------------------- */ -#include "postgres.h" +#include "c.h" #include "mb/pg_wchar.h" static void usage(void); |
