use GUC for cmdline

Lists: pgsql-patches
From: Marko Kreen <marko(at)l-t(dot)ee>
To: pgsql-patches(at)postgresql(dot)org
Subject: use GUC for cmdline
Date: 2001-06-15 16:45:27
Message-ID: 20010615184527.A5572@l-t.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Here is Tomified version of my 2 pending patches.
Dropped the set_.._real change as it is not needed.
Desc would be:

* use GUC for settings from cmdline

--
marko

Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.220
diff -u -c -r1.220 postmaster.c
*** src/backend/postmaster/postmaster.c 2001/06/14 19:59:24 1.220
--- src/backend/postmaster/postmaster.c 2001/06/15 16:22:42
***************
*** 426,439 ****
#ifndef USE_ASSERT_CHECKING
postmaster_error("Assert checking is not compiled in.");
#else
! assert_enabled = atoi(optarg);
#endif
break;
case 'a':
/* Can no longer set authentication method. */
break;
case 'B':
! NBuffers = atoi(optarg);
break;
case 'b':
/* Can no longer set the backend executable file to use. */
--- 426,439 ----
#ifndef USE_ASSERT_CHECKING
postmaster_error("Assert checking is not compiled in.");
#else
! SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, true);
#endif
break;
case 'a':
/* Can no longer set authentication method. */
break;
case 'B':
! SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
break;
case 'b':
/* Can no longer set the backend executable file to use. */
***************
*** 447,469 ****
* Turn on debugging for the postmaster and the backend
* servers descended from it.
*/
! DebugLvl = atoi(optarg);
break;
case 'F':
! enableFsync = false;
break;
case 'h':
! VirtualHost = optarg;
break;
case 'i':
! NetServer = true;
break;
case 'k':
! UnixSocketDir = optarg;
break;
#ifdef USE_SSL
case 'l':
! EnableSSL = true;
break;
#endif
case 'm':
--- 447,469 ----
* Turn on debugging for the postmaster and the backend
* servers descended from it.
*/
! SetConfigOption("debug_level", optarg, PGC_POSTMASTER, true);
break;
case 'F':
! SetConfigOption("enable_fsync", optarg, PGC_POSTMASTER, true);
break;
case 'h':
! SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, true);
break;
case 'i':
! SetConfigOption("tcpip_socket", optarg, PGC_POSTMASTER, true);
break;
case 'k':
! SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, true);
break;
#ifdef USE_SSL
case 'l':
! SetConfigOption("ssl", optarg, PGC_POSTMASTER, true);
break;
#endif
case 'm':
***************
*** 483,493 ****
* 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;
break;
case 'n':
/* Don't reinit shared mem after abnormal exit */
--- 483,489 ----
* The max number of backends to start. Can't set to less
* than 1 or more than compiled-in limit.
*/
! SetConfigOption("max_connections", optarg, PGC_POSTMASTER, true);
break;
case 'n':
/* Don't reinit shared mem after abnormal exit */
***************
*** 504,510 ****
strcpy(original_extraoptions, optarg);
break;
case 'p':
! PostPortNumber = atoi(optarg);
break;
case 'S':

--- 500,506 ----
strcpy(original_extraoptions, optarg);
break;
case 'p':
! SetConfigOption("port", optarg, PGC_POSTMASTER, true);
break;
case 'S':

***************
*** 514,520 ****
* it's most badly needed on SysV-derived systems like
* SVR4 and HP-UX.
*/
! SilentMode = true;
break;
case 's':

--- 510,516 ----
* it's most badly needed on SysV-derived systems like
* SVR4 and HP-UX.
*/
! SetConfigOption("silent_mode", optarg, PGC_POSTMASTER, true);
break;
case 's':

Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v
retrieving revision 1.220
diff -u -c -r1.220 postgres.c
*** src/backend/tcop/postgres.c 2001/06/12 22:54:06 1.220
--- src/backend/tcop/postgres.c 2001/06/15 16:22:47
***************
*** 1108,1113 ****
--- 1108,1115 ----
const char *DBName = NULL;
bool secure = true;
int errs = 0;
+ GucContext ctx;
+ char *tmp;

int firstchar;
StringInfo parser_input;
***************
*** 1117,1122 ****
--- 1119,1127 ----

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,1194 ****
{
case 'A':
#ifdef USE_ASSERT_CHECKING
! assert_enabled = atoi(optarg);
#else
fprintf(stderr, "Assert checking is not compiled in\n");
#endif
--- 1193,1199 ----
{
case 'A':
#ifdef USE_ASSERT_CHECKING
! SetConfigOption("debug_assertions", optarg, ctx, true);
#else
fprintf(stderr, "Assert checking is not compiled in\n");
#endif
***************
*** 1200,1206 ****
* specify the size of buffer pool
*/
if (secure)
! NBuffers = atoi(optarg);
break;

case 'C':
--- 1205,1211 ----
* specify the size of buffer pool
*/
if (secure)
! SetConfigOption("shared_buffers", optarg, ctx, true);
break;

case 'C':
***************
*** 1217,1233 ****
break;

case 'd': /* debug level */
! DebugLvl = atoi(optarg);
if (DebugLvl >= 1);
! Log_connections = true;
if (DebugLvl >= 2)
! Debug_print_query = true;
if (DebugLvl >= 3)
! Debug_print_parse = true;
if (DebugLvl >= 4)
! Debug_print_plan = true;
if (DebugLvl >= 5)
! Debug_print_rewritten = true;
break;

case 'E':
--- 1222,1239 ----
break;

case 'd': /* debug level */
! tmp = "true";
! SetConfigOption("debug_level", optarg, ctx, true);
if (DebugLvl >= 1);
! SetConfigOption("log_connections", tmp, ctx, true);
if (DebugLvl >= 2)
! SetConfigOption("debug_print_query", tmp, ctx, true);
if (DebugLvl >= 3)
! SetConfigOption("debug_print_parse", tmp, ctx, true);
if (DebugLvl >= 4)
! SetConfigOption("debug_print_plan", tmp, ctx, true);
if (DebugLvl >= 5)
! SetConfigOption("debug_print_rewritten", tmp, ctx, true);
break;

case 'E':
***************
*** 1252,1258 ****
* turn off fsync
*/
if (secure)
! enableFsync = false;
break;

case 'f':
--- 1258,1264 ----
* turn off fsync
*/
if (secure)
! SetConfigOption("fsync", "true", ctx, true);
break;

case 'f':
***************
*** 1260,1288 ****
/*
* f - forbid generation of certain plans
*/
switch (optarg[0])
{
case 's': /* seqscan */
! enable_seqscan = false;
break;
case 'i': /* indexscan */
! enable_indexscan = false;
break;
case 't': /* tidscan */
! enable_tidscan = false;
break;
case 'n': /* nestloop */
! enable_nestloop = false;
break;
case 'm': /* mergejoin */
! enable_mergejoin = false;
break;
case 'h': /* hashjoin */
! enable_hashjoin = false;
break;
default:
errs++;
}
break;

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

case 'i':
***************
*** 1352,1364 ****
/*
* S - amount of sort memory to use in 1k bytes
*/
! {
! int S;
!
! S = atoi(optarg);
! if (S >= 4 * BLCKSZ / 1024)
! SortMem = S;
! }
break;

case 's':
--- 1361,1367 ----
/*
* S - amount of sort memory to use in 1k bytes
*/
! SetConfigOption("sort_mem", optarg, ctx, true);
break;

case 's':
***************
*** 1366,1372 ****
/*
* s - report usage statistics (timings) after each query
*/
! Show_query_stats = 1;
break;

case 't':
--- 1369,1375 ----
/*
* s - report usage statistics (timings) after each query
*/
! SetConfigOption("show_query_stats", optarg, ctx, true);
break;

case 't':
***************
*** 1380,1402 ****
* caution: -s can not be used together with -t.
* ----------------
*/
switch (optarg[0])
{
case 'p':
if (optarg[1] == 'a')
! Show_parser_stats = 1;
else if (optarg[1] == 'l')
! Show_planner_stats = 1;
else
errs++;
break;
case 'e':
! Show_executor_stats = 1;
break;
default:
errs++;
break;
}
break;

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

case 'v':
***************
*** 1460,1468 ****
elog(ERROR, "-c %s requires argument", optarg);
}

! /* all options are allowed if not under postmaster */
! SetConfigOption(name, value,
! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
free(name);
if (value)
free(value);
--- 1466,1472 ----
elog(ERROR, "-c %s requires argument", optarg);
}

! SetConfigOption(name, value, ctx, true);
free(name);
if (value)
free(value);
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.38
diff -u -c -r1.38 guc.c
*** src/backend/utils/misc/guc.c 2001/06/12 22:54:06 1.38
--- src/backend/utils/misc/guc.c 2001/06/15 16:22:49
***************
*** 270,276 ****
DEF_PGPORT, 1, 65535, NULL, NULL},

{"sort_mem", PGC_USERSET, &SortMem,
! 512, 1, INT_MAX, NULL, NULL},

{"debug_level", PGC_USERSET, &DebugLvl,
0, 0, 16, NULL, NULL},
--- 270,276 ----
DEF_PGPORT, 1, 65535, NULL, NULL},

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

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


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-18 17:16:24
Message-ID: 200106181716.f5IHGOT10416@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


This is a new version of the "reset all update" patch?

> Here is Tomified version of my 2 pending patches.
> Dropped the set_.._real change as it is not needed.
> Desc would be:
>
> * use GUC for settings from cmdline
>
> --
> marko
>
>
> Index: src/backend/postmaster/postmaster.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
> retrieving revision 1.220
> diff -u -c -r1.220 postmaster.c
> *** src/backend/postmaster/postmaster.c 2001/06/14 19:59:24 1.220
> --- src/backend/postmaster/postmaster.c 2001/06/15 16:22:42
> ***************
> *** 426,439 ****
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! assert_enabled = atoi(optarg);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! NBuffers = atoi(optarg);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> --- 426,439 ----
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, true);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> ***************
> *** 447,469 ****
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! DebugLvl = atoi(optarg);
> break;
> case 'F':
> ! enableFsync = false;
> break;
> case 'h':
> ! VirtualHost = optarg;
> break;
> case 'i':
> ! NetServer = true;
> break;
> case 'k':
> ! UnixSocketDir = optarg;
> break;
> #ifdef USE_SSL
> case 'l':
> ! EnableSSL = true;
> break;
> #endif
> case 'm':
> --- 447,469 ----
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! SetConfigOption("debug_level", optarg, PGC_POSTMASTER, true);
> break;
> case 'F':
> ! SetConfigOption("enable_fsync", optarg, PGC_POSTMASTER, true);
> break;
> case 'h':
> ! SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, true);
> break;
> case 'i':
> ! SetConfigOption("tcpip_socket", optarg, PGC_POSTMASTER, true);
> break;
> case 'k':
> ! SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, true);
> break;
> #ifdef USE_SSL
> case 'l':
> ! SetConfigOption("ssl", optarg, PGC_POSTMASTER, true);
> break;
> #endif
> case 'm':
> ***************
> *** 483,493 ****
> * 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;
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> --- 483,489 ----
> * The max number of backends to start. Can't set to less
> * than 1 or more than compiled-in limit.
> */
> ! SetConfigOption("max_connections", optarg, PGC_POSTMASTER, true);
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> ***************
> *** 504,510 ****
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! PostPortNumber = atoi(optarg);
> break;
> case 'S':
>
> --- 500,506 ----
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! SetConfigOption("port", optarg, PGC_POSTMASTER, true);
> break;
> case 'S':
>
> ***************
> *** 514,520 ****
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SilentMode = true;
> break;
> case 's':
>
> --- 510,516 ----
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SetConfigOption("silent_mode", optarg, PGC_POSTMASTER, true);
> break;
> case 's':
>
> Index: src/backend/tcop/postgres.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v
> retrieving revision 1.220
> diff -u -c -r1.220 postgres.c
> *** src/backend/tcop/postgres.c 2001/06/12 22:54:06 1.220
> --- src/backend/tcop/postgres.c 2001/06/15 16:22:47
> ***************
> *** 1108,1113 ****
> --- 1108,1115 ----
> const char *DBName = NULL;
> bool secure = true;
> int errs = 0;
> + GucContext ctx;
> + char *tmp;
>
> int firstchar;
> StringInfo parser_input;
> ***************
> *** 1117,1122 ****
> --- 1119,1127 ----
>
> 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,1194 ****
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! assert_enabled = atoi(optarg);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> --- 1193,1199 ----
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! SetConfigOption("debug_assertions", optarg, ctx, true);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> ***************
> *** 1200,1206 ****
> * specify the size of buffer pool
> */
> if (secure)
> ! NBuffers = atoi(optarg);
> break;
>
> case 'C':
> --- 1205,1211 ----
> * specify the size of buffer pool
> */
> if (secure)
> ! SetConfigOption("shared_buffers", optarg, ctx, true);
> break;
>
> case 'C':
> ***************
> *** 1217,1233 ****
> break;
>
> case 'd': /* debug level */
> ! DebugLvl = atoi(optarg);
> if (DebugLvl >= 1);
> ! Log_connections = true;
> if (DebugLvl >= 2)
> ! Debug_print_query = true;
> if (DebugLvl >= 3)
> ! Debug_print_parse = true;
> if (DebugLvl >= 4)
> ! Debug_print_plan = true;
> if (DebugLvl >= 5)
> ! Debug_print_rewritten = true;
> break;
>
> case 'E':
> --- 1222,1239 ----
> break;
>
> case 'd': /* debug level */
> ! tmp = "true";
> ! SetConfigOption("debug_level", optarg, ctx, true);
> if (DebugLvl >= 1);
> ! SetConfigOption("log_connections", tmp, ctx, true);
> if (DebugLvl >= 2)
> ! SetConfigOption("debug_print_query", tmp, ctx, true);
> if (DebugLvl >= 3)
> ! SetConfigOption("debug_print_parse", tmp, ctx, true);
> if (DebugLvl >= 4)
> ! SetConfigOption("debug_print_plan", tmp, ctx, true);
> if (DebugLvl >= 5)
> ! SetConfigOption("debug_print_rewritten", tmp, ctx, true);
> break;
>
> case 'E':
> ***************
> *** 1252,1258 ****
> * turn off fsync
> */
> if (secure)
> ! enableFsync = false;
> break;
>
> case 'f':
> --- 1258,1264 ----
> * turn off fsync
> */
> if (secure)
> ! SetConfigOption("fsync", "true", ctx, true);
> break;
>
> case 'f':
> ***************
> *** 1260,1288 ****
> /*
> * f - forbid generation of certain plans
> */
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! enable_seqscan = false;
> break;
> case 'i': /* indexscan */
> ! enable_indexscan = false;
> break;
> case 't': /* tidscan */
> ! enable_tidscan = false;
> break;
> case 'n': /* nestloop */
> ! enable_nestloop = false;
> break;
> case 'm': /* mergejoin */
> ! enable_mergejoin = false;
> break;
> case 'h': /* hashjoin */
> ! enable_hashjoin = false;
> break;
> default:
> errs++;
> }
> break;
>
> case 'i':
> --- 1266,1297 ----
> /*
> * f - forbid generation of certain plans
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! tmp = "enable_seqscan";
> break;
> case 'i': /* indexscan */
> ! tmp = "enable_indexscan";
> break;
> case 't': /* tidscan */
> ! tmp = "enable_tidscan";
> break;
> case 'n': /* nestloop */
> ! tmp = "enable_nestloop";
> break;
> case 'm': /* mergejoin */
> ! tmp = "enable_mergejoin";
> break;
> case 'h': /* hashjoin */
> ! tmp = "enable_hashjoin";
> break;
> default:
> errs++;
> }
> + if (tmp)
> + SetConfigOption(tmp, "false", ctx, true);
> break;
>
> case 'i':
> ***************
> *** 1352,1364 ****
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! {
> ! int S;
> !
> ! S = atoi(optarg);
> ! if (S >= 4 * BLCKSZ / 1024)
> ! SortMem = S;
> ! }
> break;
>
> case 's':
> --- 1361,1367 ----
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! SetConfigOption("sort_mem", optarg, ctx, true);
> break;
>
> case 's':
> ***************
> *** 1366,1372 ****
> /*
> * s - report usage statistics (timings) after each query
> */
> ! Show_query_stats = 1;
> break;
>
> case 't':
> --- 1369,1375 ----
> /*
> * s - report usage statistics (timings) after each query
> */
> ! SetConfigOption("show_query_stats", optarg, ctx, true);
> break;
>
> case 't':
> ***************
> *** 1380,1402 ****
> * caution: -s can not be used together with -t.
> * ----------------
> */
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! Show_parser_stats = 1;
> else if (optarg[1] == 'l')
> ! Show_planner_stats = 1;
> else
> errs++;
> break;
> case 'e':
> ! Show_executor_stats = 1;
> break;
> default:
> errs++;
> break;
> }
> break;
>
> case 'v':
> --- 1383,1408 ----
> * caution: -s can not be used together with -t.
> * ----------------
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! tmp = "show_parser_stats";
> else if (optarg[1] == 'l')
> ! tmp = "show_planner_stats";
> else
> errs++;
> break;
> case 'e':
> ! tmp = "show_parser_stats";
> break;
> default:
> errs++;
> break;
> }
> + if (tmp)
> + SetConfigOption(tmp, "true", ctx, true);
> break;
>
> case 'v':
> ***************
> *** 1460,1468 ****
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! /* all options are allowed if not under postmaster */
> ! SetConfigOption(name, value,
> ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
> free(name);
> if (value)
> free(value);
> --- 1466,1472 ----
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! SetConfigOption(name, value, ctx, true);
> free(name);
> if (value)
> free(value);
> Index: src/backend/utils/misc/guc.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
> retrieving revision 1.38
> diff -u -c -r1.38 guc.c
> *** src/backend/utils/misc/guc.c 2001/06/12 22:54:06 1.38
> --- src/backend/utils/misc/guc.c 2001/06/15 16:22:49
> ***************
> *** 270,276 ****
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 1, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
> --- 270,276 ----
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-18 17:22:06
Message-ID: 200106181722.f5IHM7C11029@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

>
> Here is Tomified version of my 2 pending patches.
> Dropped the set_.._real change as it is not needed.
> Desc would be:
>
> * use GUC for settings from cmdline
>
> --
> marko
>
>
> Index: src/backend/postmaster/postmaster.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
> retrieving revision 1.220
> diff -u -c -r1.220 postmaster.c
> *** src/backend/postmaster/postmaster.c 2001/06/14 19:59:24 1.220
> --- src/backend/postmaster/postmaster.c 2001/06/15 16:22:42
> ***************
> *** 426,439 ****
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! assert_enabled = atoi(optarg);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! NBuffers = atoi(optarg);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> --- 426,439 ----
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, true);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> ***************
> *** 447,469 ****
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! DebugLvl = atoi(optarg);
> break;
> case 'F':
> ! enableFsync = false;
> break;
> case 'h':
> ! VirtualHost = optarg;
> break;
> case 'i':
> ! NetServer = true;
> break;
> case 'k':
> ! UnixSocketDir = optarg;
> break;
> #ifdef USE_SSL
> case 'l':
> ! EnableSSL = true;
> break;
> #endif
> case 'm':
> --- 447,469 ----
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! SetConfigOption("debug_level", optarg, PGC_POSTMASTER, true);
> break;
> case 'F':
> ! SetConfigOption("enable_fsync", optarg, PGC_POSTMASTER, true);
> break;
> case 'h':
> ! SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, true);
> break;
> case 'i':
> ! SetConfigOption("tcpip_socket", optarg, PGC_POSTMASTER, true);
> break;
> case 'k':
> ! SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, true);
> break;
> #ifdef USE_SSL
> case 'l':
> ! SetConfigOption("ssl", optarg, PGC_POSTMASTER, true);
> break;
> #endif
> case 'm':
> ***************
> *** 483,493 ****
> * 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;
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> --- 483,489 ----
> * The max number of backends to start. Can't set to less
> * than 1 or more than compiled-in limit.
> */
> ! SetConfigOption("max_connections", optarg, PGC_POSTMASTER, true);
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> ***************
> *** 504,510 ****
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! PostPortNumber = atoi(optarg);
> break;
> case 'S':
>
> --- 500,506 ----
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! SetConfigOption("port", optarg, PGC_POSTMASTER, true);
> break;
> case 'S':
>
> ***************
> *** 514,520 ****
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SilentMode = true;
> break;
> case 's':
>
> --- 510,516 ----
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SetConfigOption("silent_mode", optarg, PGC_POSTMASTER, true);
> break;
> case 's':
>
> Index: src/backend/tcop/postgres.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v
> retrieving revision 1.220
> diff -u -c -r1.220 postgres.c
> *** src/backend/tcop/postgres.c 2001/06/12 22:54:06 1.220
> --- src/backend/tcop/postgres.c 2001/06/15 16:22:47
> ***************
> *** 1108,1113 ****
> --- 1108,1115 ----
> const char *DBName = NULL;
> bool secure = true;
> int errs = 0;
> + GucContext ctx;
> + char *tmp;
>
> int firstchar;
> StringInfo parser_input;
> ***************
> *** 1117,1122 ****
> --- 1119,1127 ----
>
> 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,1194 ****
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! assert_enabled = atoi(optarg);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> --- 1193,1199 ----
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! SetConfigOption("debug_assertions", optarg, ctx, true);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> ***************
> *** 1200,1206 ****
> * specify the size of buffer pool
> */
> if (secure)
> ! NBuffers = atoi(optarg);
> break;
>
> case 'C':
> --- 1205,1211 ----
> * specify the size of buffer pool
> */
> if (secure)
> ! SetConfigOption("shared_buffers", optarg, ctx, true);
> break;
>
> case 'C':
> ***************
> *** 1217,1233 ****
> break;
>
> case 'd': /* debug level */
> ! DebugLvl = atoi(optarg);
> if (DebugLvl >= 1);
> ! Log_connections = true;
> if (DebugLvl >= 2)
> ! Debug_print_query = true;
> if (DebugLvl >= 3)
> ! Debug_print_parse = true;
> if (DebugLvl >= 4)
> ! Debug_print_plan = true;
> if (DebugLvl >= 5)
> ! Debug_print_rewritten = true;
> break;
>
> case 'E':
> --- 1222,1239 ----
> break;
>
> case 'd': /* debug level */
> ! tmp = "true";
> ! SetConfigOption("debug_level", optarg, ctx, true);
> if (DebugLvl >= 1);
> ! SetConfigOption("log_connections", tmp, ctx, true);
> if (DebugLvl >= 2)
> ! SetConfigOption("debug_print_query", tmp, ctx, true);
> if (DebugLvl >= 3)
> ! SetConfigOption("debug_print_parse", tmp, ctx, true);
> if (DebugLvl >= 4)
> ! SetConfigOption("debug_print_plan", tmp, ctx, true);
> if (DebugLvl >= 5)
> ! SetConfigOption("debug_print_rewritten", tmp, ctx, true);
> break;
>
> case 'E':
> ***************
> *** 1252,1258 ****
> * turn off fsync
> */
> if (secure)
> ! enableFsync = false;
> break;
>
> case 'f':
> --- 1258,1264 ----
> * turn off fsync
> */
> if (secure)
> ! SetConfigOption("fsync", "true", ctx, true);
> break;
>
> case 'f':
> ***************
> *** 1260,1288 ****
> /*
> * f - forbid generation of certain plans
> */
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! enable_seqscan = false;
> break;
> case 'i': /* indexscan */
> ! enable_indexscan = false;
> break;
> case 't': /* tidscan */
> ! enable_tidscan = false;
> break;
> case 'n': /* nestloop */
> ! enable_nestloop = false;
> break;
> case 'm': /* mergejoin */
> ! enable_mergejoin = false;
> break;
> case 'h': /* hashjoin */
> ! enable_hashjoin = false;
> break;
> default:
> errs++;
> }
> break;
>
> case 'i':
> --- 1266,1297 ----
> /*
> * f - forbid generation of certain plans
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! tmp = "enable_seqscan";
> break;
> case 'i': /* indexscan */
> ! tmp = "enable_indexscan";
> break;
> case 't': /* tidscan */
> ! tmp = "enable_tidscan";
> break;
> case 'n': /* nestloop */
> ! tmp = "enable_nestloop";
> break;
> case 'm': /* mergejoin */
> ! tmp = "enable_mergejoin";
> break;
> case 'h': /* hashjoin */
> ! tmp = "enable_hashjoin";
> break;
> default:
> errs++;
> }
> + if (tmp)
> + SetConfigOption(tmp, "false", ctx, true);
> break;
>
> case 'i':
> ***************
> *** 1352,1364 ****
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! {
> ! int S;
> !
> ! S = atoi(optarg);
> ! if (S >= 4 * BLCKSZ / 1024)
> ! SortMem = S;
> ! }
> break;
>
> case 's':
> --- 1361,1367 ----
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! SetConfigOption("sort_mem", optarg, ctx, true);
> break;
>
> case 's':
> ***************
> *** 1366,1372 ****
> /*
> * s - report usage statistics (timings) after each query
> */
> ! Show_query_stats = 1;
> break;
>
> case 't':
> --- 1369,1375 ----
> /*
> * s - report usage statistics (timings) after each query
> */
> ! SetConfigOption("show_query_stats", optarg, ctx, true);
> break;
>
> case 't':
> ***************
> *** 1380,1402 ****
> * caution: -s can not be used together with -t.
> * ----------------
> */
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! Show_parser_stats = 1;
> else if (optarg[1] == 'l')
> ! Show_planner_stats = 1;
> else
> errs++;
> break;
> case 'e':
> ! Show_executor_stats = 1;
> break;
> default:
> errs++;
> break;
> }
> break;
>
> case 'v':
> --- 1383,1408 ----
> * caution: -s can not be used together with -t.
> * ----------------
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! tmp = "show_parser_stats";
> else if (optarg[1] == 'l')
> ! tmp = "show_planner_stats";
> else
> errs++;
> break;
> case 'e':
> ! tmp = "show_parser_stats";
> break;
> default:
> errs++;
> break;
> }
> + if (tmp)
> + SetConfigOption(tmp, "true", ctx, true);
> break;
>
> case 'v':
> ***************
> *** 1460,1468 ****
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! /* all options are allowed if not under postmaster */
> ! SetConfigOption(name, value,
> ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
> free(name);
> if (value)
> free(value);
> --- 1466,1472 ----
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! SetConfigOption(name, value, ctx, true);
> free(name);
> if (value)
> free(value);
> Index: src/backend/utils/misc/guc.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
> retrieving revision 1.38
> diff -u -c -r1.38 guc.c
> *** src/backend/utils/misc/guc.c 2001/06/12 22:54:06 1.38
> --- src/backend/utils/misc/guc.c 2001/06/15 16:22:49
> ***************
> *** 270,276 ****
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 1, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
> --- 270,276 ----
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Marko Kreen <marko(at)l-t(dot)ee>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-18 17:37:27
Message-ID: 20010618193727.A15446@l-t.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Mon, Jun 18, 2001 at 01:16:24PM -0400, Bruce Momjian wrote:
>
> This is a new version of the "reset all update" patch?

Yes.

> > Here is Tomified version of my 2 pending patches.
> > Dropped the set_.._real change as it is not needed.
> > Desc would be:
> >
> > * use GUC for settings from cmdline

--
marko


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Marko Kreen <marko(at)l-t(dot)ee>, pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-18 18:10:59
Message-ID: 7483.992887859@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> This is a new version of the "reset all update" patch?

No, this goes on top of that.

Since Peter says he's in the midst of restructuring the postmaster, it'd
probably be best to wait till he's done before committing these changes.
(It being mainly a GUC thing, he might want to review/apply the patch
himself anyway.)

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Marko Kreen <marko(at)l-t(dot)ee>, pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-18 18:13:05
Message-ID: 200106181813.f5IID5r14492@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > This is a new version of the "reset all update" patch?
>
> No, this goes on top of that.
>
> Since Peter says he's in the midst of restructuring the postmaster, it'd
> probably be best to wait till he's done before committing these changes.
> (It being mainly a GUC thing, he might want to review/apply the patch
> himself anyway.)
>

Marko says it is a new version of the "reset all update" patch, or at
least a new version of the stuff we haven't applied yet.

I can hold until Peter is done and merge as needed.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Marko Kreen <marko(at)l-t(dot)ee>, pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-18 18:35:36
Message-ID: 7597.992889336@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>> No, this goes on top of that.

> Marko says it is a new version of the "reset all update" patch, or at
> least a new version of the stuff we haven't applied yet.

You're right, I was confused about what we'd applied or not applied yet.
My mistake.

> I can hold until Peter is done and merge as needed.

I'd still recommend that, unless Peter isn't as close to committing
fork-before-authenticate as I think he is...

regards, tom lane


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Marko Kreen <marko(at)l-t(dot)ee>, pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-18 18:40:19
Message-ID: 200106181840.f5IIeJE16392@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> >> No, this goes on top of that.
>
> > Marko says it is a new version of the "reset all update" patch, or at
> > least a new version of the stuff we haven't applied yet.
>
> You're right, I was confused about what we'd applied or not applied yet.
> My mistake.
>
> > I can hold until Peter is done and merge as needed.
>
> I'd still recommend that, unless Peter isn't as close to committing
> fork-before-authenticate as I think he is...

I can wait. There is no huge rush for the patch unless we are releasing
7.2 soon. :-)

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Marko Kreen <marko(at)l-t(dot)ee>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: use GUC for cmdline
Date: 2001-06-18 23:23:14
Message-ID: Pine.LNX.4.30.0106190122360.898-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Tom Lane writes:

> > I can hold until Peter is done and merge as needed.
>
> I'd still recommend that, unless Peter isn't as close to committing
> fork-before-authenticate as I think he is...

You'll be the judge of that. ;-) But I don't see this code interfering.

--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter


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

> Tom Lane writes:
>
> > > I can hold until Peter is done and merge as needed.
> >
> > I'd still recommend that, unless Peter isn't as close to committing
> > fork-before-authenticate as I think he is...
>
> You'll be the judge of that. ;-) But I don't see this code interfering.

I didn't think it would interfere either. Let me apply it and Peter let
me know if you get a CVS collision and I can back it out.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: use GUC for cmdline
Date: 2001-06-18 23:41:10
Message-ID: 200106182341.f5INfBx05080@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Peter thinks no collision. Patch applied. Thanks.

>
> Here is Tomified version of my 2 pending patches.
> Dropped the set_.._real change as it is not needed.
> Desc would be:
>
> * use GUC for settings from cmdline
>
> --
> marko
>
>
> Index: src/backend/postmaster/postmaster.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
> retrieving revision 1.220
> diff -u -c -r1.220 postmaster.c
> *** src/backend/postmaster/postmaster.c 2001/06/14 19:59:24 1.220
> --- src/backend/postmaster/postmaster.c 2001/06/15 16:22:42
> ***************
> *** 426,439 ****
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! assert_enabled = atoi(optarg);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! NBuffers = atoi(optarg);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> --- 426,439 ----
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, true);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> ***************
> *** 447,469 ****
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! DebugLvl = atoi(optarg);
> break;
> case 'F':
> ! enableFsync = false;
> break;
> case 'h':
> ! VirtualHost = optarg;
> break;
> case 'i':
> ! NetServer = true;
> break;
> case 'k':
> ! UnixSocketDir = optarg;
> break;
> #ifdef USE_SSL
> case 'l':
> ! EnableSSL = true;
> break;
> #endif
> case 'm':
> --- 447,469 ----
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! SetConfigOption("debug_level", optarg, PGC_POSTMASTER, true);
> break;
> case 'F':
> ! SetConfigOption("enable_fsync", optarg, PGC_POSTMASTER, true);
> break;
> case 'h':
> ! SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, true);
> break;
> case 'i':
> ! SetConfigOption("tcpip_socket", optarg, PGC_POSTMASTER, true);
> break;
> case 'k':
> ! SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, true);
> break;
> #ifdef USE_SSL
> case 'l':
> ! SetConfigOption("ssl", optarg, PGC_POSTMASTER, true);
> break;
> #endif
> case 'm':
> ***************
> *** 483,493 ****
> * 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;
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> --- 483,489 ----
> * The max number of backends to start. Can't set to less
> * than 1 or more than compiled-in limit.
> */
> ! SetConfigOption("max_connections", optarg, PGC_POSTMASTER, true);
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> ***************
> *** 504,510 ****
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! PostPortNumber = atoi(optarg);
> break;
> case 'S':
>
> --- 500,506 ----
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! SetConfigOption("port", optarg, PGC_POSTMASTER, true);
> break;
> case 'S':
>
> ***************
> *** 514,520 ****
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SilentMode = true;
> break;
> case 's':
>
> --- 510,516 ----
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SetConfigOption("silent_mode", optarg, PGC_POSTMASTER, true);
> break;
> case 's':
>
> Index: src/backend/tcop/postgres.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v
> retrieving revision 1.220
> diff -u -c -r1.220 postgres.c
> *** src/backend/tcop/postgres.c 2001/06/12 22:54:06 1.220
> --- src/backend/tcop/postgres.c 2001/06/15 16:22:47
> ***************
> *** 1108,1113 ****
> --- 1108,1115 ----
> const char *DBName = NULL;
> bool secure = true;
> int errs = 0;
> + GucContext ctx;
> + char *tmp;
>
> int firstchar;
> StringInfo parser_input;
> ***************
> *** 1117,1122 ****
> --- 1119,1127 ----
>
> 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,1194 ****
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! assert_enabled = atoi(optarg);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> --- 1193,1199 ----
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! SetConfigOption("debug_assertions", optarg, ctx, true);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> ***************
> *** 1200,1206 ****
> * specify the size of buffer pool
> */
> if (secure)
> ! NBuffers = atoi(optarg);
> break;
>
> case 'C':
> --- 1205,1211 ----
> * specify the size of buffer pool
> */
> if (secure)
> ! SetConfigOption("shared_buffers", optarg, ctx, true);
> break;
>
> case 'C':
> ***************
> *** 1217,1233 ****
> break;
>
> case 'd': /* debug level */
> ! DebugLvl = atoi(optarg);
> if (DebugLvl >= 1);
> ! Log_connections = true;
> if (DebugLvl >= 2)
> ! Debug_print_query = true;
> if (DebugLvl >= 3)
> ! Debug_print_parse = true;
> if (DebugLvl >= 4)
> ! Debug_print_plan = true;
> if (DebugLvl >= 5)
> ! Debug_print_rewritten = true;
> break;
>
> case 'E':
> --- 1222,1239 ----
> break;
>
> case 'd': /* debug level */
> ! tmp = "true";
> ! SetConfigOption("debug_level", optarg, ctx, true);
> if (DebugLvl >= 1);
> ! SetConfigOption("log_connections", tmp, ctx, true);
> if (DebugLvl >= 2)
> ! SetConfigOption("debug_print_query", tmp, ctx, true);
> if (DebugLvl >= 3)
> ! SetConfigOption("debug_print_parse", tmp, ctx, true);
> if (DebugLvl >= 4)
> ! SetConfigOption("debug_print_plan", tmp, ctx, true);
> if (DebugLvl >= 5)
> ! SetConfigOption("debug_print_rewritten", tmp, ctx, true);
> break;
>
> case 'E':
> ***************
> *** 1252,1258 ****
> * turn off fsync
> */
> if (secure)
> ! enableFsync = false;
> break;
>
> case 'f':
> --- 1258,1264 ----
> * turn off fsync
> */
> if (secure)
> ! SetConfigOption("fsync", "true", ctx, true);
> break;
>
> case 'f':
> ***************
> *** 1260,1288 ****
> /*
> * f - forbid generation of certain plans
> */
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! enable_seqscan = false;
> break;
> case 'i': /* indexscan */
> ! enable_indexscan = false;
> break;
> case 't': /* tidscan */
> ! enable_tidscan = false;
> break;
> case 'n': /* nestloop */
> ! enable_nestloop = false;
> break;
> case 'm': /* mergejoin */
> ! enable_mergejoin = false;
> break;
> case 'h': /* hashjoin */
> ! enable_hashjoin = false;
> break;
> default:
> errs++;
> }
> break;
>
> case 'i':
> --- 1266,1297 ----
> /*
> * f - forbid generation of certain plans
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! tmp = "enable_seqscan";
> break;
> case 'i': /* indexscan */
> ! tmp = "enable_indexscan";
> break;
> case 't': /* tidscan */
> ! tmp = "enable_tidscan";
> break;
> case 'n': /* nestloop */
> ! tmp = "enable_nestloop";
> break;
> case 'm': /* mergejoin */
> ! tmp = "enable_mergejoin";
> break;
> case 'h': /* hashjoin */
> ! tmp = "enable_hashjoin";
> break;
> default:
> errs++;
> }
> + if (tmp)
> + SetConfigOption(tmp, "false", ctx, true);
> break;
>
> case 'i':
> ***************
> *** 1352,1364 ****
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! {
> ! int S;
> !
> ! S = atoi(optarg);
> ! if (S >= 4 * BLCKSZ / 1024)
> ! SortMem = S;
> ! }
> break;
>
> case 's':
> --- 1361,1367 ----
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! SetConfigOption("sort_mem", optarg, ctx, true);
> break;
>
> case 's':
> ***************
> *** 1366,1372 ****
> /*
> * s - report usage statistics (timings) after each query
> */
> ! Show_query_stats = 1;
> break;
>
> case 't':
> --- 1369,1375 ----
> /*
> * s - report usage statistics (timings) after each query
> */
> ! SetConfigOption("show_query_stats", optarg, ctx, true);
> break;
>
> case 't':
> ***************
> *** 1380,1402 ****
> * caution: -s can not be used together with -t.
> * ----------------
> */
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! Show_parser_stats = 1;
> else if (optarg[1] == 'l')
> ! Show_planner_stats = 1;
> else
> errs++;
> break;
> case 'e':
> ! Show_executor_stats = 1;
> break;
> default:
> errs++;
> break;
> }
> break;
>
> case 'v':
> --- 1383,1408 ----
> * caution: -s can not be used together with -t.
> * ----------------
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! tmp = "show_parser_stats";
> else if (optarg[1] == 'l')
> ! tmp = "show_planner_stats";
> else
> errs++;
> break;
> case 'e':
> ! tmp = "show_parser_stats";
> break;
> default:
> errs++;
> break;
> }
> + if (tmp)
> + SetConfigOption(tmp, "true", ctx, true);
> break;
>
> case 'v':
> ***************
> *** 1460,1468 ****
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! /* all options are allowed if not under postmaster */
> ! SetConfigOption(name, value,
> ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
> free(name);
> if (value)
> free(value);
> --- 1466,1472 ----
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! SetConfigOption(name, value, ctx, true);
> free(name);
> if (value)
> free(value);
> Index: src/backend/utils/misc/guc.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
> retrieving revision 1.38
> diff -u -c -r1.38 guc.c
> *** src/backend/utils/misc/guc.c 2001/06/12 22:54:06 1.38
> --- src/backend/utils/misc/guc.c 2001/06/15 16:22:49
> ***************
> *** 270,276 ****
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 1, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
> --- 270,276 ----
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://www.postgresql.org/search.mpl
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Marko Kreen <marko(at)l-t(dot)ee>, <pgsql-patches(at)postgresql(dot)org>
Subject: Re: use GUC for cmdline
Date: 2001-06-19 20:43:36
Message-ID: Pine.LNX.4.30.0106192240570.724-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Bruce Momjian writes:

> Peter thinks no collision. Patch applied. Thanks.

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'.

>
>
> >
> > Here is Tomified version of my 2 pending patches.
> > Dropped the set_.._real change as it is not needed.
> > Desc would be:
> >
> > * use GUC for settings from cmdline
> >
> > --
> > marko
> >
> >
> > Index: src/backend/postmaster/postmaster.c
> > ===================================================================
> > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
> > retrieving revision 1.220
> > diff -u -c -r1.220 postmaster.c
> > *** src/backend/postmaster/postmaster.c 2001/06/14 19:59:24 1.220
> > --- src/backend/postmaster/postmaster.c 2001/06/15 16:22:42
> > ***************
> > *** 426,439 ****
> > #ifndef USE_ASSERT_CHECKING
> > postmaster_error("Assert checking is not compiled in.");
> > #else
> > ! assert_enabled = atoi(optarg);
> > #endif
> > break;
> > case 'a':
> > /* Can no longer set authentication method. */
> > break;
> > case 'B':
> > ! NBuffers = atoi(optarg);
> > break;
> > case 'b':
> > /* Can no longer set the backend executable file to use. */
> > --- 426,439 ----
> > #ifndef USE_ASSERT_CHECKING
> > postmaster_error("Assert checking is not compiled in.");
> > #else
> > ! SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, true);
> > #endif
> > break;
> > case 'a':
> > /* Can no longer set authentication method. */
> > break;
> > case 'B':
> > ! SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
> > break;
> > case 'b':
> > /* Can no longer set the backend executable file to use. */
> > ***************
> > *** 447,469 ****
> > * Turn on debugging for the postmaster and the backend
> > * servers descended from it.
> > */
> > ! DebugLvl = atoi(optarg);
> > break;
> > case 'F':
> > ! enableFsync = false;
> > break;
> > case 'h':
> > ! VirtualHost = optarg;
> > break;
> > case 'i':
> > ! NetServer = true;
> > break;
> > case 'k':
> > ! UnixSocketDir = optarg;
> > break;
> > #ifdef USE_SSL
> > case 'l':
> > ! EnableSSL = true;
> > break;
> > #endif
> > case 'm':
> > --- 447,469 ----
> > * Turn on debugging for the postmaster and the backend
> > * servers descended from it.
> > */
> > ! SetConfigOption("debug_level", optarg, PGC_POSTMASTER, true);
> > break;
> > case 'F':
> > ! SetConfigOption("enable_fsync", optarg, PGC_POSTMASTER, true);
> > break;
> > case 'h':
> > ! SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, true);
> > break;
> > case 'i':
> > ! SetConfigOption("tcpip_socket", optarg, PGC_POSTMASTER, true);
> > break;
> > case 'k':
> > ! SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, true);
> > break;
> > #ifdef USE_SSL
> > case 'l':
> > ! SetConfigOption("ssl", optarg, PGC_POSTMASTER, true);
> > break;
> > #endif
> > case 'm':
> > ***************
> > *** 483,493 ****
> > * 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;
> > break;
> > case 'n':
> > /* Don't reinit shared mem after abnormal exit */
> > --- 483,489 ----
> > * The max number of backends to start. Can't set to less
> > * than 1 or more than compiled-in limit.
> > */
> > ! SetConfigOption("max_connections", optarg, PGC_POSTMASTER, true);
> > break;
> > case 'n':
> > /* Don't reinit shared mem after abnormal exit */
> > ***************
> > *** 504,510 ****
> > strcpy(original_extraoptions, optarg);
> > break;
> > case 'p':
> > ! PostPortNumber = atoi(optarg);
> > break;
> > case 'S':
> >
> > --- 500,506 ----
> > strcpy(original_extraoptions, optarg);
> > break;
> > case 'p':
> > ! SetConfigOption("port", optarg, PGC_POSTMASTER, true);
> > break;
> > case 'S':
> >
> > ***************
> > *** 514,520 ****
> > * it's most badly needed on SysV-derived systems like
> > * SVR4 and HP-UX.
> > */
> > ! SilentMode = true;
> > break;
> > case 's':
> >
> > --- 510,516 ----
> > * it's most badly needed on SysV-derived systems like
> > * SVR4 and HP-UX.
> > */
> > ! SetConfigOption("silent_mode", optarg, PGC_POSTMASTER, true);
> > break;
> > case 's':
> >
> > Index: src/backend/tcop/postgres.c
> > ===================================================================
> > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v
> > retrieving revision 1.220
> > diff -u -c -r1.220 postgres.c
> > *** src/backend/tcop/postgres.c 2001/06/12 22:54:06 1.220
> > --- src/backend/tcop/postgres.c 2001/06/15 16:22:47
> > ***************
> > *** 1108,1113 ****
> > --- 1108,1115 ----
> > const char *DBName = NULL;
> > bool secure = true;
> > int errs = 0;
> > + GucContext ctx;
> > + char *tmp;
> >
> > int firstchar;
> > StringInfo parser_input;
> > ***************
> > *** 1117,1122 ****
> > --- 1119,1127 ----
> >
> > 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,1194 ****
> > {
> > case 'A':
> > #ifdef USE_ASSERT_CHECKING
> > ! assert_enabled = atoi(optarg);
> > #else
> > fprintf(stderr, "Assert checking is not compiled in\n");
> > #endif
> > --- 1193,1199 ----
> > {
> > case 'A':
> > #ifdef USE_ASSERT_CHECKING
> > ! SetConfigOption("debug_assertions", optarg, ctx, true);
> > #else
> > fprintf(stderr, "Assert checking is not compiled in\n");
> > #endif
> > ***************
> > *** 1200,1206 ****
> > * specify the size of buffer pool
> > */
> > if (secure)
> > ! NBuffers = atoi(optarg);
> > break;
> >
> > case 'C':
> > --- 1205,1211 ----
> > * specify the size of buffer pool
> > */
> > if (secure)
> > ! SetConfigOption("shared_buffers", optarg, ctx, true);
> > break;
> >
> > case 'C':
> > ***************
> > *** 1217,1233 ****
> > break;
> >
> > case 'd': /* debug level */
> > ! DebugLvl = atoi(optarg);
> > if (DebugLvl >= 1);
> > ! Log_connections = true;
> > if (DebugLvl >= 2)
> > ! Debug_print_query = true;
> > if (DebugLvl >= 3)
> > ! Debug_print_parse = true;
> > if (DebugLvl >= 4)
> > ! Debug_print_plan = true;
> > if (DebugLvl >= 5)
> > ! Debug_print_rewritten = true;
> > break;
> >
> > case 'E':
> > --- 1222,1239 ----
> > break;
> >
> > case 'd': /* debug level */
> > ! tmp = "true";
> > ! SetConfigOption("debug_level", optarg, ctx, true);
> > if (DebugLvl >= 1);
> > ! SetConfigOption("log_connections", tmp, ctx, true);
> > if (DebugLvl >= 2)
> > ! SetConfigOption("debug_print_query", tmp, ctx, true);
> > if (DebugLvl >= 3)
> > ! SetConfigOption("debug_print_parse", tmp, ctx, true);
> > if (DebugLvl >= 4)
> > ! SetConfigOption("debug_print_plan", tmp, ctx, true);
> > if (DebugLvl >= 5)
> > ! SetConfigOption("debug_print_rewritten", tmp, ctx, true);
> > break;
> >
> > case 'E':
> > ***************
> > *** 1252,1258 ****
> > * turn off fsync
> > */
> > if (secure)
> > ! enableFsync = false;
> > break;
> >
> > case 'f':
> > --- 1258,1264 ----
> > * turn off fsync
> > */
> > if (secure)
> > ! SetConfigOption("fsync", "true", ctx, true);
> > break;
> >
> > case 'f':
> > ***************
> > *** 1260,1288 ****
> > /*
> > * f - forbid generation of certain plans
> > */
> > switch (optarg[0])
> > {
> > case 's': /* seqscan */
> > ! enable_seqscan = false;
> > break;
> > case 'i': /* indexscan */
> > ! enable_indexscan = false;
> > break;
> > case 't': /* tidscan */
> > ! enable_tidscan = false;
> > break;
> > case 'n': /* nestloop */
> > ! enable_nestloop = false;
> > break;
> > case 'm': /* mergejoin */
> > ! enable_mergejoin = false;
> > break;
> > case 'h': /* hashjoin */
> > ! enable_hashjoin = false;
> > break;
> > default:
> > errs++;
> > }
> > break;
> >
> > case 'i':
> > --- 1266,1297 ----
> > /*
> > * f - forbid generation of certain plans
> > */
> > + tmp = NULL;
> > switch (optarg[0])
> > {
> > case 's': /* seqscan */
> > ! tmp = "enable_seqscan";
> > break;
> > case 'i': /* indexscan */
> > ! tmp = "enable_indexscan";
> > break;
> > case 't': /* tidscan */
> > ! tmp = "enable_tidscan";
> > break;
> > case 'n': /* nestloop */
> > ! tmp = "enable_nestloop";
> > break;
> > case 'm': /* mergejoin */
> > ! tmp = "enable_mergejoin";
> > break;
> > case 'h': /* hashjoin */
> > ! tmp = "enable_hashjoin";
> > break;
> > default:
> > errs++;
> > }
> > + if (tmp)
> > + SetConfigOption(tmp, "false", ctx, true);
> > break;
> >
> > case 'i':
> > ***************
> > *** 1352,1364 ****
> > /*
> > * S - amount of sort memory to use in 1k bytes
> > */
> > ! {
> > ! int S;
> > !
> > ! S = atoi(optarg);
> > ! if (S >= 4 * BLCKSZ / 1024)
> > ! SortMem = S;
> > ! }
> > break;
> >
> > case 's':
> > --- 1361,1367 ----
> > /*
> > * S - amount of sort memory to use in 1k bytes
> > */
> > ! SetConfigOption("sort_mem", optarg, ctx, true);
> > break;
> >
> > case 's':
> > ***************
> > *** 1366,1372 ****
> > /*
> > * s - report usage statistics (timings) after each query
> > */
> > ! Show_query_stats = 1;
> > break;
> >
> > case 't':
> > --- 1369,1375 ----
> > /*
> > * s - report usage statistics (timings) after each query
> > */
> > ! SetConfigOption("show_query_stats", optarg, ctx, true);
> > break;
> >
> > case 't':
> > ***************
> > *** 1380,1402 ****
> > * caution: -s can not be used together with -t.
> > * ----------------
> > */
> > switch (optarg[0])
> > {
> > case 'p':
> > if (optarg[1] == 'a')
> > ! Show_parser_stats = 1;
> > else if (optarg[1] == 'l')
> > ! Show_planner_stats = 1;
> > else
> > errs++;
> > break;
> > case 'e':
> > ! Show_executor_stats = 1;
> > break;
> > default:
> > errs++;
> > break;
> > }
> > break;
> >
> > case 'v':
> > --- 1383,1408 ----
> > * caution: -s can not be used together with -t.
> > * ----------------
> > */
> > + tmp = NULL;
> > switch (optarg[0])
> > {
> > case 'p':
> > if (optarg[1] == 'a')
> > ! tmp = "show_parser_stats";
> > else if (optarg[1] == 'l')
> > ! tmp = "show_planner_stats";
> > else
> > errs++;
> > break;
> > case 'e':
> > ! tmp = "show_parser_stats";
> > break;
> > default:
> > errs++;
> > break;
> > }
> > + if (tmp)
> > + SetConfigOption(tmp, "true", ctx, true);
> > break;
> >
> > case 'v':
> > ***************
> > *** 1460,1468 ****
> > elog(ERROR, "-c %s requires argument", optarg);
> > }
> >
> > ! /* all options are allowed if not under postmaster */
> > ! SetConfigOption(name, value,
> > ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
> > free(name);
> > if (value)
> > free(value);
> > --- 1466,1472 ----
> > elog(ERROR, "-c %s requires argument", optarg);
> > }
> >
> > ! SetConfigOption(name, value, ctx, true);
> > free(name);
> > if (value)
> > free(value);
> > Index: src/backend/utils/misc/guc.c
> > ===================================================================
> > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
> > retrieving revision 1.38
> > diff -u -c -r1.38 guc.c
> > *** src/backend/utils/misc/guc.c 2001/06/12 22:54:06 1.38
> > --- src/backend/utils/misc/guc.c 2001/06/15 16:22:49
> > ***************
> > *** 270,276 ****
> > DEF_PGPORT, 1, 65535, NULL, NULL},
> >
> > {"sort_mem", PGC_USERSET, &SortMem,
> > ! 512, 1, INT_MAX, NULL, NULL},
> >
> > {"debug_level", PGC_USERSET, &DebugLvl,
> > 0, 0, 16, NULL, NULL},
> > --- 270,276 ----
> > DEF_PGPORT, 1, 65535, NULL, NULL},
> >
> > {"sort_mem", PGC_USERSET, &SortMem,
> > ! 512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL},
> >
> > {"debug_level", PGC_USERSET, &DebugLvl,
> > 0, 0, 16, NULL, NULL},
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> > http://www.postgresql.org/search.mpl
> >
>
>

--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter


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

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

regards, tom lane


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

> 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.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Attachment Content-Type Size
unknown_filename text/plain 18.7 KB

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 | Resend email
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},


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

Marko Kreen writes:

> 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.

No. PGC_BACKEND settings have no permission check, because users can pass
them in from the client with the PGOPTIONS environment variable. The fix
might involve a non-trivial rearrangement of the way PGOPTIONS is
processed (might be impossible, because PGC_BACKEND might be useless if
the setting will only happen after the first table access (pg_shadow)) or
another context level (might be too much work for one case). At the
moment you might want to just cheat and fix the context at PGC_POSTMASTER
for this particular case.

> 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?

See include/utils/guc.h

--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
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 22:23:03
Message-ID: 22930.993162183@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Marko Kreen <marko(at)l-t(dot)ee> writes:
>> No. PGC_BACKEND settings have no permission check, because users can pass
>> them in from the client with the PGOPTIONS environment variable. The fix
>> might involve a non-trivial rearrangement of the way PGOPTIONS is
>> processed (might be impossible, because PGC_BACKEND might be useless if
>> the setting will only happen after the first table access (pg_shadow)) or
>> another context level (might be too much work for one case). At the
>> moment you might want to just cheat and fix the context at PGC_POSTMASTER
>> for this particular case.

> Do you mean following?

> 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.

Note that the above change for log_connections is shown to be wrong
by this same logic, because -d is *not* a secure switch. If you do want
to keep log_connections protected against being set by mere users,
then the appropriate coding would be

if (DebugLvl >= 1 && secure)
SetConfigOption("log_connections", tmp, PGC_POSTMASTER, true);
if (DebugLvl >= 2)
SetConfigOption("debug_print_query", tmp, ctx, true);
... etc ...

but again, I don't see a rationale for this restriction.

regards, tom lane


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

On Wed, Jun 20, 2001 at 05:43:07PM +0200, Peter Eisentraut wrote:
> Marko Kreen writes:
>
> > 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.
>
> No. PGC_BACKEND settings have no permission check, because users can pass
> them in from the client with the PGOPTIONS environment variable. The fix
> might involve a non-trivial rearrangement of the way PGOPTIONS is
> processed (might be impossible, because PGC_BACKEND might be useless if
> the setting will only happen after the first table access (pg_shadow)) or
> another context level (might be too much work for one case). At the
> moment you might want to just cheat and fix the context at PGC_POSTMASTER
> for this particular case.

Do you mean following?

--
marko

diff -u src/backend/tcop/postgres.c src/backend/tcop/postgres.c
--- src/backend/tcop/postgres.c
+++ src/backend/tcop/postgres.c
@@ -1225,7 +1225,7 @@
tmp = "true";
SetConfigOption("debug_level", optarg, ctx, true);
if (DebugLvl >= 1);
- SetConfigOption("log_connections", tmp, ctx, true);
+ SetConfigOption("log_connections", tmp, PGC_POSTMASTER, true);
if (DebugLvl >= 2)
SetConfigOption("debug_print_query", tmp, ctx, true);
if (DebugLvl >= 3)
@@ -1258,7 +1258,7 @@
* turn off fsync
*/
if (secure)
- SetConfigOption("fsync", "false", ctx, true);
+ SetConfigOption("fsync", "false", PGC_POSTMASTER, true);
break;

case 'f':


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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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},


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
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:50:44
Message-ID: 28267.993167444@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Marko Kreen <marko(at)l-t(dot)ee> writes:
>> 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.

> - if (secure)
> - SetConfigOption("shared_buffers", optarg, ctx, true);
> + SetConfigOption("shared_buffers", optarg, secure_ctx, true);

Uh, removing the security checks is NOT what I had in mind. Wasn't
my example clear enough?

regards, tom lane


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-22 00:36:40
Message-ID: 20010622023640.A12679@l-t.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Thu, Jun 21, 2001 at 07:50:44PM -0400, Tom Lane wrote:
> Marko Kreen <marko(at)l-t(dot)ee> writes:
> >> 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.
>
> > - if (secure)
> > - SetConfigOption("shared_buffers", optarg, ctx, true);
> > + SetConfigOption("shared_buffers", optarg, secure_ctx, true);
>
> Uh, removing the security checks is NOT what I had in mind. Wasn't
> my example clear enough?

Ee, this is done in set_config_option?

secure_ctx = PGC_POSTMASTER until '-p' then it will
get ordinary 'ctx'. This should follow use of secure.
Ofcourse this assumes all GUC vars you want to protect
with 'secure' have PGC_POSTMASTER/PGC_SIGHUP as context.
Wont it be true?

--
marko


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
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-22 01:09:20
Message-ID: 2182.993172160@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Marko Kreen <marko(at)l-t(dot)ee> writes:
>> Uh, removing the security checks is NOT what I had in mind. Wasn't
>> my example clear enough?

> Ee, this is done in set_config_option?

No, you still need the if (secure) --- because that changes while
we're reading the switches. *If* secure is true, it's okay to set
the option with PGC_POSTMASTER context.

regards, tom lane


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-22 08:52:42
Message-ID: 20010622105242.A14582@l-t.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Thu, Jun 21, 2001 at 09:09:20PM -0400, Tom Lane wrote:
> Marko Kreen <marko(at)l-t(dot)ee> writes:
> >> Uh, removing the security checks is NOT what I had in mind. Wasn't
> >> my example clear enough?
>
> > Ee, this is done in set_config_option?
>
> No, you still need the if (secure) --- because that changes while
> we're reading the switches. *If* secure is true, it's okay to set
> the option with PGC_POSTMASTER context.

secure_ctx changes too. it will be PGC_BACKEND after '-p'.

I did it this way, because I imagined the 'if (secure)' as a
permission check for non-GUC variables. For GUC the permission
checks should be done in guc.c, this also means clearer code
in postgres.c. Now that I think about it, it could be
even simplified to the following.

This is mostly matter of taste, and I can ofcourse do it your
way, but ATM it seems to me you missed the secure_ctx = ctx;
line in last patch.

--
marko

diff -u src/backend/tcop/postgres.c src/backend/tcop/postgres.c
--- src/backend/tcop/postgres.c
+++ src/backend/tcop/postgres.c
@@ -1120,8 +1120,8 @@

char *potential_DataDir = NULL;

- /* all options are allowed if not under postmaster */
- ctx = IsUnderPostmaster ? PGC_BACKEND : PGC_POSTMASTER;
+ /* all options are allowed if not under postmaster or until -p */
+ ctx = PGC_POSTMASTER;

/*
* Catch standard options before doing much else. This even works on
@@ -1207,8 +1207,7 @@
/*
* specify the size of buffer pool
*/
- if (secure)
- SetConfigOption("shared_buffers", optarg, ctx, true);
+ SetConfigOption("shared_buffers", optarg, ctx, true);
break;

case 'C':
@@ -1227,8 +1226,8 @@
case 'd': /* debug level */
tmp = "true";
SetConfigOption("debug_level", optarg, ctx, true);
- if (DebugLvl >= 1);
- SetConfigOption("log_connections", tmp, ctx, 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 +1259,7 @@
/*
* turn off fsync
*/
- if (secure)
- SetConfigOption("fsync", "false", ctx, true);
+ SetConfigOption("fsync", "false", ctx, true);
break;

case 'f':
@@ -1356,6 +1354,7 @@
DBName = strdup(optarg);
secure = false; /* subsequent switches are NOT
* secure */
+ ctx = PGC_BACKEND;
}
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},


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
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-22 13:18:55
Message-ID: 3129.993215935@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Marko Kreen <marko(at)l-t(dot)ee> writes:
> secure_ctx changes too. it will be PGC_BACKEND after '-p'.

Oh, okay, I missed that part. Could we see the total state of the
patch --- ie, a diff against current CVS, not a bunch of deltas?
I've gotten confused about what's in and what's out.

regards, tom lane


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-22 16:29:14
Message-ID: 20010622182914.A16887@l-t.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

On Fri, Jun 22, 2001 at 09:18:55AM -0400, Tom Lane wrote:
> Marko Kreen <marko(at)l-t(dot)ee> writes:
> > secure_ctx changes too. it will be PGC_BACKEND after '-p'.
>
> Oh, okay, I missed that part. Could we see the total state of the
> patch --- ie, a diff against current CVS, not a bunch of deltas?
> I've gotten confused about what's in and what's out.

Ok, here it is. Cleared the ctx comment too - after -p
it will be PGC_BACKEND in any case.

--
marko

Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.225
diff -u -c -r1.225 postmaster.c
*** src/backend/postmaster/postmaster.c 2001/06/21 16:43:24 1.225
--- src/backend/postmaster/postmaster.c 2001/06/22 13:57:02
***************
*** 429,442 ****
#ifndef USE_ASSERT_CHECKING
postmaster_error("Assert checking is not compiled in.");
#else
! assert_enabled = atoi(optarg);
#endif
break;
case 'a':
/* Can no longer set authentication method. */
break;
case 'B':
! NBuffers = atoi(optarg);
break;
case 'b':
/* Can no longer set the backend executable file to use. */
--- 429,442 ----
#ifndef USE_ASSERT_CHECKING
postmaster_error("Assert checking is not compiled in.");
#else
! SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, true);
#endif
break;
case 'a':
/* Can no longer set authentication method. */
break;
case 'B':
! SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
break;
case 'b':
/* Can no longer set the backend executable file to use. */
***************
*** 450,472 ****
* Turn on debugging for the postmaster and the backend
* servers descended from it.
*/
! DebugLvl = atoi(optarg);
break;
case 'F':
! enableFsync = false;
break;
case 'h':
! VirtualHost = optarg;
break;
case 'i':
! NetServer = true;
break;
case 'k':
! UnixSocketDir = optarg;
break;
#ifdef USE_SSL
case 'l':
! EnableSSL = true;
break;
#endif
case 'm':
--- 450,472 ----
* Turn on debugging for the postmaster and the backend
* servers descended from it.
*/
! SetConfigOption("debug_level", optarg, PGC_POSTMASTER, true);
break;
case 'F':
! SetConfigOption("enable_fsync", "false", PGC_POSTMASTER, true);
break;
case 'h':
! SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, true);
break;
case 'i':
! SetConfigOption("tcpip_socket", "true", PGC_POSTMASTER, true);
break;
case 'k':
! SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, true);
break;
#ifdef USE_SSL
case 'l':
! SetConfigOption("ssl", "true", PGC_POSTMASTER, true);
break;
#endif
case 'm':
***************
*** 486,496 ****
* 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;
break;
case 'n':
/* Don't reinit shared mem after abnormal exit */
--- 486,492 ----
* The max number of backends to start. Can't set to less
* than 1 or more than compiled-in limit.
*/
! SetConfigOption("max_connections", optarg, PGC_POSTMASTER, true);
break;
case 'n':
/* Don't reinit shared mem after abnormal exit */
***************
*** 507,513 ****
strcpy(original_extraoptions, optarg);
break;
case 'p':
! PostPortNumber = atoi(optarg);
break;
case 'S':

--- 503,509 ----
strcpy(original_extraoptions, optarg);
break;
case 'p':
! SetConfigOption("port", optarg, PGC_POSTMASTER, true);
break;
case 'S':

***************
*** 517,523 ****
* it's most badly needed on SysV-derived systems like
* SVR4 and HP-UX.
*/
! SilentMode = true;
break;
case 's':

--- 513,519 ----
* it's most badly needed on SysV-derived systems like
* SVR4 and HP-UX.
*/
! SetConfigOption("silent_mode", "true", PGC_POSTMASTER, true);
break;
case 's':

Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v
retrieving revision 1.223
diff -u -c -r1.223 postgres.c
*** src/backend/tcop/postgres.c 2001/06/20 18:07:55 1.223
--- src/backend/tcop/postgres.c 2001/06/22 13:57:07
***************
*** 1109,1114 ****
--- 1109,1116 ----
const char *DBName = NULL;
bool secure = true;
int errs = 0;
+ GucContext ctx;
+ char *tmp;

int firstchar;
StringInfo parser_input;
***************
*** 1118,1123 ****
--- 1120,1128 ----

char *potential_DataDir = NULL;

+ /* all options are allowed until '-p' */
+ ctx = PGC_POSTMASTER;
+
/*
* Catch standard options before doing much else. This even works on
* systems without getopt_long.
***************
*** 1191,1197 ****
{
case 'A':
#ifdef USE_ASSERT_CHECKING
! assert_enabled = atoi(optarg);
#else
fprintf(stderr, "Assert checking is not compiled in\n");
#endif
--- 1196,1202 ----
{
case 'A':
#ifdef USE_ASSERT_CHECKING
! SetConfigOption("debug_assertions", optarg, ctx, true);
#else
fprintf(stderr, "Assert checking is not compiled in\n");
#endif
***************
*** 1202,1209 ****
/*
* specify the size of buffer pool
*/
! if (secure)
! NBuffers = atoi(optarg);
break;

case 'C':
--- 1207,1213 ----
/*
* specify the size of buffer pool
*/
! SetConfigOption("shared_buffers", optarg, ctx, true);
break;

case 'C':
***************
*** 1220,1236 ****
break;

case 'd': /* debug level */
! DebugLvl = atoi(optarg);
! if (DebugLvl >= 1);
! Log_connections = true;
if (DebugLvl >= 2)
! Debug_print_query = true;
if (DebugLvl >= 3)
! Debug_print_parse = true;
if (DebugLvl >= 4)
! Debug_print_plan = true;
if (DebugLvl >= 5)
! Debug_print_rewritten = true;
break;

case 'E':
--- 1224,1241 ----
break;

case 'd': /* debug level */
! tmp = "true";
! SetConfigOption("debug_level", optarg, ctx, true);
! if (DebugLvl >= 1)
! SetConfigOption("log_connections", tmp, ctx, true);
if (DebugLvl >= 2)
! SetConfigOption("debug_print_query", tmp, ctx, true);
if (DebugLvl >= 3)
! SetConfigOption("debug_print_parse", tmp, ctx, true);
if (DebugLvl >= 4)
! SetConfigOption("debug_print_plan", tmp, ctx, true);
if (DebugLvl >= 5)
! SetConfigOption("debug_print_rewritten", tmp, ctx, true);
break;

case 'E':
***************
*** 1254,1261 ****
/*
* turn off fsync
*/
! if (secure)
! enableFsync = false;
break;

case 'f':
--- 1259,1265 ----
/*
* turn off fsync
*/
! SetConfigOption("fsync", "false", ctx, true);
break;

case 'f':
***************
*** 1263,1291 ****
/*
* f - forbid generation of certain plans
*/
switch (optarg[0])
{
case 's': /* seqscan */
! enable_seqscan = false;
break;
case 'i': /* indexscan */
! enable_indexscan = false;
break;
case 't': /* tidscan */
! enable_tidscan = false;
break;
case 'n': /* nestloop */
! enable_nestloop = false;
break;
case 'm': /* mergejoin */
! enable_mergejoin = false;
break;
case 'h': /* hashjoin */
! enable_hashjoin = false;
break;
default:
errs++;
}
break;

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

case 'i':
***************
*** 1347,1352 ****
--- 1354,1360 ----
DBName = strdup(optarg);
secure = false; /* subsequent switches are NOT
* secure */
+ ctx = PGC_BACKEND;
}
break;

***************
*** 1355,1367 ****
/*
* S - amount of sort memory to use in 1k bytes
*/
! {
! int S;
!
! S = atoi(optarg);
! if (S >= 4 * BLCKSZ / 1024)
! SortMem = S;
! }
break;

case 's':
--- 1363,1369 ----
/*
* S - amount of sort memory to use in 1k bytes
*/
! SetConfigOption("sort_mem", optarg, ctx, true);
break;

case 's':
***************
*** 1369,1375 ****
/*
* s - report usage statistics (timings) after each query
*/
! Show_query_stats = 1;
break;

case 't':
--- 1371,1377 ----
/*
* s - report usage statistics (timings) after each query
*/
! SetConfigOption("show_query_stats", "true", ctx, true);
break;

case 't':
***************
*** 1383,1405 ****
* caution: -s can not be used together with -t.
* ----------------
*/
switch (optarg[0])
{
case 'p':
if (optarg[1] == 'a')
! Show_parser_stats = 1;
else if (optarg[1] == 'l')
! Show_planner_stats = 1;
else
errs++;
break;
case 'e':
! Show_executor_stats = 1;
break;
default:
errs++;
break;
}
break;

case 'v':
--- 1385,1410 ----
* caution: -s can not be used together with -t.
* ----------------
*/
+ tmp = NULL;
switch (optarg[0])
{
case 'p':
if (optarg[1] == 'a')
! tmp = "show_parser_stats";
else if (optarg[1] == 'l')
! tmp = "show_planner_stats";
else
errs++;
break;
case 'e':
! tmp = "show_parser_stats";
break;
default:
errs++;
break;
}
+ if (tmp)
+ SetConfigOption(tmp, "true", ctx, true);
break;

case 'v':
***************
*** 1463,1471 ****
elog(ERROR, "-c %s requires argument", optarg);
}

! /* all options are allowed if not under postmaster */
! SetConfigOption(name, value,
! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
free(name);
if (value)
free(value);
--- 1468,1474 ----
elog(ERROR, "-c %s requires argument", optarg);
}

! SetConfigOption(name, value, ctx, true);
free(name);
if (value)
free(value);
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.41
diff -u -c -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/22 13:57:10
***************
*** 196,202 ****
{"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
{"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL},

! {"log_connections", PGC_SIGHUP, &Log_connections, false, NULL},
{"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL},
{"log_pid", PGC_SIGHUP, &Log_pid, false, NULL},

--- 196,202 ----
{"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
{"silent_mode", PGC_POSTMASTER, &SilentMode, 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},

***************
*** 276,282 ****
DEF_PGPORT, 1, 65535, NULL, NULL},

{"sort_mem", PGC_USERSET, &SortMem,
! 512, 1, INT_MAX, NULL, NULL},

{"debug_level", PGC_USERSET, &DebugLvl,
0, 0, 16, NULL, NULL},
--- 276,282 ----
DEF_PGPORT, 1, 65535, NULL, NULL},

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

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


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
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-23 01:55:22
Message-ID: 200106230155.f5N1tMn00945@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

Your patch has been added to the PostgreSQL unapplied patches list at:

http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

> On Fri, Jun 22, 2001 at 09:18:55AM -0400, Tom Lane wrote:
> > Marko Kreen <marko(at)l-t(dot)ee> writes:
> > > secure_ctx changes too. it will be PGC_BACKEND after '-p'.
> >
> > Oh, okay, I missed that part. Could we see the total state of the
> > patch --- ie, a diff against current CVS, not a bunch of deltas?
> > I've gotten confused about what's in and what's out.
>
> Ok, here it is. Cleared the ctx comment too - after -p
> it will be PGC_BACKEND in any case.
>
> --
> marko
>
>
> Index: src/backend/postmaster/postmaster.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
> retrieving revision 1.225
> diff -u -c -r1.225 postmaster.c
> *** src/backend/postmaster/postmaster.c 2001/06/21 16:43:24 1.225
> --- src/backend/postmaster/postmaster.c 2001/06/22 13:57:02
> ***************
> *** 429,442 ****
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! assert_enabled = atoi(optarg);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! NBuffers = atoi(optarg);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> --- 429,442 ----
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, true);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> ***************
> *** 450,472 ****
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! DebugLvl = atoi(optarg);
> break;
> case 'F':
> ! enableFsync = false;
> break;
> case 'h':
> ! VirtualHost = optarg;
> break;
> case 'i':
> ! NetServer = true;
> break;
> case 'k':
> ! UnixSocketDir = optarg;
> break;
> #ifdef USE_SSL
> case 'l':
> ! EnableSSL = true;
> break;
> #endif
> case 'm':
> --- 450,472 ----
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! SetConfigOption("debug_level", optarg, PGC_POSTMASTER, true);
> break;
> case 'F':
> ! SetConfigOption("enable_fsync", "false", PGC_POSTMASTER, true);
> break;
> case 'h':
> ! SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, true);
> break;
> case 'i':
> ! SetConfigOption("tcpip_socket", "true", PGC_POSTMASTER, true);
> break;
> case 'k':
> ! SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, true);
> break;
> #ifdef USE_SSL
> case 'l':
> ! SetConfigOption("ssl", "true", PGC_POSTMASTER, true);
> break;
> #endif
> case 'm':
> ***************
> *** 486,496 ****
> * 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;
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> --- 486,492 ----
> * The max number of backends to start. Can't set to less
> * than 1 or more than compiled-in limit.
> */
> ! SetConfigOption("max_connections", optarg, PGC_POSTMASTER, true);
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> ***************
> *** 507,513 ****
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! PostPortNumber = atoi(optarg);
> break;
> case 'S':
>
> --- 503,509 ----
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! SetConfigOption("port", optarg, PGC_POSTMASTER, true);
> break;
> case 'S':
>
> ***************
> *** 517,523 ****
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SilentMode = true;
> break;
> case 's':
>
> --- 513,519 ----
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SetConfigOption("silent_mode", "true", PGC_POSTMASTER, true);
> break;
> case 's':
>
> Index: src/backend/tcop/postgres.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v
> retrieving revision 1.223
> diff -u -c -r1.223 postgres.c
> *** src/backend/tcop/postgres.c 2001/06/20 18:07:55 1.223
> --- src/backend/tcop/postgres.c 2001/06/22 13:57:07
> ***************
> *** 1109,1114 ****
> --- 1109,1116 ----
> const char *DBName = NULL;
> bool secure = true;
> int errs = 0;
> + GucContext ctx;
> + char *tmp;
>
> int firstchar;
> StringInfo parser_input;
> ***************
> *** 1118,1123 ****
> --- 1120,1128 ----
>
> char *potential_DataDir = NULL;
>
> + /* all options are allowed until '-p' */
> + ctx = PGC_POSTMASTER;
> +
> /*
> * Catch standard options before doing much else. This even works on
> * systems without getopt_long.
> ***************
> *** 1191,1197 ****
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! assert_enabled = atoi(optarg);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> --- 1196,1202 ----
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! SetConfigOption("debug_assertions", optarg, ctx, true);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> ***************
> *** 1202,1209 ****
> /*
> * specify the size of buffer pool
> */
> ! if (secure)
> ! NBuffers = atoi(optarg);
> break;
>
> case 'C':
> --- 1207,1213 ----
> /*
> * specify the size of buffer pool
> */
> ! SetConfigOption("shared_buffers", optarg, ctx, true);
> break;
>
> case 'C':
> ***************
> *** 1220,1236 ****
> break;
>
> case 'd': /* debug level */
> ! DebugLvl = atoi(optarg);
> ! if (DebugLvl >= 1);
> ! Log_connections = true;
> if (DebugLvl >= 2)
> ! Debug_print_query = true;
> if (DebugLvl >= 3)
> ! Debug_print_parse = true;
> if (DebugLvl >= 4)
> ! Debug_print_plan = true;
> if (DebugLvl >= 5)
> ! Debug_print_rewritten = true;
> break;
>
> case 'E':
> --- 1224,1241 ----
> break;
>
> case 'd': /* debug level */
> ! tmp = "true";
> ! SetConfigOption("debug_level", optarg, ctx, true);
> ! if (DebugLvl >= 1)
> ! SetConfigOption("log_connections", tmp, ctx, true);
> if (DebugLvl >= 2)
> ! SetConfigOption("debug_print_query", tmp, ctx, true);
> if (DebugLvl >= 3)
> ! SetConfigOption("debug_print_parse", tmp, ctx, true);
> if (DebugLvl >= 4)
> ! SetConfigOption("debug_print_plan", tmp, ctx, true);
> if (DebugLvl >= 5)
> ! SetConfigOption("debug_print_rewritten", tmp, ctx, true);
> break;
>
> case 'E':
> ***************
> *** 1254,1261 ****
> /*
> * turn off fsync
> */
> ! if (secure)
> ! enableFsync = false;
> break;
>
> case 'f':
> --- 1259,1265 ----
> /*
> * turn off fsync
> */
> ! SetConfigOption("fsync", "false", ctx, true);
> break;
>
> case 'f':
> ***************
> *** 1263,1291 ****
> /*
> * f - forbid generation of certain plans
> */
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! enable_seqscan = false;
> break;
> case 'i': /* indexscan */
> ! enable_indexscan = false;
> break;
> case 't': /* tidscan */
> ! enable_tidscan = false;
> break;
> case 'n': /* nestloop */
> ! enable_nestloop = false;
> break;
> case 'm': /* mergejoin */
> ! enable_mergejoin = false;
> break;
> case 'h': /* hashjoin */
> ! enable_hashjoin = false;
> break;
> default:
> errs++;
> }
> break;
>
> case 'i':
> --- 1267,1298 ----
> /*
> * f - forbid generation of certain plans
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! tmp = "enable_seqscan";
> break;
> case 'i': /* indexscan */
> ! tmp = "enable_indexscan";
> break;
> case 't': /* tidscan */
> ! tmp = "enable_tidscan";
> break;
> case 'n': /* nestloop */
> ! tmp = "enable_nestloop";
> break;
> case 'm': /* mergejoin */
> ! tmp = "enable_mergejoin";
> break;
> case 'h': /* hashjoin */
> ! tmp = "enable_hashjoin";
> break;
> default:
> errs++;
> }
> + if (tmp)
> + SetConfigOption(tmp, "false", ctx, true);
> break;
>
> case 'i':
> ***************
> *** 1347,1352 ****
> --- 1354,1360 ----
> DBName = strdup(optarg);
> secure = false; /* subsequent switches are NOT
> * secure */
> + ctx = PGC_BACKEND;
> }
> break;
>
> ***************
> *** 1355,1367 ****
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! {
> ! int S;
> !
> ! S = atoi(optarg);
> ! if (S >= 4 * BLCKSZ / 1024)
> ! SortMem = S;
> ! }
> break;
>
> case 's':
> --- 1363,1369 ----
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! SetConfigOption("sort_mem", optarg, ctx, true);
> break;
>
> case 's':
> ***************
> *** 1369,1375 ****
> /*
> * s - report usage statistics (timings) after each query
> */
> ! Show_query_stats = 1;
> break;
>
> case 't':
> --- 1371,1377 ----
> /*
> * s - report usage statistics (timings) after each query
> */
> ! SetConfigOption("show_query_stats", "true", ctx, true);
> break;
>
> case 't':
> ***************
> *** 1383,1405 ****
> * caution: -s can not be used together with -t.
> * ----------------
> */
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! Show_parser_stats = 1;
> else if (optarg[1] == 'l')
> ! Show_planner_stats = 1;
> else
> errs++;
> break;
> case 'e':
> ! Show_executor_stats = 1;
> break;
> default:
> errs++;
> break;
> }
> break;
>
> case 'v':
> --- 1385,1410 ----
> * caution: -s can not be used together with -t.
> * ----------------
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! tmp = "show_parser_stats";
> else if (optarg[1] == 'l')
> ! tmp = "show_planner_stats";
> else
> errs++;
> break;
> case 'e':
> ! tmp = "show_parser_stats";
> break;
> default:
> errs++;
> break;
> }
> + if (tmp)
> + SetConfigOption(tmp, "true", ctx, true);
> break;
>
> case 'v':
> ***************
> *** 1463,1471 ****
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! /* all options are allowed if not under postmaster */
> ! SetConfigOption(name, value,
> ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
> free(name);
> if (value)
> free(value);
> --- 1468,1474 ----
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! SetConfigOption(name, value, ctx, true);
> free(name);
> if (value)
> free(value);
> Index: src/backend/utils/misc/guc.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
> retrieving revision 1.41
> diff -u -c -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/22 13:57:10
> ***************
> *** 196,202 ****
> {"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
> {"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL},
>
> ! {"log_connections", PGC_SIGHUP, &Log_connections, false, NULL},
> {"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL},
> {"log_pid", PGC_SIGHUP, &Log_pid, false, NULL},
>
> --- 196,202 ----
> {"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
> {"silent_mode", PGC_POSTMASTER, &SilentMode, 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},
>
> ***************
> *** 276,282 ****
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 1, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
> --- 276,282 ----
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Marko Kreen <marko(at)l-t(dot)ee>
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-23 22:21:13
Message-ID: 200106232221.f5NMLDY11939@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches


Patch applied. Thanks.

> On Fri, Jun 22, 2001 at 09:18:55AM -0400, Tom Lane wrote:
> > Marko Kreen <marko(at)l-t(dot)ee> writes:
> > > secure_ctx changes too. it will be PGC_BACKEND after '-p'.
> >
> > Oh, okay, I missed that part. Could we see the total state of the
> > patch --- ie, a diff against current CVS, not a bunch of deltas?
> > I've gotten confused about what's in and what's out.
>
> Ok, here it is. Cleared the ctx comment too - after -p
> it will be PGC_BACKEND in any case.
>
> --
> marko
>
>
> Index: src/backend/postmaster/postmaster.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/postmaster/postmaster.c,v
> retrieving revision 1.225
> diff -u -c -r1.225 postmaster.c
> *** src/backend/postmaster/postmaster.c 2001/06/21 16:43:24 1.225
> --- src/backend/postmaster/postmaster.c 2001/06/22 13:57:02
> ***************
> *** 429,442 ****
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! assert_enabled = atoi(optarg);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! NBuffers = atoi(optarg);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> --- 429,442 ----
> #ifndef USE_ASSERT_CHECKING
> postmaster_error("Assert checking is not compiled in.");
> #else
> ! SetConfigOption("debug_assertions", optarg, PGC_POSTMASTER, true);
> #endif
> break;
> case 'a':
> /* Can no longer set authentication method. */
> break;
> case 'B':
> ! SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, true);
> break;
> case 'b':
> /* Can no longer set the backend executable file to use. */
> ***************
> *** 450,472 ****
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! DebugLvl = atoi(optarg);
> break;
> case 'F':
> ! enableFsync = false;
> break;
> case 'h':
> ! VirtualHost = optarg;
> break;
> case 'i':
> ! NetServer = true;
> break;
> case 'k':
> ! UnixSocketDir = optarg;
> break;
> #ifdef USE_SSL
> case 'l':
> ! EnableSSL = true;
> break;
> #endif
> case 'm':
> --- 450,472 ----
> * Turn on debugging for the postmaster and the backend
> * servers descended from it.
> */
> ! SetConfigOption("debug_level", optarg, PGC_POSTMASTER, true);
> break;
> case 'F':
> ! SetConfigOption("enable_fsync", "false", PGC_POSTMASTER, true);
> break;
> case 'h':
> ! SetConfigOption("virtual_host", optarg, PGC_POSTMASTER, true);
> break;
> case 'i':
> ! SetConfigOption("tcpip_socket", "true", PGC_POSTMASTER, true);
> break;
> case 'k':
> ! SetConfigOption("unix_socket_directory", optarg, PGC_POSTMASTER, true);
> break;
> #ifdef USE_SSL
> case 'l':
> ! SetConfigOption("ssl", "true", PGC_POSTMASTER, true);
> break;
> #endif
> case 'm':
> ***************
> *** 486,496 ****
> * 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;
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> --- 486,492 ----
> * The max number of backends to start. Can't set to less
> * than 1 or more than compiled-in limit.
> */
> ! SetConfigOption("max_connections", optarg, PGC_POSTMASTER, true);
> break;
> case 'n':
> /* Don't reinit shared mem after abnormal exit */
> ***************
> *** 507,513 ****
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! PostPortNumber = atoi(optarg);
> break;
> case 'S':
>
> --- 503,509 ----
> strcpy(original_extraoptions, optarg);
> break;
> case 'p':
> ! SetConfigOption("port", optarg, PGC_POSTMASTER, true);
> break;
> case 'S':
>
> ***************
> *** 517,523 ****
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SilentMode = true;
> break;
> case 's':
>
> --- 513,519 ----
> * it's most badly needed on SysV-derived systems like
> * SVR4 and HP-UX.
> */
> ! SetConfigOption("silent_mode", "true", PGC_POSTMASTER, true);
> break;
> case 's':
>
> Index: src/backend/tcop/postgres.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/tcop/postgres.c,v
> retrieving revision 1.223
> diff -u -c -r1.223 postgres.c
> *** src/backend/tcop/postgres.c 2001/06/20 18:07:55 1.223
> --- src/backend/tcop/postgres.c 2001/06/22 13:57:07
> ***************
> *** 1109,1114 ****
> --- 1109,1116 ----
> const char *DBName = NULL;
> bool secure = true;
> int errs = 0;
> + GucContext ctx;
> + char *tmp;
>
> int firstchar;
> StringInfo parser_input;
> ***************
> *** 1118,1123 ****
> --- 1120,1128 ----
>
> char *potential_DataDir = NULL;
>
> + /* all options are allowed until '-p' */
> + ctx = PGC_POSTMASTER;
> +
> /*
> * Catch standard options before doing much else. This even works on
> * systems without getopt_long.
> ***************
> *** 1191,1197 ****
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! assert_enabled = atoi(optarg);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> --- 1196,1202 ----
> {
> case 'A':
> #ifdef USE_ASSERT_CHECKING
> ! SetConfigOption("debug_assertions", optarg, ctx, true);
> #else
> fprintf(stderr, "Assert checking is not compiled in\n");
> #endif
> ***************
> *** 1202,1209 ****
> /*
> * specify the size of buffer pool
> */
> ! if (secure)
> ! NBuffers = atoi(optarg);
> break;
>
> case 'C':
> --- 1207,1213 ----
> /*
> * specify the size of buffer pool
> */
> ! SetConfigOption("shared_buffers", optarg, ctx, true);
> break;
>
> case 'C':
> ***************
> *** 1220,1236 ****
> break;
>
> case 'd': /* debug level */
> ! DebugLvl = atoi(optarg);
> ! if (DebugLvl >= 1);
> ! Log_connections = true;
> if (DebugLvl >= 2)
> ! Debug_print_query = true;
> if (DebugLvl >= 3)
> ! Debug_print_parse = true;
> if (DebugLvl >= 4)
> ! Debug_print_plan = true;
> if (DebugLvl >= 5)
> ! Debug_print_rewritten = true;
> break;
>
> case 'E':
> --- 1224,1241 ----
> break;
>
> case 'd': /* debug level */
> ! tmp = "true";
> ! SetConfigOption("debug_level", optarg, ctx, true);
> ! if (DebugLvl >= 1)
> ! SetConfigOption("log_connections", tmp, ctx, true);
> if (DebugLvl >= 2)
> ! SetConfigOption("debug_print_query", tmp, ctx, true);
> if (DebugLvl >= 3)
> ! SetConfigOption("debug_print_parse", tmp, ctx, true);
> if (DebugLvl >= 4)
> ! SetConfigOption("debug_print_plan", tmp, ctx, true);
> if (DebugLvl >= 5)
> ! SetConfigOption("debug_print_rewritten", tmp, ctx, true);
> break;
>
> case 'E':
> ***************
> *** 1254,1261 ****
> /*
> * turn off fsync
> */
> ! if (secure)
> ! enableFsync = false;
> break;
>
> case 'f':
> --- 1259,1265 ----
> /*
> * turn off fsync
> */
> ! SetConfigOption("fsync", "false", ctx, true);
> break;
>
> case 'f':
> ***************
> *** 1263,1291 ****
> /*
> * f - forbid generation of certain plans
> */
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! enable_seqscan = false;
> break;
> case 'i': /* indexscan */
> ! enable_indexscan = false;
> break;
> case 't': /* tidscan */
> ! enable_tidscan = false;
> break;
> case 'n': /* nestloop */
> ! enable_nestloop = false;
> break;
> case 'm': /* mergejoin */
> ! enable_mergejoin = false;
> break;
> case 'h': /* hashjoin */
> ! enable_hashjoin = false;
> break;
> default:
> errs++;
> }
> break;
>
> case 'i':
> --- 1267,1298 ----
> /*
> * f - forbid generation of certain plans
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 's': /* seqscan */
> ! tmp = "enable_seqscan";
> break;
> case 'i': /* indexscan */
> ! tmp = "enable_indexscan";
> break;
> case 't': /* tidscan */
> ! tmp = "enable_tidscan";
> break;
> case 'n': /* nestloop */
> ! tmp = "enable_nestloop";
> break;
> case 'm': /* mergejoin */
> ! tmp = "enable_mergejoin";
> break;
> case 'h': /* hashjoin */
> ! tmp = "enable_hashjoin";
> break;
> default:
> errs++;
> }
> + if (tmp)
> + SetConfigOption(tmp, "false", ctx, true);
> break;
>
> case 'i':
> ***************
> *** 1347,1352 ****
> --- 1354,1360 ----
> DBName = strdup(optarg);
> secure = false; /* subsequent switches are NOT
> * secure */
> + ctx = PGC_BACKEND;
> }
> break;
>
> ***************
> *** 1355,1367 ****
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! {
> ! int S;
> !
> ! S = atoi(optarg);
> ! if (S >= 4 * BLCKSZ / 1024)
> ! SortMem = S;
> ! }
> break;
>
> case 's':
> --- 1363,1369 ----
> /*
> * S - amount of sort memory to use in 1k bytes
> */
> ! SetConfigOption("sort_mem", optarg, ctx, true);
> break;
>
> case 's':
> ***************
> *** 1369,1375 ****
> /*
> * s - report usage statistics (timings) after each query
> */
> ! Show_query_stats = 1;
> break;
>
> case 't':
> --- 1371,1377 ----
> /*
> * s - report usage statistics (timings) after each query
> */
> ! SetConfigOption("show_query_stats", "true", ctx, true);
> break;
>
> case 't':
> ***************
> *** 1383,1405 ****
> * caution: -s can not be used together with -t.
> * ----------------
> */
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! Show_parser_stats = 1;
> else if (optarg[1] == 'l')
> ! Show_planner_stats = 1;
> else
> errs++;
> break;
> case 'e':
> ! Show_executor_stats = 1;
> break;
> default:
> errs++;
> break;
> }
> break;
>
> case 'v':
> --- 1385,1410 ----
> * caution: -s can not be used together with -t.
> * ----------------
> */
> + tmp = NULL;
> switch (optarg[0])
> {
> case 'p':
> if (optarg[1] == 'a')
> ! tmp = "show_parser_stats";
> else if (optarg[1] == 'l')
> ! tmp = "show_planner_stats";
> else
> errs++;
> break;
> case 'e':
> ! tmp = "show_parser_stats";
> break;
> default:
> errs++;
> break;
> }
> + if (tmp)
> + SetConfigOption(tmp, "true", ctx, true);
> break;
>
> case 'v':
> ***************
> *** 1463,1471 ****
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! /* all options are allowed if not under postmaster */
> ! SetConfigOption(name, value,
> ! (IsUnderPostmaster) ? PGC_BACKEND : PGC_POSTMASTER, true);
> free(name);
> if (value)
> free(value);
> --- 1468,1474 ----
> elog(ERROR, "-c %s requires argument", optarg);
> }
>
> ! SetConfigOption(name, value, ctx, true);
> free(name);
> if (value)
> free(value);
> Index: src/backend/utils/misc/guc.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
> retrieving revision 1.41
> diff -u -c -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/22 13:57:10
> ***************
> *** 196,202 ****
> {"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
> {"silent_mode", PGC_POSTMASTER, &SilentMode, false, NULL},
>
> ! {"log_connections", PGC_SIGHUP, &Log_connections, false, NULL},
> {"log_timestamp", PGC_SIGHUP, &Log_timestamp, false, NULL},
> {"log_pid", PGC_SIGHUP, &Log_pid, false, NULL},
>
> --- 196,202 ----
> {"fsync", PGC_SIGHUP, &enableFsync, true, NULL},
> {"silent_mode", PGC_POSTMASTER, &SilentMode, 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},
>
> ***************
> *** 276,282 ****
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 1, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
> --- 276,282 ----
> DEF_PGPORT, 1, 65535, NULL, NULL},
>
> {"sort_mem", PGC_USERSET, &SortMem,
> ! 512, 4*BLCKSZ/1024, INT_MAX, NULL, NULL},
>
> {"debug_level", PGC_USERSET, &DebugLvl,
> 0, 0, 16, NULL, NULL},
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026