Add '-c name=val' flag for setting run-time parameters.
authorPeter Eisentraut <peter_e@gmx.net>
Wed, 8 Nov 2000 17:57:46 +0000 (17:57 +0000)
committerPeter Eisentraut <peter_e@gmx.net>
Wed, 8 Nov 2000 17:57:46 +0000 (17:57 +0000)
doc/src/sgml/runtime.sgml
src/backend/postmaster/postmaster.c
src/backend/tcop/postgres.c

index 8fcacd7bb742875e0e5bdfa1b758967dffccce8c..1192c39fe37e00d277ec363baf1f881b14eef583 100644 (file)
@@ -411,7 +411,7 @@ syslog = 2
     A second way to set these configuration parameters is to give them
     as a command line option to the postmaster, such as
 <programlisting>
-postmaster --log-connections=yes --syslog=2
+postmaster -c log_connections=yes -c syslog=2
 </programlisting>
     which would have the same effect as the previous example.
    </para>
@@ -422,7 +422,7 @@ postmaster --log-connections=yes --syslog=2
     <envar>PGOPTIONS</envar> can be used for this purpose on the
     client side:
 <programlisting>
-env PGOPTIONS='--geqo=off' psql
+env PGOPTIONS='-geqo=off' psql
 </programlisting>
     (This works for any client application, not just
     <application>psql</application>.) Note that this won't work for
index 4c966f2631d84d14dbee184fca17796c387f0786..26f544091e0a56c7a9c9a7a91326e85e65451774 100644 (file)
@@ -372,7 +372,7 @@ PostmasterMain(int argc, char *argv[])
         * will occur.
         */
        opterr = 1;
-       while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:SsV-:?")) != EOF)
+       while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Film:MN:no:p:SsV-:?")) != EOF)
        {
                switch(opt)
                {
@@ -428,7 +428,7 @@ PostmasterMain(int argc, char *argv[])
 #ifdef HAVE_INT_OPTRESET
        optreset = 1;
 #endif
-       while ((opt = getopt(argc, argv, "A:a:B:b:D:d:Film:MN:no:p:SsV-:?")) != EOF)
+       while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Film:MN:no:p:SsV-:?")) != EOF)
        {
                switch (opt)
                {
@@ -530,13 +530,19 @@ PostmasterMain(int argc, char *argv[])
                                 */
                                SendStop = true;
                                break;
+                       case 'c':
                        case '-':
                        {
                                char *name, *value;
 
                                ParseLongOption(optarg, &name, &value);
                                if (!value)
-                                       elog(ERROR, "--%s requires argument", optarg);
+                               {
+                                       if (opt == '-')
+                                               elog(ERROR, "--%s requires argument", optarg);
+                                       else
+                                               elog(ERROR, "-c %s requires argument", optarg);
+                               }
 
                                SetConfigOption(name, value, PGC_POSTMASTER);
                                free(name);
@@ -766,6 +772,7 @@ usage(const char *progname)
        printf("  -A 1|0          enable/disable runtime assert checking\n");
 #endif
        printf("  -B <buffers>    number of shared buffers\n");
+       printf("  -c <name>=<value> set run-time parameter\n");
        printf("  -d 1-5          debugging level\n");
        printf("  -D <directory>  database directory\n");
        printf("  -F              turn fsync off\n");
@@ -775,7 +782,7 @@ usage(const char *progname)
 #endif
        printf("  -N <number>     maximum number of allowed connections (1..%d, default %d)\n",
                        MAXBACKENDS, DEF_MAXBACKENDS);
-       printf("  -o <option>     pass `option' to each backend server\n");
+       printf("  -o <option>     pass 'option' to each backend server\n");
        printf("  -p <port>       port number to listen on\n");
        printf("  -S              silent mode (dissociate from tty)\n");
 
@@ -783,7 +790,7 @@ usage(const char *progname)
        printf("  -n              don't reinitialize shared memory after abnormal exit\n");
        printf("  -s              send SIGSTOP to all backend servers if one dies\n");
 
-       printf("\nPlease read the documentation for the complete list of runtime\n"
+       printf("\nPlease read the documentation for the complete list of run-time\n"
                   "configuration settings and how to set them on the command line or in\n"
                   "the configuration file.\n\n");
 
index 14a3d2b1296ddeb567f844546d6ac5d1626d5cef..adbc3a1ce7138c23afab3c0195d1497406c348d1 100644 (file)
@@ -1010,6 +1010,7 @@ usage(char *progname)
        fprintf(stderr, "\t-A on\t\tenable/disable assert checking\n");
 #endif
        fprintf(stderr, "\t-B buffers\tset number of buffers in buffer pool\n");
+       fprintf(stderr, "\t-c name=value\tset run-time parameter\n");
        fprintf(stderr, "\t-C \t\tsuppress version info\n");
        fprintf(stderr, "\t-D dir\t\tdata directory\n");
        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
 
        optind = 1;                                     /* reset after postmaster's usage */
 
-       while ((flag = getopt(argc, argv,  "A:B:CD:d:Eef:FiLNOPo:p:S:st:v:VW:x:-:?")) != EOF)
+       while ((flag = getopt(argc, argv,  "A:B:c:CD:d:Eef:FiLNOPo:p:S:st:v:VW:x:-:?")) != EOF)
                switch (flag)
                {
                        case 'A':
@@ -1383,6 +1384,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
 #endif
                                break;
 
+                       case 'c':
                        case '-':
                        {
                                char *name, *value;
@@ -1399,7 +1401,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
                                        exit(0);
                                }
                                if (!value)
-                                       elog(ERROR, "--%s requires argument", optarg);
+                               {
+                                       if (flag == '-')
+                                               elog(ERROR, "--%s requires argument", optarg);
+                                       else
+                                               elog(ERROR, "-c %s requires argument", optarg);
+                               }
 
                                SetConfigOption(name, value, PGC_BACKEND);
                                free(name);
@@ -1639,7 +1646,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
        if (!IsUnderPostmaster)
        {
                puts("\nPOSTGRES backend interactive interface ");
-               puts("$Revision: 1.186 $ $Date: 2000/11/06 22:18:08 $\n");
+               puts("$Revision: 1.187 $ $Date: 2000/11/08 17:57:46 $\n");
        }
 
        /*