Re: use GUC for cmdline - Mailing list pgsql-patches

From Marko Kreen
Subject Re: use GUC for cmdline
Date
Msg-id 20010622011312.A12283@l-t.ee
Whole thread Raw
In response to Re: use GUC for cmdline  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: use GUC for cmdline  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
On Thu, Jun 21, 2001 at 06:23:03PM -0400, Tom Lane wrote:
> Marko Kreen <marko@l-t.ee> writes:
> >                  if (DebugLvl >= 1);
> > -                SetConfigOption("log_connections", tmp, ctx, true);
> > +                SetConfigOption("log_connections", tmp, PGC_POSTMASTER, true);
>
> In this particular case, there is no reason for log_connections to be
> restricted that I can see --- it's a pretty harmless switch.  I'd
> recommend downgrading its PGC restriction level to BACKEND.
>
> BTW, *please* remove the bogus ';' on the if() line.
>
> >                  if (secure)
> > -                    SetConfigOption("fsync", "false", ctx, true);
> > +                    SetConfigOption("fsync", "false", PGC_POSTMASTER, true);
>
> This seems like an appropriate fix.  I would recommend doing the same
> with all the option switch settings that are protected with "if
> (secure)".  This is not a hack: essentially it says we will treat
> options passed to the postmaster with -o as postmaster-time options.

Well?

--
marko



diff -u src/backend/tcop/postgres.c src/backend/tcop/postgres.c
--- src/backend/tcop/postgres.c
+++ src/backend/tcop/postgres.c
@@ -1110,6 +1110,7 @@
     bool        secure = true;
     int            errs = 0;
     GucContext    ctx;
+    GucContext    secure_ctx = PGC_POSTMASTER;
     char        *tmp;

     int            firstchar;
@@ -1207,8 +1208,7 @@
                 /*
                  * specify the size of buffer pool
                  */
-                if (secure)
-                    SetConfigOption("shared_buffers", optarg, ctx, true);
+                SetConfigOption("shared_buffers", optarg, secure_ctx, true);
                 break;

             case 'C':
@@ -1227,8 +1227,8 @@
             case 'd':            /* debug level */
                 tmp = "true";
                 SetConfigOption("debug_level", optarg, ctx, true);
-                if (DebugLvl >= 1);
-                SetConfigOption("log_connections", tmp, PGC_POSTMASTER, true);
+                if (DebugLvl >= 1)
+                    SetConfigOption("log_connections", tmp, ctx, true);
                 if (DebugLvl >= 2)
                     SetConfigOption("debug_print_query", tmp, ctx, true);
                 if (DebugLvl >= 3)
@@ -1260,8 +1260,7 @@
                 /*
                  * turn off fsync
                  */
-                if (secure)
-                    SetConfigOption("fsync", "false", PGC_POSTMASTER, true);
+                SetConfigOption("fsync", "false", secure_ctx, true);
                 break;

             case 'f':
@@ -1356,6 +1355,7 @@
                     DBName = strdup(optarg);
                     secure = false;        /* subsequent switches are NOT
                                          * secure */
+                    secure_ctx = ctx;
                 }
                 break;

diff -u src/backend/utils/misc/guc.c src/backend/utils/misc/guc.c
--- src/backend/utils/misc/guc.c
+++ src/backend/utils/misc/guc.c
@@ -196,7 +196,7 @@
     {"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
     {"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL},

-    {"log_connections", PGC_SIGHUP, &Log_connections, false, NULL},
+    {"log_connections", PGC_BACKEND, &Log_connections, false, NULL},
     {"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL},
     {"log_pid", PGC_SIGHUP, &Log_pid, false, NULL},


pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [ADMIN] High memory usage [PATCH]
Next
From: Tom Lane
Date:
Subject: Re: use GUC for cmdline