88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.220 2001/06/12 22:54:06 tgl Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.221 2001/06/18 23:42:32 momjian Exp $
1212 *
1313 * NOTES
1414 * this is the "main" module of the postgres backend and
@@ -1108,6 +1108,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
11081108const char * DBName = NULL ;
11091109bool secure = true;
11101110int errs = 0 ;
1111+ GucContext ctx ;
1112+ char * tmp ;
11111113
11121114int firstchar ;
11131115StringInfo parser_input ;
@@ -1117,6 +1119,9 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
11171119
11181120char * potential_DataDir = NULL ;
11191121
1122+ /* all options are allowed if not under postmaster */
1123+ ctx = IsUnderPostmaster ?PGC_BACKEND :PGC_POSTMASTER ;
1124+
11201125/*
11211126 * Catch standard options before doing much else. This even works on
11221127 * systems without getopt_long.
@@ -1188,7 +1193,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
11881193{
11891194case 'A' :
11901195#ifdef USE_ASSERT_CHECKING
1191- assert_enabled = atoi ( optarg );
1196+ SetConfigOption ( "debug_assertions" , optarg , ctx , true );
11921197#else
11931198fprintf (stderr ,"Assert checking is not compiled in\n" );
11941199#endif
@@ -1200,7 +1205,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
12001205 * specify the size of buffer pool
12011206 */
12021207if (secure )
1203- NBuffers = atoi ( optarg );
1208+ SetConfigOption ( "shared_buffers" , optarg , ctx , true );
12041209break ;
12051210
12061211case 'C' :
@@ -1217,17 +1222,18 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
12171222break ;
12181223
12191224case 'd' :/* debug level */
1220- DebugLvl = atoi (optarg );
1225+ tmp = "true" ;
1226+ SetConfigOption ("debug_level" ,optarg ,ctx , true);
12211227if (DebugLvl >=1 );
1222- Log_connections = true;
1228+ SetConfigOption ( "log_connections" , tmp , ctx , true) ;
12231229if (DebugLvl >=2 )
1224- Debug_print_query = true;
1230+ SetConfigOption ( "debug_print_query" , tmp , ctx , true) ;
12251231if (DebugLvl >=3 )
1226- Debug_print_parse = true;
1232+ SetConfigOption ( "debug_print_parse" , tmp , ctx , true) ;
12271233if (DebugLvl >=4 )
1228- Debug_print_plan = true;
1234+ SetConfigOption ( "debug_print_plan" , tmp , ctx , true) ;
12291235if (DebugLvl >=5 )
1230- Debug_print_rewritten = true;
1236+ SetConfigOption ( "debug_print_rewritten" , tmp , ctx , true) ;
12311237break ;
12321238
12331239case 'E' :
@@ -1252,37 +1258,40 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
12521258 * turn off fsync
12531259 */
12541260if (secure )
1255- enableFsync = false ;
1261+ SetConfigOption ( "fsync" , "true" , ctx , true) ;
12561262break ;
12571263
12581264case 'f' :
12591265
12601266/*
12611267 * f - forbid generation of certain plans
12621268 */
1269+ tmp = NULL ;
12631270switch (optarg [0 ])
12641271{
12651272case 's' :/* seqscan */
1266- enable_seqscan = false ;
1273+ tmp = "enable_seqscan" ;
12671274break ;
12681275case 'i' :/* indexscan */
1269- enable_indexscan = false ;
1276+ tmp = "enable_indexscan" ;
12701277break ;
12711278case 't' :/* tidscan */
1272- enable_tidscan = false ;
1279+ tmp = "enable_tidscan" ;
12731280break ;
12741281case 'n' :/* nestloop */
1275- enable_nestloop = false ;
1282+ tmp = "enable_nestloop" ;
12761283break ;
12771284case 'm' :/* mergejoin */
1278- enable_mergejoin = false ;
1285+ tmp = "enable_mergejoin" ;
12791286break ;
12801287case 'h' :/* hashjoin */
1281- enable_hashjoin = false ;
1288+ tmp = "enable_hashjoin" ;
12821289break ;
12831290default :
12841291errs ++ ;
12851292}
1293+ if (tmp )
1294+ SetConfigOption (tmp ,"false" ,ctx , true);
12861295break ;
12871296
12881297case 'i' :
@@ -1352,21 +1361,15 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
13521361/*
13531362 * S - amount of sort memory to use in 1k bytes
13541363 */
1355- {
1356- int S ;
1357-
1358- S = atoi (optarg );
1359- if (S >=4 * BLCKSZ /1024 )
1360- SortMem = S ;
1361- }
1364+ SetConfigOption ("sort_mem" ,optarg ,ctx , true);
13621365break ;
13631366
13641367case 's' :
13651368
13661369/*
13671370 * s - report usage statistics (timings) after each query
13681371 */
1369- Show_query_stats = 1 ;
1372+ SetConfigOption ( "show_query_stats" , optarg , ctx , true) ;
13701373break ;
13711374
13721375case 't' :
@@ -1380,23 +1383,26 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
13801383 *caution: -s can not be used together with -t.
13811384 * ----------------
13821385 */
1386+ tmp = NULL ;
13831387switch (optarg [0 ])
13841388{
13851389case 'p' :
13861390if (optarg [1 ]== 'a' )
1387- Show_parser_stats = 1 ;
1391+ tmp = "show_parser_stats" ;
13881392else if (optarg [1 ]== 'l' )
1389- Show_planner_stats = 1 ;
1393+ tmp = "show_planner_stats" ;
13901394else
13911395errs ++ ;
13921396break ;
13931397case 'e' :
1394- Show_executor_stats = 1 ;
1398+ tmp = "show_parser_stats" ;
13951399break ;
13961400default :
13971401errs ++ ;
13981402break ;
13991403}
1404+ if (tmp )
1405+ SetConfigOption (tmp ,"true" ,ctx , true);
14001406break ;
14011407
14021408case 'v' :
@@ -1460,9 +1466,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
14601466elog (ERROR ,"-c %s requires argument" ,optarg );
14611467}
14621468
1463- /* all options are allowed if not under postmaster */
1464- SetConfigOption (name ,value ,
1465- (IsUnderPostmaster ) ?PGC_BACKEND :PGC_POSTMASTER , true);
1469+ SetConfigOption (name ,value ,ctx , true);
14661470free (name );
14671471if (value )
14681472free (value );
@@ -1709,7 +1713,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
17091713if (!IsUnderPostmaster )
17101714{
17111715puts ("\nPOSTGRES backend interactive interface " );
1712- puts ("$Revision: 1.220 $ $Date: 2001/06/12 22:54:06 $\n" );
1716+ puts ("$Revision: 1.221 $ $Date: 2001/06/18 23:42:32 $\n" );
17131717}
17141718
17151719/*