Re: use GUC for cmdline

From: Marko Kreen <marko(at)l-t(dot)ee>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-20 13:43:03
Message-ID: 20010620154300.A1381@l-t.ee
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-patches

On Tue, Jun 19, 2001 at 07:41:11PM -0400, Bruce Momjian wrote:
> > Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> > > Now that I look at it, this patch is pretty broken. For one, calling
> > > SetConfigOption("option_name", optarg, PGC_POSTMASTER, true);
> > > when the option letter doesn't take an argument is surely wrong.
> >
> > > Hint: Try 'postmaster -i'.
> >
> > Also try
> > postmaster -o -F
> > which has always worked in the past. Now it causes backends to fail
> > to start up, saying
> > FATAL 1: 'fsync' cannot be changed now
>
> OK, I have backed out the patch and attached it here. Marko, can you
> fix the problems and resubmit? Thanks.

Oh, well... Here it is.

I have not fixed the '-o -F', for which the reason is that
'fsync' var has in guc.c context of PGC_SIGHUP. Another
such variable is 'log_connections' - it has PGC_SIGHUP
and in same time is command-line settable.

How should this be fixed? Simpliest would be to change those
to PGC_BACKEND. But what exactly means PGC_SIGHUP in
ConfigureNames arrays? ATM I am confused. In set_config_option
it seems it should equal to either PGC_BACKEND or PGC_POSTMASTER
only has different error handling. But why PGC_SIGHUP in
ConfigureNames?

--
marko

Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.223
diff -u -r1.223 postmaster.c
--- src/backend/postmaster/postmaster.c 2001/06/19 23:40:10 1.223
+++ src/backend/postmaster/postmaster.c 2001/06/20 12:09:01
@@ -426,14 +426,14 @@
#ifndef USE_ASSERT_CHECKING
postmaster_error("Assert checking is not compiled in.");
#else
- assert_enabled = atoi(optarg);
+ SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, true);
#endif
break;
case 'a':
/* Can no longer set authentication method. */
break;
case 'B':
- NBuffers = atoi(optarg);
+ SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
break;
case 'b':
/* Can no longer set the backend executable file to use. */
@@ -447,23 +447,23 @@
* Turn on debugging for the postmaster and the backend
* servers descended from it.
*/
- DebugLvl = atoi(optarg);
+ SetConfigOption("debug_level", optarg, PGC_POSTMASTER, true);
break;
case 'F':
- enableFsync = false;
+ SetConfigOption("enable_fsync", "false", PGC_POSTMASTER, true);
break;
case 'h':
- VirtualHost = optarg;
+ SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, true);
break;
case 'i':
- NetServer = true;
+ SetConfigOption("tcpip_socket", "true", PGC_POSTMASTER, true);
break;
case 'k':
- UnixSocketDir = optarg;
+ SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, true);
break;
#ifdef USE_SSL
case 'l':
- EnableSSL = true;
+ SetConfigOption("ssl", "true", PGC_POSTMASTER, true);
break;
#endif
case 'm':
@@ -483,11 +483,7 @@
* The max number of backends to start. Can't set to less
* than 1 or more than compiled-in limit.
*/
- MaxBackends = atoi(optarg);
- if (MaxBackends < 1)
- MaxBackends = 1;
- if (MaxBackends > MAXBACKENDS)
- MaxBackends = MAXBACKENDS;
+ SetConfigOption("max_connections", optarg, PGC_POSTMASTER, true);
break;
case 'n':
/* Don't reinit shared mem after abnormal exit */
@@ -504,7 +500,7 @@
strcpy(original_extraoptions, optarg);
break;
case 'p':
- PostPortNumber = atoi(optarg);
+ SetConfigOption("port", optarg, PGC_POSTMASTER, true);
break;
case 'S':

@@ -514,7 +510,7 @@
* it's most badly needed on SysV-derived systems like
* SVR4 and HP-UX.
*/
- SilentMode = true;
+ SetConfigOption("silent_mode", "true", PGC_POSTMASTER, true);
break;
case 's':

Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/src/backend/tcop/postgres.c,v
retrieving revision 1.222
diff -u -r1.222 postgres.c
--- src/backend/tcop/postgres.c 2001/06/19 23:40:10 1.222
+++ src/backend/tcop/postgres.c 2001/06/20 12:08:39
@@ -1108,6 +1108,8 @@
const char *DBName = NULL;
bool secure = true;
int errs = 0;
+ GucContext ctx;
+ char *tmp;

int firstchar;
StringInfo parser_input;
@@ -1117,6 +1119,9 @@

char *potential_DataDir = NULL;

+ /* all options are allowed if not under postmaster */
+ ctx = IsUnderPostmaster ? PGC_BACKEND : PGC_POSTMASTER;
+
/*
* Catch standard options before doing much else. This even works on
* systems without getopt_long.
@@ -1188,7 +1193,7 @@
{
case 'A':
#ifdef USE_ASSERT_CHECKING
- assert_enabled = atoi(optarg);
+ SetConfigOption("debug_assertions", optarg, ctx, true);
#else
fprintf(stderr, "Assert checking is not compiled in\n");
#endif
@@ -1200,7 +1205,7 @@
* specify the size of buffer pool
*/
if (secure)
- NBuffers = atoi(optarg);
+ SetConfigOption("shared_buffers", optarg, ctx, true);
break;

case 'C':
@@ -1217,17 +1222,18 @@
break;

case 'd': /* debug level */
- DebugLvl = atoi(optarg);
+ tmp = "true";
+ SetConfigOption("debug_level", optarg, ctx, true);
if (DebugLvl >= 1);
- Log_connections = true;
+ SetConfigOption("log_connections", tmp, ctx, true);
if (DebugLvl >= 2)
- Debug_print_query = true;
+ SetConfigOption("debug_print_query", tmp, ctx, true);
if (DebugLvl >= 3)
- Debug_print_parse = true;
+ SetConfigOption("debug_print_parse", tmp, ctx, true);
if (DebugLvl >= 4)
- Debug_print_plan = true;
+ SetConfigOption("debug_print_plan", tmp, ctx, true);
if (DebugLvl >= 5)
- Debug_print_rewritten = true;
+ SetConfigOption("debug_print_rewritten", tmp, ctx, true);
break;

case 'E':
@@ -1252,7 +1258,7 @@
* turn off fsync
*/
if (secure)
- enableFsync = false;
+ SetConfigOption("fsync", "false", ctx, true);
break;

case 'f':
@@ -1260,29 +1266,32 @@
/*
* f - forbid generation of certain plans
*/
+ tmp = NULL;
switch (optarg[0])
{
case 's': /* seqscan */
- enable_seqscan = false;
+ tmp = "enable_seqscan";
break;
case 'i': /* indexscan */
- enable_indexscan = false;
+ tmp = "enable_indexscan";
break;
case 't': /* tidscan */
- enable_tidscan = false;
+ tmp = "enable_tidscan";
break;
case 'n': /* nestloop */
- enable_nestloop = false;
+ tmp = "enable_nestloop";
break;
case 'm': /* mergejoin */
- enable_mergejoin = false;
+ tmp = "enable_mergejoin";
break;
case 'h': /* hashjoin */
- enable_hashjoin = false;
+ tmp = "enable_hashjoin";
break;
default:
errs++;
}
+ if (tmp)
+ SetConfigOption(tmp, "false", ctx, true);
break;

case 'i':
@@ -1352,13 +1361,7 @@
/*
* S - amount of sort memory to use in 1k bytes
*/
- {
- int S;
-
- S = atoi(optarg);
- if (S >= 4 * BLCKSZ / 1024)
- SortMem = S;
- }
+ SetConfigOption("sort_mem", optarg, ctx, true);
break;

case 's':
@@ -1366,7 +1369,7 @@
/*
* s - report usage statistics (timings) after each query
*/
- Show_query_stats = 1;
+ SetConfigOption("show_query_stats", "true", ctx, true);
break;

case 't':
@@ -1380,23 +1383,26 @@
* caution: -s can not be used together with -t.
* ----------------
*/
+ tmp = NULL;
switch (optarg[0])
{
case 'p':
if (optarg[1] == 'a')
- Show_parser_stats = 1;
+ tmp = "show_parser_stats";
else if (optarg[1] == 'l')
- Show_planner_stats = 1;
+ tmp = "show_planner_stats";
else
errs++;
break;
case 'e':
- Show_executor_stats = 1;
+ tmp = "show_parser_stats";
break;
default:
errs++;
break;
}
+ if (tmp)
+ SetConfigOption(tmp, "true", ctx, true);
break;

case 'v':
@@ -1460,9 +1466,7 @@
elog(ERROR, "-c %s requires argument", optarg);
}

- /* all options are allowed if not under postmaster */
- SetConfigOption(name, value,
- (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
+ SetConfigOption(name, value, ctx, true);
free(name);
if (value)
free(value);
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /opt/cvs/pgsql/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.41
diff -u -r1.41 guc.c
--- src/backend/utils/misc/guc.c 2001/06/19 23:40:10 1.41
+++ src/backend/utils/misc/guc.c 2001/06/20 12:02:52
@@ -276,7 +276,7 @@
DEF_PGPORT, 1, 65535, NULL, NULL},

{"sort_mem", PGC_USERSET, &SortMem,
- 512, 1, INT_MAX, NULL, NULL},
+ 512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL},

{"debug_level", PGC_USERSET, &DebugLvl,
0, 0, 16, NULL, NULL},

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Thalis A. Kalfigopoulos 2001-06-20 15:10:21 Re: Re: [PATCHES] [PATCH] Contrib C source for casting MONEY to INT[248] and FLOAT[48]
Previous Message Jason Tishler 2001-06-20 13:39:15 Re: [PATCHES] Cygwin contrib patch