88 *
99 *
1010 * IDENTIFICATION
11- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.296 2002/09/27 03:34:15 momjian Exp $
11+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.297 2002/09/27 03:59:00 momjian Exp $
1212 *
1313 * NOTES
1414 * this is the "main" module of the postgres backend and
@@ -1136,6 +1136,7 @@ PostgresMain(int argc, char *argv[], const char *username)
11361136const char * DBName = NULL ;
11371137bool secure ;
11381138int errs = 0 ;
1139+ int debug_flag = 0 ;
11391140GucContext ctx ;
11401141GucSource gucsource ;
11411142char * tmp ;
@@ -1250,6 +1251,7 @@ PostgresMain(int argc, char *argv[], const char *username)
12501251
12511252case 'd' :/* debug level */
12521253{
1254+ debug_flag = atoi (optarg );
12531255/* Set server debugging level. */
12541256if (atoi (optarg )!= 0 )
12551257{
@@ -1259,25 +1261,10 @@ PostgresMain(int argc, char *argv[], const char *username)
12591261SetConfigOption ("server_min_messages" ,debugstr ,ctx ,gucsource );
12601262pfree (debugstr );
12611263
1262- /*
1263- * -d is not the same as setting
1264- * client_min_messages because it enables other
1265- * output options.
1266- */
1267- if (atoi (optarg ) >=1 )
1268- SetConfigOption ("log_connections" ,"true" ,ctx ,gucsource );
1269- if (atoi (optarg ) >=2 )
1270- SetConfigOption ("log_statement" ,"true" ,ctx ,gucsource );
1271- if (atoi (optarg ) >=3 )
1272- SetConfigOption ("debug_print_parse" ,"true" ,ctx ,gucsource );
1273- if (atoi (optarg ) >=4 )
1274- SetConfigOption ("debug_print_plan" ,"true" ,ctx ,gucsource );
1275- if (atoi (optarg ) >=5 )
1276- SetConfigOption ("debug_print_rewritten" ,"true" ,ctx ,gucsource );
12771264}
12781265else
12791266/*
1280- * -d 0 allows user to prevent postmaster debug
1267+ * -d0 allows user to prevent postmaster debug
12811268 * from propagating to backend. It would be nice
12821269 * to set it to the postgresql.conf value here.
12831270 */
@@ -1520,6 +1507,22 @@ PostgresMain(int argc, char *argv[], const char *username)
15201507break ;
15211508}
15221509
1510+ /*
1511+ * -d is not the same as setting
1512+ * server_min_messages because it enables other
1513+ * output options.
1514+ */
1515+ if (debug_flag >=1 )
1516+ SetConfigOption ("log_connections" ,"true" ,ctx ,gucsource );
1517+ if (debug_flag >=2 )
1518+ SetConfigOption ("log_statement" ,"true" ,ctx ,gucsource );
1519+ if (debug_flag >=3 )
1520+ SetConfigOption ("debug_print_parse" ,"true" ,ctx ,gucsource );
1521+ if (debug_flag >=4 )
1522+ SetConfigOption ("debug_print_plan" ,"true" ,ctx ,gucsource );
1523+ if (debug_flag >=5 )
1524+ SetConfigOption ("debug_print_rewritten" ,"true" ,ctx ,gucsource );
1525+
15231526/*
15241527 * Post-processing for command line options.
15251528 */
@@ -1698,7 +1701,7 @@ PostgresMain(int argc, char *argv[], const char *username)
16981701if (!IsUnderPostmaster )
16991702{
17001703puts ("\nPOSTGRES backend interactive interface " );
1701- puts ("$Revision: 1.296 $ $Date: 2002/09/27 03:34:15 $\n" );
1704+ puts ("$Revision: 1.297 $ $Date: 2002/09/27 03:59:00 $\n" );
17021705}
17031706
17041707/*