8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.224 2001/06/22 19:16:23 wieck Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.225 2001/06/23 22:23:49 momjian Exp $
12
12
*
13
13
* NOTES
14
14
* this is the "main" module of the postgres backend and
@@ -1110,6 +1110,8 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1110
1110
const char * DBName = NULL ;
1111
1111
bool secure = true;
1112
1112
int errs = 0 ;
1113
+ GucContext ctx ;
1114
+ char * tmp ;
1113
1115
1114
1116
int firstchar ;
1115
1117
StringInfo parser_input ;
@@ -1119,6 +1121,9 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1119
1121
1120
1122
char * potential_DataDir = NULL ;
1121
1123
1124
+ /* all options are allowed until '-p' */
1125
+ ctx = PGC_POSTMASTER ;
1126
+
1122
1127
/*
1123
1128
* Catch standard options before doing much else. This even works on
1124
1129
* systems without getopt_long.
@@ -1192,7 +1197,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1192
1197
{
1193
1198
case 'A' :
1194
1199
#ifdef USE_ASSERT_CHECKING
1195
- assert_enabled = atoi ( optarg );
1200
+ SetConfigOption ( "debug_assertions" , optarg , ctx , true );
1196
1201
#else
1197
1202
fprintf (stderr , "Assert checking is not compiled in\n" );
1198
1203
#endif
@@ -1203,8 +1208,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1203
1208
/*
1204
1209
* specify the size of buffer pool
1205
1210
*/
1206
- if (secure )
1207
- NBuffers = atoi (optarg );
1211
+ SetConfigOption ("shared_buffers" , optarg , ctx , true);
1208
1212
break ;
1209
1213
1210
1214
case 'C' :
@@ -1221,17 +1225,18 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1221
1225
break ;
1222
1226
1223
1227
case 'd' : /* debug level */
1224
- DebugLvl = atoi (optarg );
1225
- if (DebugLvl >= 1 );
1226
- Log_connections = true;
1228
+ tmp = "true" ;
1229
+ SetConfigOption ("debug_level" , optarg , ctx , true);
1230
+ if (DebugLvl >= 1 )
1231
+ SetConfigOption ("log_connections" , tmp , ctx , true);
1227
1232
if (DebugLvl >= 2 )
1228
- Debug_print_query = true;
1233
+ SetConfigOption ( "debug_print_query" , tmp , ctx , true) ;
1229
1234
if (DebugLvl >= 3 )
1230
- Debug_print_parse = true;
1235
+ SetConfigOption ( "debug_print_parse" , tmp , ctx , true) ;
1231
1236
if (DebugLvl >= 4 )
1232
- Debug_print_plan = true;
1237
+ SetConfigOption ( "debug_print_plan" , tmp , ctx , true) ;
1233
1238
if (DebugLvl >= 5 )
1234
- Debug_print_rewritten = true;
1239
+ SetConfigOption ( "debug_print_rewritten" , tmp , ctx , true) ;
1235
1240
break ;
1236
1241
1237
1242
case 'E' :
@@ -1255,38 +1260,40 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1255
1260
/*
1256
1261
* turn off fsync
1257
1262
*/
1258
- if (secure )
1259
- enableFsync = false;
1263
+ SetConfigOption ("fsync" , "false" , ctx , true);
1260
1264
break ;
1261
1265
1262
1266
case 'f' :
1263
1267
1264
1268
/*
1265
1269
* f - forbid generation of certain plans
1266
1270
*/
1271
+ tmp = NULL ;
1267
1272
switch (optarg [0 ])
1268
1273
{
1269
1274
case 's' : /* seqscan */
1270
- enable_seqscan = false ;
1275
+ tmp = "enable_seqscan" ;
1271
1276
break ;
1272
1277
case 'i' : /* indexscan */
1273
- enable_indexscan = false ;
1278
+ tmp = "enable_indexscan" ;
1274
1279
break ;
1275
1280
case 't' : /* tidscan */
1276
- enable_tidscan = false ;
1281
+ tmp = "enable_tidscan" ;
1277
1282
break ;
1278
1283
case 'n' : /* nestloop */
1279
- enable_nestloop = false ;
1284
+ tmp = "enable_nestloop" ;
1280
1285
break ;
1281
1286
case 'm' : /* mergejoin */
1282
- enable_mergejoin = false ;
1287
+ tmp = "enable_mergejoin" ;
1283
1288
break ;
1284
1289
case 'h' : /* hashjoin */
1285
- enable_hashjoin = false ;
1290
+ tmp = "enable_hashjoin" ;
1286
1291
break ;
1287
1292
default :
1288
1293
errs ++ ;
1289
1294
}
1295
+ if (tmp )
1296
+ SetConfigOption (tmp , "false" , ctx , true);
1290
1297
break ;
1291
1298
1292
1299
case 'i' :
@@ -1348,6 +1355,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1348
1355
DBName = strdup (optarg );
1349
1356
secure = false; /* subsequent switches are NOT
1350
1357
* secure */
1358
+ ctx = PGC_BACKEND ;
1351
1359
}
1352
1360
break ;
1353
1361
@@ -1356,21 +1364,15 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1356
1364
/*
1357
1365
* S - amount of sort memory to use in 1k bytes
1358
1366
*/
1359
- {
1360
- int S ;
1361
-
1362
- S = atoi (optarg );
1363
- if (S >= 4 * BLCKSZ / 1024 )
1364
- SortMem = S ;
1365
- }
1367
+ SetConfigOption ("sort_mem" , optarg , ctx , true);
1366
1368
break ;
1367
1369
1368
1370
case 's' :
1369
1371
1370
1372
/*
1371
1373
* s - report usage statistics (timings) after each query
1372
1374
*/
1373
- Show_query_stats = 1 ;
1375
+ SetConfigOption ( "show_query_stats" , "true" , ctx , true) ;
1374
1376
break ;
1375
1377
1376
1378
case 't' :
@@ -1384,23 +1386,26 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1384
1386
* caution: -s can not be used together with -t.
1385
1387
* ----------------
1386
1388
*/
1389
+ tmp = NULL ;
1387
1390
switch (optarg [0 ])
1388
1391
{
1389
1392
case 'p' :
1390
1393
if (optarg [1 ] == 'a' )
1391
- Show_parser_stats = 1 ;
1394
+ tmp = "show_parser_stats" ;
1392
1395
else if (optarg [1 ] == 'l' )
1393
- Show_planner_stats = 1 ;
1396
+ tmp = "show_planner_stats" ;
1394
1397
else
1395
1398
errs ++ ;
1396
1399
break ;
1397
1400
case 'e' :
1398
- Show_executor_stats = 1 ;
1401
+ tmp = "show_parser_stats" ;
1399
1402
break ;
1400
1403
default :
1401
1404
errs ++ ;
1402
1405
break ;
1403
1406
}
1407
+ if (tmp )
1408
+ SetConfigOption (tmp , "true" , ctx , true);
1404
1409
break ;
1405
1410
1406
1411
case 'v' :
@@ -1464,9 +1469,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1464
1469
elog (ERROR , "-c %s requires argument" , optarg );
1465
1470
}
1466
1471
1467
- /* all options are allowed if not under postmaster */
1468
- SetConfigOption (name , value ,
1469
- (IsUnderPostmaster ) ? PGC_BACKEND : PGC_POSTMASTER , true);
1472
+ SetConfigOption (name , value , ctx , true);
1470
1473
free (name );
1471
1474
if (value )
1472
1475
free (value );
@@ -1711,7 +1714,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
1711
1714
if (!IsUnderPostmaster )
1712
1715
{
1713
1716
puts ("\nPOSTGRES backend interactive interface " );
1714
- puts ("$Revision: 1.224 $ $Date: 2001/06/22 19:16:23 $\n" );
1717
+ puts ("$Revision: 1.225 $ $Date: 2001/06/23 22:23:49 $\n" );
1715
1718
}
1716
1719
1717
1720
/*
0 commit comments