Skip to content

Commit 929a599

Browse files
committed
Add '-c name=val' flag for setting run-time parameters.
1 parent 3304341 commit 929a599

File tree

3 files changed

+27
-13
lines changed

3 files changed

+27
-13
lines changed

doc/src/sgml/runtime.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.31 2000/11/01 21:14:00 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.32 2000/11/08 17:57:45 petere Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -411,7 +411,7 @@ syslog = 2
411411
A second way to set these configuration parameters is to give them
412412
as a command line option to the postmaster, such as
413413
<programlisting>
414-
postmaster --log-connections=yes --syslog=2
414+
postmaster -c log_connections=yes -c syslog=2
415415
</programlisting>
416416
which would have the same effect as the previous example.
417417
</para>
@@ -422,7 +422,7 @@ postmaster --log-connections=yes --syslog=2
422422
<envar>PGOPTIONS</envar> can be used for this purpose on the
423423
client side:
424424
<programlisting>
425-
env PGOPTIONS='--geqo=off' psql
425+
env PGOPTIONS='-c geqo=off' psql
426426
</programlisting>
427427
(This works for any client application, not just
428428
<application>psql</application>.) Note that this won't work for

src/backend/postmaster/postmaster.c

Lines changed: 13 additions & 6 deletions
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.179 2000/11/06 22:18:06 petere Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.180 2000/11/08 17:57:46 petere Exp $
1515
*
1616
* NOTES
1717
*
@@ -372,7 +372,7 @@ PostmasterMain(int argc, char *argv[])
372372
* will occur.
373373
*/
374374
opterr = 1;
375-
while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:SsV-:?")) != EOF)
375+
while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Film:MN:no:p:SsV-:?")) != EOF)
376376
{
377377
switch(opt)
378378
{
@@ -428,7 +428,7 @@ PostmasterMain(int argc, char *argv[])
428428
#ifdef HAVE_INT_OPTRESET
429429
optreset = 1;
430430
#endif
431-
while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:SsV-:?")) != EOF)
431+
while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Film:MN:no:p:SsV-:?")) != EOF)
432432
{
433433
switch (opt)
434434
{
@@ -530,13 +530,19 @@ PostmasterMain(int argc, char *argv[])
530530
*/
531531
SendStop = true;
532532
break;
533+
case 'c':
533534
case '-':
534535
{
535536
char *name, *value;
536537

537538
ParseLongOption(optarg, &name, &value);
538539
if (!value)
539-
elog(ERROR, "--%s requires argument", optarg);
540+
{
541+
if (opt == '-')
542+
elog(ERROR, "--%s requires argument", optarg);
543+
else
544+
elog(ERROR, "-c %s requires argument", optarg);
545+
}
540546

541547
SetConfigOption(name, value, PGC_POSTMASTER);
542548
free(name);
@@ -766,6 +772,7 @@ usage(const char *progname)
766772
printf(" -A 1|0 enable/disable runtime assert checking\n");
767773
#endif
768774
printf(" -B <buffers> number of shared buffers\n");
775+
printf(" -c <name>=<value> set run-time parameter\n");
769776
printf(" -d 1-5 debugging level\n");
770777
printf(" -D <directory> database directory\n");
771778
printf(" -F turn fsync off\n");
@@ -775,15 +782,15 @@ usage(const char *progname)
775782
#endif
776783
printf(" -N <number> maximum number of allowed connections (1..%d, default %d)\n",
777784
MAXBACKENDS, DEF_MAXBACKENDS);
778-
printf(" -o <option> pass `option' to each backend server\n");
785+
printf(" -o <option> pass 'option' to each backend server\n");
779786
printf(" -p <port> port number to listen on\n");
780787
printf(" -S silent mode (dissociate from tty)\n");
781788

782789
printf("\nDeveloper options:\n");
783790
printf(" -n don't reinitialize shared memory after abnormal exit\n");
784791
printf(" -s send SIGSTOP to all backend servers if one dies\n");
785792

786-
printf("\nPlease read the documentation for the complete list of runtime\n"
793+
printf("\nPlease read the documentation for the complete list of run-time\n"
787794
"configuration settings and how to set them on the command line or in\n"
788795
"the configuration file.\n\n");
789796

src/backend/tcop/postgres.c

Lines changed: 11 additions & 4 deletions
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.186 2000/11/06 22:18:08 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.187 2000/11/08 17:57:46 petere Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -1010,6 +1010,7 @@ usage(char *progname)
10101010
fprintf(stderr, "\t-A on\t\tenable/disable assert checking\n");
10111011
#endif
10121012
fprintf(stderr, "\t-B buffers\tset number of buffers in buffer pool\n");
1013+
fprintf(stderr, "\t-c name=value\tset run-time parameter\n");
10131014
fprintf(stderr, "\t-C \t\tsuppress version info\n");
10141015
fprintf(stderr, "\t-D dir\t\tdata directory\n");
10151016
fprintf(stderr, "\t-E \t\techo query before execution\n");
@@ -1112,7 +1113,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
11121113

11131114
optind = 1; /* reset after postmaster's usage */
11141115

1115-
while ((flag = getopt(argc, argv, "A:B:CD:d:Eef:FiLNOPo:p:S:st:v:VW:x:-:?")) != EOF)
1116+
while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiLNOPo:p:S:st:v:VW:x:-:?")) != EOF)
11161117
switch (flag)
11171118
{
11181119
case 'A':
@@ -1383,6 +1384,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
13831384
#endif
13841385
break;
13851386

1387+
case 'c':
13861388
case '-':
13871389
{
13881390
char *name, *value;
@@ -1399,7 +1401,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
13991401
exit(0);
14001402
}
14011403
if (!value)
1402-
elog(ERROR, "--%s requires argument", optarg);
1404+
{
1405+
if (flag == '-')
1406+
elog(ERROR, "--%s requires argument", optarg);
1407+
else
1408+
elog(ERROR, "-c %s requires argument", optarg);
1409+
}
14031410

14041411
SetConfigOption(name, value, PGC_BACKEND);
14051412
free(name);
@@ -1639,7 +1646,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
16391646
if (!IsUnderPostmaster)
16401647
{
16411648
puts("\nPOSTGRES backend interactive interface ");
1642-
puts("$Revision: 1.186 $ $Date: 2000/11/06 22:18:08 $\n");
1649+
puts("$Revision: 1.187 $ $Date: 2000/11/08 17:57:46 $\n");
16431650
}
16441651

16451652
/*

0 commit comments

Comments
 (0)