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

From Bruce Momjian
Subject Re: use GUC for cmdline
Date
Msg-id 200106232221.f5NMLDY11939@candle.pha.pa.us
Whole thread Raw
In response to Re: use GUC for cmdline  (Marko Kreen <marko@l-t.ee>)
List pgsql-patches
Patch applied.  Thanks.


> On Fri, Jun 22, 2001 at 09:18:55AM -0400, Tom Lane wrote:
> > Marko Kreen <marko@l-t.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@postgresql.org so that your
> message can get through to the mailing list cleanly
>

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

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: use GUC for cmdline
Next
From: Bruce Momjian
Date:
Subject: Bytea binary compatible