|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.349 2003/07/04 16:41:21 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.350 2003/07/09 06:47:34 momjian Exp $ |
12 | 12 | * |
13 | 13 | * NOTES |
14 | 14 | * this is the "main" module of the postgres backend and |
@@ -1943,7 +1943,7 @@ PostgresMain(int argc, char *argv[], const char *username) |
1943 | 1943 | boolsecure; |
1944 | 1944 | interrs=0; |
1945 | 1945 | intdebug_flag=0; |
1946 | | -GucContextctx; |
| 1946 | +GucContextctx,debug_context; |
1947 | 1947 | GucSourcegucsource; |
1948 | 1948 | char*tmp; |
1949 | 1949 | intfirstchar; |
@@ -2018,7 +2018,7 @@ PostgresMain(int argc, char *argv[], const char *username) |
2018 | 2018 |
|
2019 | 2019 | /* all options are allowed until '-p' */ |
2020 | 2020 | secure= true; |
2021 | | -ctx=PGC_POSTMASTER; |
| 2021 | +ctx=debug_context=PGC_POSTMASTER; |
2022 | 2022 | gucsource=PGC_S_ARGV;/* initial switches came from command line */ |
2023 | 2023 |
|
2024 | 2024 | while ((flag=getopt(argc,argv,"A:B:c:CD:d:Eef:FiNOPo:p:S:st:v:W:x:-:"))!=-1) |
@@ -2055,25 +2055,34 @@ PostgresMain(int argc, char *argv[], const char *username) |
2055 | 2055 |
|
2056 | 2056 | case'd':/* debug level */ |
2057 | 2057 | { |
2058 | | -debug_flag=atoi(optarg); |
2059 | | -/* Set server debugging level. */ |
2060 | | -if (atoi(optarg)!=0) |
| 2058 | +/* |
| 2059 | + *Client option can't decrease debug level. |
| 2060 | + *We have to do the test here because we group priv and client |
| 2061 | + *set GUC calls below, after we know the final debug value. |
| 2062 | + */ |
| 2063 | +if (ctx!=PGC_BACKEND||atoi(optarg)>debug_flag) |
2061 | 2064 | { |
2062 | | -char*debugstr=palloc(strlen("debug")+strlen(optarg)+1); |
2063 | | - |
2064 | | -sprintf(debugstr,"debug%s",optarg); |
2065 | | -SetConfigOption("log_min_messages",debugstr,ctx,gucsource); |
2066 | | -pfree(debugstr); |
2067 | | - |
| 2065 | +debug_flag=atoi(optarg); |
| 2066 | +debug_context=ctx;/* save context for use below */ |
| 2067 | +/* Set server debugging level. */ |
| 2068 | +if (debug_flag!=0) |
| 2069 | +{ |
| 2070 | +char*debugstr=palloc(strlen("debug")+strlen(optarg)+1); |
| 2071 | + |
| 2072 | +sprintf(debugstr,"debug%s",optarg); |
| 2073 | +SetConfigOption("log_min_messages",debugstr,ctx,gucsource); |
| 2074 | +pfree(debugstr); |
| 2075 | + |
| 2076 | +} |
| 2077 | +else |
| 2078 | +/* |
| 2079 | + * -d0 allows user to prevent postmaster debug |
| 2080 | + * from propagating to backend. It would be nice |
| 2081 | + * to set it to the postgresql.conf value here. |
| 2082 | + */ |
| 2083 | +SetConfigOption("log_min_messages","notice", |
| 2084 | +ctx,gucsource); |
2068 | 2085 | } |
2069 | | -else |
2070 | | -/* |
2071 | | - * -d0 allows user to prevent postmaster debug |
2072 | | - * from propagating to backend. It would be nice |
2073 | | - * to set it to the postgresql.conf value here. |
2074 | | - */ |
2075 | | -SetConfigOption("log_min_messages","notice", |
2076 | | -ctx,gucsource); |
2077 | 2086 | } |
2078 | 2087 | break; |
2079 | 2088 |
|
@@ -2323,20 +2332,19 @@ PostgresMain(int argc, char *argv[], const char *username) |
2323 | 2332 |
|
2324 | 2333 |
|
2325 | 2334 | /* |
2326 | | - * -d is not the same as setting |
2327 | | - * log_min_messages because it enables other |
2328 | | - * output options. |
| 2335 | + * -d is not the same as setting log_min_messages because it enables |
| 2336 | + * other output options. |
2329 | 2337 | */ |
2330 | 2338 | if (debug_flag >=1) |
2331 | | -SetConfigOption("log_connections","true",ctx,gucsource); |
| 2339 | +SetConfigOption("log_connections","true",debug_context,gucsource); |
2332 | 2340 | if (debug_flag >=2) |
2333 | | -SetConfigOption("log_statement","true",ctx,gucsource); |
| 2341 | +SetConfigOption("log_statement","true",debug_context,gucsource); |
2334 | 2342 | if (debug_flag >=3) |
2335 | | -SetConfigOption("debug_print_parse","true",ctx,gucsource); |
| 2343 | +SetConfigOption("debug_print_parse","true",debug_context,gucsource); |
2336 | 2344 | if (debug_flag >=4) |
2337 | | -SetConfigOption("debug_print_plan","true",ctx,gucsource); |
| 2345 | +SetConfigOption("debug_print_plan","true",debug_context,gucsource); |
2338 | 2346 | if (debug_flag >=5) |
2339 | | -SetConfigOption("debug_print_rewritten","true",ctx,gucsource); |
| 2347 | +SetConfigOption("debug_print_rewritten","true",debug_context,gucsource); |
2340 | 2348 |
|
2341 | 2349 | /* |
2342 | 2350 | * Process any additional GUC variable settings passed in startup packet. |
@@ -2548,7 +2556,7 @@ PostgresMain(int argc, char *argv[], const char *username) |
2548 | 2556 | if (!IsUnderPostmaster) |
2549 | 2557 | { |
2550 | 2558 | puts("\nPOSTGRES backend interactive interface "); |
2551 | | -puts("$Revision: 1.349 $ $Date: 2003/07/04 16:41:21 $\n"); |
| 2559 | +puts("$Revision: 1.350 $ $Date: 2003/07/09 06:47:34 $\n"); |
2552 | 2560 | } |
2553 | 2561 |
|
2554 | 2562 | /* |
|