Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/tcop/postgres.c,v
retrieving revision 1.296
diff -c -c -r1.296 postgres.c
*** src/backend/tcop/postgres.c	27 Sep 2002 03:34:15 -0000	1.296
--- src/backend/tcop/postgres.c	27 Sep 2002 03:49:34 -0000
***************
*** 1136,1141 ****
--- 1136,1142 ----
  	const char *DBName = NULL;
  	bool		secure;
  	int			errs = 0;
+ 	int			debug_flag = 0;
  	GucContext	ctx;
  	GucSource	gucsource;
  	char	   *tmp;
***************
*** 1250,1255 ****
--- 1251,1257 ----
  
  			case 'd':			/* debug level */
  				{
+ 					debug_flag = atoi(optarg);
  					/* Set server debugging level. */
  					if (atoi(optarg) != 0)
  					{
***************
*** 1259,1283 ****
  						SetConfigOption("server_min_messages", debugstr, ctx, gucsource);
  						pfree(debugstr);
  
- 						/*
- 						 * -d is not the same as setting
- 						 * client_min_messages because it enables other
- 						 * output options.
- 						 */
- 						if (atoi(optarg) >= 1)
- 							SetConfigOption("log_connections", "true", ctx, gucsource);
- 						if (atoi(optarg) >= 2)
- 							SetConfigOption("log_statement", "true", ctx, gucsource);
- 						if (atoi(optarg) >= 3)
- 							SetConfigOption("debug_print_parse", "true", ctx, gucsource);
- 						if (atoi(optarg) >= 4)
- 							SetConfigOption("debug_print_plan", "true", ctx, gucsource);
- 						if (atoi(optarg) >= 5)
- 							SetConfigOption("debug_print_rewritten", "true", ctx, gucsource);
  					}
  					else
  						/*
! 						 * -d 0 allows user to prevent postmaster debug
  						 * from propagating to backend.  It would be nice
  						 * to set it to the postgresql.conf value here.
  						 */
--- 1261,1270 ----
  						SetConfigOption("server_min_messages", debugstr, ctx, gucsource);
  						pfree(debugstr);
  
  					}
  					else
  						/*
! 						 * -d0 allows user to prevent postmaster debug
  						 * from propagating to backend.  It would be nice
  						 * to set it to the postgresql.conf value here.
  						 */
***************
*** 1519,1524 ****
--- 1506,1527 ----
  				errs++;
  				break;
  		}
+ 
+ 	/*
+ 	 * -d is not the same as setting
+ 	 * server_min_messages because it enables other
+ 	 * output options.
+ 	 */
+ 	if (debug_flag >= 1)
+ 		SetConfigOption("log_connections", "true", ctx, gucsource);
+ 	if (debug_flag >= 2)
+ 		SetConfigOption("log_statement", "true", ctx, gucsource);
+ 	if (debug_flag >= 3)
+ 		SetConfigOption("debug_print_parse", "true", ctx, gucsource);
+ 	if (debug_flag >= 4)
+ 		SetConfigOption("debug_print_plan", "true", ctx, gucsource);
+ 	if (debug_flag >= 5)
+ 		SetConfigOption("debug_print_rewritten", "true", ctx, gucsource);
  
  	/*
  	 * Post-processing for command line options.
