8
8
*
9
9
*
10
10
* 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 $
12
12
*
13
13
* NOTES
14
14
* 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
1108
1108
const char * DBName = NULL ;
1109
1109
bool secure = true;
1110
1110
int errs = 0 ;
1111
+ GucContext ctx ;
1112
+ char * tmp ;
1111
1113
1112
1114
int firstchar ;
1113
1115
StringInfo parser_input ;
@@ -1117,6 +1119,9 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1117
1119
1118
1120
char * potential_DataDir = NULL ;
1119
1121
1122
+ /* all options are allowed if not under postmaster */
1123
+ ctx = IsUnderPostmaster ? PGC_BACKEND : PGC_POSTMASTER ;
1124
+
1120
1125
/*
1121
1126
* Catch standard options before doing much else. This even works on
1122
1127
* systems without getopt_long.
@@ -1188,7 +1193,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1188
1193
{
1189
1194
case 'A' :
1190
1195
#ifdef USE_ASSERT_CHECKING
1191
- assert_enabled = atoi ( optarg );
1196
+ SetConfigOption ( "debug_assertions" , optarg , ctx , true );
1192
1197
#else
1193
1198
fprintf (stderr , "Assert checking is not compiled in\n" );
1194
1199
#endif
@@ -1200,7 +1205,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1200
1205
* specify the size of buffer pool
1201
1206
*/
1202
1207
if (secure )
1203
- NBuffers = atoi ( optarg );
1208
+ SetConfigOption ( "shared_buffers" , optarg , ctx , true );
1204
1209
break ;
1205
1210
1206
1211
case 'C' :
@@ -1217,17 +1222,18 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1217
1222
break ;
1218
1223
1219
1224
case 'd' : /* debug level */
1220
- DebugLvl = atoi (optarg );
1225
+ tmp = "true" ;
1226
+ SetConfigOption ("debug_level" , optarg , ctx , true);
1221
1227
if (DebugLvl >= 1 );
1222
- Log_connections = true;
1228
+ SetConfigOption ( "log_connections" , tmp , ctx , true) ;
1223
1229
if (DebugLvl >= 2 )
1224
- Debug_print_query = true;
1230
+ SetConfigOption ( "debug_print_query" , tmp , ctx , true) ;
1225
1231
if (DebugLvl >= 3 )
1226
- Debug_print_parse = true;
1232
+ SetConfigOption ( "debug_print_parse" , tmp , ctx , true) ;
1227
1233
if (DebugLvl >= 4 )
1228
- Debug_print_plan = true;
1234
+ SetConfigOption ( "debug_print_plan" , tmp , ctx , true) ;
1229
1235
if (DebugLvl >= 5 )
1230
- Debug_print_rewritten = true;
1236
+ SetConfigOption ( "debug_print_rewritten" , tmp , ctx , true) ;
1231
1237
break ;
1232
1238
1233
1239
case 'E' :
@@ -1252,37 +1258,40 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1252
1258
* turn off fsync
1253
1259
*/
1254
1260
if (secure )
1255
- enableFsync = false ;
1261
+ SetConfigOption ( "fsync" , "true" , ctx , true) ;
1256
1262
break ;
1257
1263
1258
1264
case 'f' :
1259
1265
1260
1266
/*
1261
1267
* f - forbid generation of certain plans
1262
1268
*/
1269
+ tmp = NULL ;
1263
1270
switch (optarg [0 ])
1264
1271
{
1265
1272
case 's' : /* seqscan */
1266
- enable_seqscan = false ;
1273
+ tmp = "enable_seqscan" ;
1267
1274
break ;
1268
1275
case 'i' : /* indexscan */
1269
- enable_indexscan = false ;
1276
+ tmp = "enable_indexscan" ;
1270
1277
break ;
1271
1278
case 't' : /* tidscan */
1272
- enable_tidscan = false ;
1279
+ tmp = "enable_tidscan" ;
1273
1280
break ;
1274
1281
case 'n' : /* nestloop */
1275
- enable_nestloop = false ;
1282
+ tmp = "enable_nestloop" ;
1276
1283
break ;
1277
1284
case 'm' : /* mergejoin */
1278
- enable_mergejoin = false ;
1285
+ tmp = "enable_mergejoin" ;
1279
1286
break ;
1280
1287
case 'h' : /* hashjoin */
1281
- enable_hashjoin = false ;
1288
+ tmp = "enable_hashjoin" ;
1282
1289
break ;
1283
1290
default :
1284
1291
errs ++ ;
1285
1292
}
1293
+ if (tmp )
1294
+ SetConfigOption (tmp , "false" , ctx , true);
1286
1295
break ;
1287
1296
1288
1297
case 'i' :
@@ -1352,21 +1361,15 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1352
1361
/*
1353
1362
* S - amount of sort memory to use in 1k bytes
1354
1363
*/
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);
1362
1365
break ;
1363
1366
1364
1367
case 's' :
1365
1368
1366
1369
/*
1367
1370
* s - report usage statistics (timings) after each query
1368
1371
*/
1369
- Show_query_stats = 1 ;
1372
+ SetConfigOption ( "show_query_stats" , optarg , ctx , true) ;
1370
1373
break ;
1371
1374
1372
1375
case 't' :
@@ -1380,23 +1383,26 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1380
1383
* caution: -s can not be used together with -t.
1381
1384
* ----------------
1382
1385
*/
1386
+ tmp = NULL ;
1383
1387
switch (optarg [0 ])
1384
1388
{
1385
1389
case 'p' :
1386
1390
if (optarg [1 ] == 'a' )
1387
- Show_parser_stats = 1 ;
1391
+ tmp = "show_parser_stats" ;
1388
1392
else if (optarg [1 ] == 'l' )
1389
- Show_planner_stats = 1 ;
1393
+ tmp = "show_planner_stats" ;
1390
1394
else
1391
1395
errs ++ ;
1392
1396
break ;
1393
1397
case 'e' :
1394
- Show_executor_stats = 1 ;
1398
+ tmp = "show_parser_stats" ;
1395
1399
break ;
1396
1400
default :
1397
1401
errs ++ ;
1398
1402
break ;
1399
1403
}
1404
+ if (tmp )
1405
+ SetConfigOption (tmp , "true" , ctx , true);
1400
1406
break ;
1401
1407
1402
1408
case 'v' :
@@ -1460,9 +1466,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1460
1466
elog (ERROR , "-c %s requires argument" , optarg );
1461
1467
}
1462
1468
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);
1466
1470
free (name );
1467
1471
if (value )
1468
1472
free (value );
@@ -1709,7 +1713,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1709
1713
if (!IsUnderPostmaster )
1710
1714
{
1711
1715
puts ("\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" );
1713
1717
}
1714
1718
1715
1719
/*
0 commit comments