Skip site navigation (1) Skip section navigation (2)

Re: use GUC for cmdline

From: Marko Kreen <marko(at)l-t(dot)ee>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-21 23:13:12
Message-ID: 20010622011312.A12283@l-t.ee (view raw or flat)
Thread:
Lists: pgsql-patches
On Thu, Jun 21, 2001 at 06:23:03PM -0400, Tom Lane wrote:
> Marko Kreen <marko(at)l-t(dot)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},
 

In response to

Responses

pgsql-patches by date

Next:From: Tom LaneDate: 2001-06-21 23:50:44
Subject: Re: use GUC for cmdline
Previous:From: Marko KreenDate: 2001-06-21 22:27:50
Subject: Re: use GUC for cmdline

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group