Skip to content

Commit 648677c

Browse files
committed
Add assert checking to GUC ("debug_assertions")
Rename settings net_server to tcpip_socket, max_backends to max_connections Add --help and --version to postmaster, reformat help output
1 parent cbdaa27 commit 648677c

File tree

5 files changed

+127
-66
lines changed

5 files changed

+127
-66
lines changed

doc/src/sgml/runtime.sgml

+27-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.12 2000/06/22 22:31:15 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.13 2000/07/12 17:38:41 petere Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -671,6 +671,19 @@ env PGOPTIONS='--geqo=off' psql
671671

672672
<para>
673673
<variablelist>
674+
<varlistentry>
675+
<term>DEBUG_ASSERTIONS (<type>boolean</type>)</term>
676+
<listitem>
677+
<para>
678+
Turns on various assertion checks. This is a debugging aid. If
679+
you are experiencing strange problems or crashes you might
680+
want to turn this on, as it might expose programming mistakes.
681+
To use this option, the macro <literal>USE_ASSERT_CHECKING</>
682+
must be defined when Postgres is built.
683+
</para>
684+
</listitem>
685+
</varlistentry>
686+
674687
<varlistentry>
675688
<term>DEBUG_LEVEL (<type>integer</type>)</term>
676689
<listitem>
@@ -843,13 +856,13 @@ env PGOPTIONS='--geqo=off' psql
843856
</varlistentry>
844857

845858
<varlistentry>
846-
<term>MAX_BACKENDS (<type>integer</type>)</term>
859+
<term>MAX_CONNECTIONS (<type>integer</type>)</term>
847860
<listitem>
848861
<para>
849862
Determines how many concurrent connections the database server
850-
will allow. The default is 32. Note that there is also a
851-
compiled-in hard limit on this option, which is currently
852-
1024. This parameter can only be set at server start.
863+
will allow. The default is 32. There is also a compiled-in
864+
hard upper limit on this option, which is currently 1024. This
865+
parameter can only be set at server start.
853866
</para>
854867
</listitem>
855868
</varlistentry>
@@ -868,7 +881,7 @@ env PGOPTIONS='--geqo=off' psql
868881
</varlistentry>
869882

870883
<varlistentry>
871-
<term>NET_SERVER (<type>boolean</type>)</term>
884+
<term>TCPIP_SOCKET (<type>boolean</type>)</term>
872885
<listitem>
873886
<para>
874887
If this is true, then the server will accept TCP/IP
@@ -922,12 +935,12 @@ env PGOPTIONS='--geqo=off' psql
922935
This controls the inheritance semantics, in particular whether
923936
subtables are included into the consideration of various
924937
commands by default. This was not the case in versions prior
925-
to 7.1. If you need this behaviour you can set this variable
926-
to off, but in the long run you are encouraged to change your
927-
applications to use the <literal>ONLY</literal> keyword to
928-
exclude subtables. See the SQL language reference and the
929-
<citetitle>User's Guide</citetitle> for more information about
930-
inheritance.
938+
to 7.1. If you need the old behaviour you can set this
939+
variable to off, but in the long run you are encouraged to
940+
change your applications to use the <literal>ONLY</literal>
941+
keyword to exclude subtables. See the SQL language reference
942+
and the <citetitle>User's Guide</citetitle> for more
943+
information about inheritance.
931944
</para>
932945
</listitem>
933946
</varlistentry>
@@ -971,12 +984,12 @@ env PGOPTIONS='--geqo=off' psql
971984
</row>
972985
<row>
973986
<entry>-i</entry>
974-
<entry>net_server = on</entry>
987+
<entry>tcpip_socket = on</entry>
975988
<entry></entry>
976989
</row>
977990
<row>
978991
<entry>-N <replaceable>x</replaceable></entry>
979-
<entry>max_backends = <replaceable>x</replaceable></entry>
992+
<entry>max_connections = <replaceable>x</replaceable></entry>
980993
<entry></entry>
981994
</row>
982995
<row>

src/backend/postmaster/postmaster.c

+85-40
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.154 2000/07/09 13:14:05 petere Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.155 2000/07/12 17:38:42 petere Exp $
1515
*
1616
* NOTES
1717
*
@@ -280,11 +280,6 @@ void GetCharSetByHost(char *, int, char *);
280280

281281
#endif
282282

283-
#ifdef USE_ASSERT_CHECKING
284-
285-
int assert_enabled = 1;
286-
287-
#endif
288283

289284
static void
290285
checkDataDir(const char *DataDir)
@@ -387,13 +382,46 @@ PostmasterMain(int argc, char *argv[])
387382
* will occur.
388383
*/
389384
opterr = 1;
390-
while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:")) != EOF)
385+
while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:?")) != EOF)
391386
{
392-
if (opt == 'D')
387+
switch(opt)
393388
{
394-
if (DataDir)
395-
free(DataDir);
396-
DataDir = strdup(optarg);
389+
case 'D':
390+
if (DataDir)
391+
free(DataDir);
392+
DataDir = strdup(optarg);
393+
break;
394+
395+
case '-':
396+
{
397+
char *name, *value;
398+
399+
ParseLongOption(optarg, &name, &value);
400+
if (strcmp(name, "help")==0)
401+
{
402+
usage(progname);
403+
exit(0);
404+
}
405+
else if (strcmp(name, "version")==0)
406+
{
407+
puts("postmaster (PostgreSQL) " PG_VERSION);
408+
exit(0);
409+
}
410+
break;
411+
}
412+
413+
case '?':
414+
if (strcmp(argv[optind - 1], "-?") == 0)
415+
{
416+
usage(progname);
417+
exit(0);
418+
}
419+
else
420+
{
421+
fprintf(stderr, "Try -? for help.\n");
422+
exit(1);
423+
}
424+
break;
397425
}
398426
}
399427

@@ -403,21 +431,15 @@ PostmasterMain(int argc, char *argv[])
403431
ProcessConfigFile(PGC_POSTMASTER);
404432

405433
IgnoreSystemIndexes(false);
406-
while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:")) != EOF)
434+
while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:Ss-:?")) != EOF)
407435
{
408436
switch (opt)
409437
{
410438
case 'A':
411439
#ifndef USE_ASSERT_CHECKING
412-
fprintf(stderr, "Assert checking is not enabled\n");
440+
fprintf(stderr, "Assert checking is not compiled in\n");
413441
#else
414-
415-
/*
416-
* Pass this option also to each backend.
417-
*/
418442
assert_enabled = atoi(optarg);
419-
strcat(ExtraOptions, " -A ");
420-
strcat(ExtraOptions, optarg);
421443
#endif
422444
break;
423445
case 'a':
@@ -525,13 +547,23 @@ PostmasterMain(int argc, char *argv[])
525547
free(value);
526548
break;
527549
}
550+
528551
default:
529-
/* usage() never returns */
530-
usage(progname);
531-
break;
552+
/* shouldn't get here */
553+
fprintf(stderr, "Try -? for help.\n");
554+
exit(1);
532555
}
533556
}
534557

558+
/*
559+
* Non-option switch arguments don't exist.
560+
*/
561+
if (optind < argc)
562+
{
563+
fprintf(stderr, "%s: invalid argument -- %s\n", progname, argv[optind]);
564+
exit(1);
565+
}
566+
535567
/*
536568
* Check for invalid combinations of switches
537569
*/
@@ -543,7 +575,7 @@ PostmasterMain(int argc, char *argv[])
543575
* for lack of buffers. The specific choices here are somewhat
544576
* arbitrary.
545577
*/
546-
fprintf(stderr, "%s: -B must be at least twice -N and at least 16.\n",
578+
fprintf(stderr, "%s: The number of buffers (-B) must be at least twice the number of allowed connections (-N) and at least 16.\n",
547579
progname);
548580
exit(1);
549581
}
@@ -717,30 +749,43 @@ pmdaemonize(int argc, char *argv[])
717749
on_proc_exit(UnlinkPidFile, NULL);
718750
}
719751

752+
753+
754+
/*
755+
* Print out help message
756+
*/
720757
static void
721758
usage(const char *progname)
722759
{
723-
fprintf(stderr, "usage: %s [options]\n", progname);
760+
printf("%s is the PostgreSQL server.\n\n", progname);
761+
printf("Usage:\n %s [options]\n\n", progname);
762+
printf("Options:\n");
724763
#ifdef USE_ASSERT_CHECKING
725-
fprintf(stderr, "\t-A [1|0]\tenable/disable runtime assert checking\n");
764+
printf(" -A 1|0 enable/disable runtime assert checking\n");
726765
#endif
727-
fprintf(stderr, "\t-B nbufs\tset number of shared buffers\n");
728-
fprintf(stderr, "\t-D datadir\tset data directory\n");
729-
fprintf(stderr, "\t-S \t\tsilent mode (disassociate from tty)\n");
730-
fprintf(stderr, "\t-a system\tuse this authentication system\n");
731-
fprintf(stderr, "\t-b backend\tuse a specific backend server executable\n");
732-
fprintf(stderr, "\t-d [1-5]\tset debugging level\n");
733-
fprintf(stderr, "\t-i \t\tlisten on TCP/IP sockets as well as Unix domain socket\n");
766+
printf(" -B <buffers> number of shared buffers\n");
767+
printf(" -d 1-5 debugging level\n");
768+
printf(" -D <directory> database directory\n");
769+
printf(" -F turn fsync off\n");
770+
printf(" -i listen on TCP/IP sockets\n");
734771
#ifdef USE_SSL
735-
fprintf(stderr, " \t-l \t\tfor TCP/IP sockets, listen only on SSL connections\n");
772+
printf(" -l listen only on SSL connections (EXPERIMENTAL)\n");
736773
#endif
737-
fprintf(stderr, "\t-N nprocs\tset max number of backends (1..%d, default %d)\n",
774+
printf(" -N <number> maximum number of allowed connections (1..%d, default %d)\n",
738775
MAXBACKENDS, DEF_MAXBACKENDS);
739-
fprintf(stderr, "\t-n \t\tdon't reinitialize shared memory after abnormal exit\n");
740-
fprintf(stderr, "\t-o option\tpass 'option' to each backend servers\n");
741-
fprintf(stderr, "\t-p port\tspecify port for postmaster to listen on\n");
742-
fprintf(stderr, "\t-s \t\tsend SIGSTOP to all backend servers if one dies\n");
743-
exit(1);
776+
printf(" -o <option> pass `option' to each backend server\n");
777+
printf(" -p <port> port number to listen on\n");
778+
printf(" -S silent mode (dissociate from tty)\n");
779+
780+
printf("\nDeveloper options:\n");
781+
printf(" -n don't reinitialize shared memory after abnormal exit\n");
782+
printf(" -s send SIGSTOP to all backend servers if one dies\n");
783+
784+
printf("\nPlease read the documentation for the complete list of runtime\n"
785+
"configuration settings and how to set them on the command line or in\n"
786+
"the configuration file.\n\n");
787+
788+
printf("Report bugs to <pgsql-bugs@postgresql.org>.\n");
744789
}
745790

746791
static int
@@ -1231,7 +1276,7 @@ reset_shared(int port)
12311276

12321277

12331278
/*
1234-
* set flag is SIGHUP was detected so config file can be reread in
1279+
* Set flag if SIGHUP was detected so config file can be reread in
12351280
* main loop
12361281
*/
12371282
static void

src/backend/tcop/postgres.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.168 2000/07/11 14:30:27 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.169 2000/07/12 17:38:45 petere Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -907,14 +907,10 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
907907
switch (flag)
908908
{
909909
case 'A':
910-
/* ----------------
911-
* enable/disable assert checking.
912-
* ----------------
913-
*/
914910
#ifdef USE_ASSERT_CHECKING
915911
assert_enabled = atoi(optarg);
916912
#else
917-
fprintf(stderr, "Assert checking is not enabled\n");
913+
fprintf(stderr, "Assert checking is not compiled in\n");
918914
#endif
919915
break;
920916

@@ -1415,7 +1411,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
14151411
if (!IsUnderPostmaster)
14161412
{
14171413
puts("\nPOSTGRES backend interactive interface ");
1418-
puts("$Revision: 1.168 $ $Date: 2000/07/11 14:30:27 $\n");
1414+
puts("$Revision: 1.169 $ $Date: 2000/07/12 17:38:45 $\n");
14191415
}
14201416

14211417
/*

src/backend/utils/misc/guc.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Support for grand unified configuration scheme, including SET
55
* command, configuration file, and command line options.
66
*
7-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.5 2000/07/03 20:46:05 petere Exp $
7+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.6 2000/07/12 17:38:48 petere Exp $
88
*
99
* Copyright 2000 by PostgreSQL Global Development Group
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -37,6 +37,9 @@ extern bool Log_connections;
3737
/*
3838
* Debugging options
3939
*/
40+
#ifdef USE_ASSERT_CHECKING
41+
bool assert_enabled;
42+
#endif
4043
bool Debug_print_query = false;
4144
bool Debug_print_plan = false;
4245
bool Debug_print_parse = false;
@@ -150,13 +153,17 @@ ConfigureNamesBool[] =
150153
{"ksqo", PGC_USERSET, &_use_keyset_query_optimizer, false},
151154
{"geqo", PGC_USERSET, &enable_geqo, true},
152155

153-
{"net_server", PGC_POSTMASTER, &NetServer, false},
156+
{"tcpip_socket", PGC_POSTMASTER, &NetServer, false},
154157
{"fsync", PGC_USERSET, &enableFsync, true},
155158

156159
{"log_connections", PGC_SIGHUP, &Log_connections, false},
157160
{"log_timestamp", PGC_SIGHUP, &Log_timestamp, false},
158161
{"log_pid", PGC_SIGHUP, &Log_pid, false},
159162

163+
#ifdef USE_ASSERT_CHECKING
164+
{"debug_assertions", PGC_USERSET, &assert_enabled, false},
165+
#endif
166+
160167
{"debug_print_query", PGC_USERSET, &Debug_print_query, false},
161168
{"debug_print_parse", PGC_USERSET, &Debug_print_parse, false},
162169
{"debug_print_rewritten", PGC_USERSET, &Debug_print_rewritten, false},
@@ -216,7 +223,7 @@ ConfigureNamesInt[] =
216223
* make sure the buffers are at least twice the number of
217224
* backends, so the constraints here are partially unused.
218225
*/
219-
{"max_backends", PGC_POSTMASTER, &MaxBackends,
226+
{"max_connections", PGC_POSTMASTER, &MaxBackends,
220227
DEF_MAXBACKENDS, 1, MAXBACKENDS},
221228
{"shmem_buffers", PGC_POSTMASTER, &NBuffers,
222229
DEF_NBUFFERS, 16, INT_MAX},

src/include/c.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: c.h,v 1.76 2000/07/07 21:12:47 tgl Exp $
11+
* $Id: c.h,v 1.77 2000/07/12 17:38:53 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -706,7 +706,7 @@ typedef struct Exception
706706
#define AssertState(condition) \
707707
Trap(!(condition), BadState)
708708

709-
extern int assert_enabled;
709+
extern bool assert_enabled;
710710

711711
#endif /* USE_ASSERT_CHECKING */
712712

0 commit comments

Comments
 (0)