Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a1bfbc

Browse files
committed
- 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
1 parenta765db4 commit2a1bfbc

File tree

13 files changed

+590
-544
lines changed

13 files changed

+590
-544
lines changed

‎doc/src/sgml/ref/initdb.sgml

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.6 1999/12/17 01:05:29 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/initdb.sgml,v 1.7 2000/01/15 18:30:27 petere Exp $
33
Postgres documentation
44
-->
55

@@ -25,8 +25,8 @@ Postgres documentation
2525
<synopsis>
2626
initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
2727
[ --sysid|-i <replaceable class="parameter">sysid</replaceable> ]
28-
[ --password|-W <replaceable class="parameter">password</replaceable> ]
29-
[ --pgencoding|-e <replaceable class="parameter">encoding</replaceable> ]
28+
[ --pwprompt|-W ]
29+
[ --encoding|-e <replaceable class="parameter">encoding</replaceable> ]
3030
[ --pglib|-L <replaceable class="parameter">libdir</replaceable> ]
3131
[ --username|-u <replaceable class="parameter">name</replaceable> ]
3232
[ --noclean | -n ] [ --debug | -d ] [ --template | -t ]
@@ -71,20 +71,20 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
7171
</varlistentry>
7272

7373
<varlistentry>
74-
<term>--password=<replaceable class="parameter">password</replaceable></term>
75-
<term>-W <replaceable class="parameter">password</replaceable></term>
74+
<term>--pwprompt</term>
75+
<term>-W</term>
7676
<listitem>
7777
<para>
78-
Sets thepassword of the database superuser. If you don't plan
79-
on using password authentication, this is not important. If you
80-
do, youcan save yourself a trip by specifying it here, but you
81-
can always change it later. The defaultpasswordis empty.
78+
Makes initdb prompt for apassword of the database superuser. If you
79+
don't planon using password authentication, this is not important.
80+
Otherwise youwon't be able to use password authentication until
81+
you have apasswordset up.
8282
</para>
8383
</listitem>
8484
</varlistentry>
8585

8686
<varlistentry>
87-
<term>--pgencoding=<replaceable class="parameter">encoding</replaceable></term>
87+
<term>--encoding=<replaceable class="parameter">encoding</replaceable></term>
8888
<term>-e <replaceable class="parameter">encoding</replaceable></term>
8989
<listitem>
9090
<para>
@@ -246,15 +246,6 @@ initdb [ --pgdata|-D <replaceable class="parameter">dbdir</replaceable> ]
246246
it is a good idea to create the data directory before running <application>initdb</application>
247247
<emphasis>and</emphasis> to hand over the ownership of it to the database superuser.
248248
</para>
249-
250-
<para>
251-
Note that if you use the <option>--username</option> you must give correct
252-
information about the name of the <emphasis>current</emphasis> user. If you don't
253-
this will usually manifest itself in an error message about <literal>chmod</literal>
254-
failing on a file <filename>pg_pwd</filename>, because the backend silently
255-
refuses to create it.
256-
</para>
257-
258249
</refsect1>
259250
</refentry>
260251

‎src/Makefile.global.in

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.62 1999/12/13 22:32:15 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.63 2000/01/15 18:30:28 petere Exp $
1111
#
1212
# NOTES
1313
# Essentially all Postgres make files include this file and use the
@@ -158,14 +158,8 @@ X_CFLAGS= @X_CFLAGS@
158158
X_LIBS= @X_LIBS@
159159
X11_LIBS= -lX11 @X_EXTRA_LIBS@
160160

161-
#
162-
# enable multi-byte support
163-
# choose one of:
164-
# EUC_JP,EUC_CN,EUC_KR,EUC_TW,UNICODE,MULE_INTERNAL,LATIN1-5
161+
# flag whether multibyte is on/off
165162
MULTIBYTE=@MULTIBYTE@
166-
ifdef MULTIBYTE
167-
MBFLAGS = -DMULTIBYTE=$(MULTIBYTE)
168-
endif
169163

170164
##############################################################################
171165
#

‎src/backend/tcop/utility.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.78 2000/01/14 22:11:35 petere Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.79 2000/01/15 18:30:30 petere Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -359,21 +359,24 @@ ProcessUtility(Node *parsetree,
359359
aip=stmt->aclitem;
360360

361361
modechg=stmt->modechg;
362-
#ifndefNO_SECURITY
363362
foreach(i,stmt->relNames)
364-
{
363+
{
364+
Relationrel;
365+
365366
relname=strVal(lfirst(i));
367+
rel=heap_openr(relname,AccessExclusiveLock);
368+
if (rel&&rel->rd_rel->relkind==RELKIND_INDEX)
369+
elog(ERROR,"\"%s\" is an index relation",
370+
relname);
371+
/* close rel, but keep lock until end of xact */
372+
heap_close(rel,NoLock);
373+
#ifndefNO_SECURITY
366374
if (!pg_ownercheck(userName,relname,RELNAME))
367375
elog(ERROR,"you do not own class \"%s\"",
368376
relname);
369-
}
370377
#endif
371-
foreach(i,stmt->relNames)
372-
{
373-
relname=strVal(lfirst(i));
374378
ChangeAcl(relname,aip,modechg);
375379
}
376-
377380
}
378381
break;
379382

‎src/bin/initdb/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/bin/initdb/Makefile,v 1.15 1999/12/18 02:48:53 momjian Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/initdb/Makefile,v 1.16 2000/01/15 18:30:31 petere Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -17,7 +17,7 @@ include ../../Makefile.global
1717
all: initdb
1818

1919
initdb: initdb.sh
20-
sed -e's/__MULTIBYTE__/$(MULTIBYTE)/' initdb.sh> initdb
20+
sed -e's/__MULTIBYTE__/$(MULTIBYTE)/g'< initdb.sh> initdb
2121

2222
install: initdb
2323
$(INSTALL)$(INSTL_EXE_OPTS)$+$(BINDIR)

‎src/bin/initdb/initdb.sh

Lines changed: 77 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
#
2727
#
2828
# IDENTIFICATION
29-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.78 2000/01/13 18:22:10 petere Exp $
29+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.79 2000/01/15 18:30:31 petere Exp $
3030
#
3131
#-------------------------------------------------------------------------
3232

3333
exit_nicely(){
34+
sttyecho>& /dev/null
3435
echo
3536
echo"$CMDNAME failed."
3637
if ["$noclean"-eq 0 ];then
@@ -60,6 +61,18 @@ else
6061
TEMPFILE="/tmp/initdb.$$"
6162
fi
6263

64+
65+
# Check for echo -n vs echo \c
66+
ifecho'\c'| grep -s c>/dev/null2>&1
67+
then
68+
ECHO_N="echo -n"
69+
ECHO_C=""
70+
else
71+
ECHO_N="echo"
72+
ECHO_C='\c'
73+
fi
74+
75+
6376
#
6477
# Find out where we're located
6578
#
@@ -98,7 +111,7 @@ done
98111

99112
# 0 is the default (non-)encoding
100113
MULTIBYTEID=0
101-
# This is placed here by configure --with-mb=XXX.
114+
# This is placed here by configure --enable-multibyte[=XXX].
102115
MULTIBYTE=__MULTIBYTE__
103116

104117
# Set defaults:
@@ -118,8 +131,6 @@ template_only=0
118131
POSTGRES_SUPERUSERNAME="$EffectiveUser"
119132
POSTGRES_SUPERUSERID="`id -u2>/dev/null||echo 0`"
120133

121-
Password='_null_'
122-
123134
while ["$#"-gt 0 ]
124135
do
125136
case"$1"in
@@ -160,14 +171,9 @@ do
160171
POSTGRES_SUPERUSERID=`echo$1| sed's/^-i//'`
161172
;;
162173
# The default password of the database superuser.
163-
--password|-W)
164-
Password="$2"
165-
shift;;
166-
--password=*)
167-
Password=`echo$1| sed's/^--password=//'`
168-
;;
169-
-W*)
170-
Password=`echo$1| sed's/^-W//'`
174+
# Make initdb prompt for the default password of the database superuser.
175+
--pwprompt|-W)
176+
PwPrompt=1
171177
;;
172178
# Directory where to install the data. No default, unless the environment
173179
# variable PGDATA is set.
@@ -193,43 +199,43 @@ do
193199
;;
194200
# The encoding of the template1 database. Defaults to what you chose
195201
# at configure time. (see above)
196-
--pgencoding|-e)
202+
--encoding|-e)
197203
MULTIBYTE="$2"
198204
shift;;
199-
--pgencoding=*)
200-
MULTIBYTE=`echo$1| sed's/^--pgencoding=//'`
205+
--encoding=*)
206+
MULTIBYTE=`echo$1| sed's/^--encoding=//'`
201207
;;
202208
-e*)
203209
MULTIBYTE=`echo$1| sed's/^-e//'`
204210
;;
205211
*)
206-
echo"Unrecognized option '$1'. Try -? for help."
207-
exit 1
212+
PGDATA=$1
208213
;;
209214
esac
210215
shift
211216
done
212217

213-
if ["$usage" ]
214-
then
215-
echo""
216-
echo"Usage:$CMDNAME [options]"
217-
echo""
218-
echo" -t, --template"
219-
echo" -d, --debug"
220-
echo" -n, --noclean"
221-
echo" -i SYSID, --sysid=SYSID"
222-
echo" -W PASSWORD, --password=PASSWORD"
223-
echo" -u SUPERUSER, --username=SUPERUSER"
224-
echo" -D DATADIR, --pgdata=DATADIR"
225-
echo" -L LIBDIR, --pglib=LIBDIR"
226-
218+
if ["$usage" ];then
219+
echo"initdb initialized a PostgreSQL database."
220+
echo
221+
echo"Usage:"
222+
echo"$CMDNAME [options] datadir"
223+
echo
224+
echo"Options:"
225+
echo" [-D, --pgdata] <datadir> Location for this database"
226+
echo" -W, --pwprompt Prompt for a password for the new superuser's"
227227
if [-n"$MULTIBYTE" ]
228228
then
229-
echo" -e ENCODING, --pgencoding=ENCODING"
229+
echo"-e, --encoding <encoding> Set the default multibyte encoding for new databases"
230230
fi
231-
echo" -?, --help"
232-
echo""
231+
echo" -i, --sysid <sysid> Database sysid for the superuser"
232+
echo"Less commonly used options:"
233+
echo" -L, --pglib <libdir> Where to find the input files (should happend automatically"
234+
echo" -t, --template Re-initialize template database only"
235+
echo" -d, --debug Generate lots of debugging output"
236+
echo" -n, --noclean Do not clean up after errors"
237+
echo
238+
echo"Report bugs to <bugs@postgresql.org>."
233239
exit 0
234240
fi
235241

@@ -239,17 +245,18 @@ fi
239245

240246
if ["$MULTIBYTE" ]
241247
then
242-
MULTIBYTEID=`$PGPATH/pg_encoding$MULTIBYTE`
248+
MULTIBYTEID=`$PGPATH/pg_encoding$MULTIBYTE2> /dev/null`
243249
if ["$?"-ne 0 ]
244250
then
245-
echo"The program pg_encoding failed. Perhaps you did not configure"
246-
echo"PostgreSQL for multibyte support or the program was not success-"
247-
echo"fully installed."
251+
echo"$CMDNAME: pg_encoding failed"
252+
echo
253+
echo"Perhaps you did not configure PostgreSQL for multibyte support or"
254+
echo"the program was not successfully installed."
248255
exit 1
249256
fi
250257
if [-z"$MULTIBYTEID" ]
251258
then
252-
echo"$CMDNAME:$MULTIBYTE is not a valid encoding name."
259+
echo"$CMDNAME:$MULTIBYTE is not a valid encoding name"
253260
exit 1
254261
fi
255262
fi
@@ -273,7 +280,7 @@ fi
273280

274281
if!echo"$PGDATA"| grep'^/'> /dev/null2>&1
275282
then
276-
echo"$CMDNAME:Thedata path must be specified as an absolute path."
283+
echo"$CMDNAME: data path must be specified as an absolute path"
277284
exit 1
278285
fi
279286

@@ -284,8 +291,7 @@ fi
284291
# This means they have neither 'id' nor 'whoami'!
285292
if [-z"$POSTGRES_SUPERUSERNAME" ]
286293
then
287-
echo"$CMDNAME: Could not determine what the name of the database"
288-
echo"superuser should be. Please use the --username option."
294+
echo"$CMDNAME: Could not the determine current username. Please use the -u option."
289295
exit 1
290296
fi
291297

@@ -431,7 +437,6 @@ then
431437
cat"$GLOBAL" \
432438
| sed -e"s/POSTGRES/$POSTGRES_SUPERUSERNAME/g" \
433439
-e"s/PGUID/$POSTGRES_SUPERUSERID/g" \
434-
-e"s/PASSWORD/$Password/g" \
435440
|"$PGPATH"/postgres$BACKENDARGS template1 \
436441
|| exit_nicely
437442

@@ -470,17 +475,35 @@ echo "CREATE TRIGGER pg_sync_pg_pwd AFTER INSERT OR UPDATE OR DELETE ON pg_shado
470475
"FOR EACH ROW EXECUTE PROCEDURE update_pg_pwd()" \
471476
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
472477

473-
# Create the initial pg_pwd (flat-file copy of pg_shadow)
474-
echo"Writing password file."
475-
echo"COPY pg_shadow TO '$PGDATA/pg_pwd' USING DELIMITERS '\\t'" \
478+
# needs to be done before alter user
479+
echo"REVOKE ALL on pg_shadow FROM public" \
476480
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
477481

478-
# An ordinary COPY will leave the file too loosely protected.
479-
# Note: If you lied above and specified a --username different from the one
480-
# you really are, this will manifest itself in this command failing because
481-
# of a missing file, since the COPY command above failed. It would perhaps
482-
# be better if postgres returned an error code.
483-
chmod go-rw"$PGDATA"/pg_pwd|| exit_nicely
482+
# set up password
483+
if ["$PwPrompt" ];then
484+
$ECHO_N"Enter new superuser password:"$ECHO_C
485+
stty -echo>& /dev/null
486+
read FirstPw
487+
sttyecho>& /dev/null
488+
echo
489+
$ECHO_N"Enter it again:"$ECHO_C
490+
stty -echo>& /dev/null
491+
read SecondPw
492+
sttyecho>& /dev/null
493+
echo
494+
if ["$FirstPw"!="$SecondPw" ];then
495+
echo"Passwords didn't match."
496+
exit_nicely
497+
fi
498+
echo"ALTER USER\"$POSTGRES_SUPERUSERNAME\" WITH PASSWORD '$FirstPw'" \
499+
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
500+
if [!-f$PGDATA/pg_pwd ];then
501+
echo"The password file wasn't generated. Please report this problem."
502+
exit_nicely
503+
fi
504+
echo"Setting password"
505+
fi
506+
484507

485508
echo"Creating view pg_user."
486509
echo"CREATE VIEW pg_user AS\
@@ -496,9 +519,6 @@ echo "CREATE VIEW pg_user AS \
496519
FROM pg_shadow" \
497520
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
498521

499-
echo"REVOKE ALL on pg_shadow FROM public" \
500-
|"$PGPATH"/postgres$PGSQL_OPT template1> /dev/null|| exit_nicely
501-
502522
echo"Creating view pg_rules."
503523
echo"CREATE VIEW pg_rules AS\
504524
SELECT\
@@ -569,9 +589,9 @@ echo "VACUUM ANALYZE" \
569589

570590
echo
571591
echo"$CMDNAME completed successfully. You can now start the database server."
572-
echo"($PGPATH/postmaster -D$PGDATA)"
592+
echo"$PGPATH/postmaster -D$PGDATA"
573593
echo"or"
574-
echo"($PGPATH/pg_ctl -D$PGDATA start)"
594+
echo"$PGPATH/pg_ctl -D$PGDATA start"
575595
echo
576596

577597
exit 0

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp