From 5057010944246c392b5dbbf465b69e6affe273d1 Mon Sep 17 00:00:00 2001 From: Jan Wieck Date: Tue, 11 May 1999 09:06:35 +0000 Subject: [PATCH] Changed debug options: -d4 now prints compressed trees from nodeToString() -d5 prints pretty trees via nodeDisplay() new pg_options: pretty_plan, pretty_parse, pretty_rewritten Jan --- src/backend/tcop/postgres.c | 72 +++++++++++++++++++++++++--------- src/backend/utils/misc/trace.c | 3 ++ src/include/utils/trace.h | 3 ++ 3 files changed, 59 insertions(+), 19 deletions(-) diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 24b2303ee9..0a1a45b4db 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.111 1999/05/09 23:31:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.112 1999/05/11 09:06:31 wieck Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -103,11 +103,15 @@ #define DebugPrintQuery pg_options[TRACE_QUERY] #define DebugPrintPlan pg_options[TRACE_PLAN] #define DebugPrintParse pg_options[TRACE_PARSE] +#define DebugPrintRewrittenParsetree \ + pg_options[TRACE_REWRITTEN] +#define DebugPPrintPlan pg_options[TRACE_PRETTY_PLAN] +#define DebugPPrintParse pg_options[TRACE_PRETTY_PARSE] +#define DebugPPrintRewrittenParsetree \ + pg_options[TRACE_PRETTY_REWRITTEN] #define ShowParserStats pg_options[TRACE_PARSERSTATS] #define ShowPlannerStats pg_options[TRACE_PLANNERSTATS] #define ShowExecutorStats pg_options[TRACE_EXECUTORSTATS] -#define DebugPrintRewrittenParsetree \ - pg_options[TRACE_REWRITTEN] #ifdef LOCK_MGR_DEBUG #define LockDebug pg_options[TRACE_LOCKS] #endif @@ -474,10 +478,15 @@ pg_parse_and_plan(char *query_string, /* string to execute */ { querytree = querytree_list->qtrees[i]; - if (DebugPrintParse) + if (DebugPrintParse || DebugPPrintParse) { - TPRINTF(TRACE_PARSE, "parser outputs:"); - nodeDisplay(querytree); + if (DebugPPrintParse) { + TPRINTF(TRACE_PRETTY_PARSE, "parser outputs:"); + nodeDisplay(querytree); + } else { + TPRINTF(TRACE_PARSE, "parser outputs:"); + printf("\n%s\n\n", nodeToString(querytree)); + } } /* don't rewrite utilites, just dump 'em into new_list */ @@ -545,14 +554,23 @@ pg_parse_and_plan(char *query_string, /* string to execute */ } } - if (DebugPrintRewrittenParsetree) + if (DebugPrintRewrittenParsetree || DebugPPrintRewrittenParsetree) { - TPRINTF(TRACE_REWRITTEN, "after rewriting:"); + if (DebugPPrintRewrittenParsetree) { + TPRINTF(TRACE_PRETTY_REWRITTEN, "after rewriting:"); - for (i = 0; i < querytree_list->len; i++) - { - nodeDisplay(querytree_list->qtrees[i]); - printf("\n"); + for (i = 0; i < querytree_list->len; i++) + { + nodeDisplay(querytree_list->qtrees[i]); + printf("\n"); + } + } else { + TPRINTF(TRACE_REWRITTEN, "after rewriting:"); + + for (i = 0; i < querytree_list->len; i++) + { + printf("\n%s\n\n", nodeToString(querytree_list->qtrees[i])); + } } } @@ -608,10 +626,15 @@ pg_parse_and_plan(char *query_string, /* string to execute */ * also for queries in functions. DZ - 27-8-1996 * ---------------- */ - if (DebugPrintPlan) + if (DebugPrintPlan || DebugPPrintPlan) { - TPRINTF(TRACE_PLAN, "plan:"); - nodeDisplay(plan); + if (DebugPPrintPlan) { + TPRINTF(TRACE_PRETTY_PLAN, "plan:"); + nodeDisplay(plan); + } else { + TPRINTF(TRACE_PLAN, "plan:"); + printf("\n%s\n\n", nodeToString(plan)); + } } #endif } @@ -747,10 +770,15 @@ pg_exec_query_dest(char *query_string, /* string to execute */ * print plan if debugging * ---------------- */ - if (DebugPrintPlan) + if (DebugPrintPlan || DebugPPrintPlan) { - TPRINTF(TRACE_PLAN, "plan:"); - nodeDisplay(plan); + if (DebugPPrintPlan) { + TPRINTF(TRACE_PRETTY_PLAN, "plan:"); + nodeDisplay(plan); + } else { + TPRINTF(TRACE_PLAN, "plan:"); + printf("\n%s\n\n", nodeToString(plan)); + } } #endif @@ -1047,6 +1075,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) DebugPrintPlan = true; DebugPrintRewrittenParsetree = true; } + if (DebugLvl >= 5) + { + DebugPPrintParse = true; + DebugPPrintPlan = true; + DebugPPrintRewrittenParsetree = true; + } break; case 'E': @@ -1510,7 +1544,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[]) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.111 $ $Date: 1999/05/09 23:31:47 $\n"); + puts("$Revision: 1.112 $ $Date: 1999/05/11 09:06:31 $\n"); } /* ---------------- diff --git a/src/backend/utils/misc/trace.c b/src/backend/utils/misc/trace.c index 51070ba7ca..1f96065c9e 100644 --- a/src/backend/utils/misc/trace.c +++ b/src/backend/utils/misc/trace.c @@ -53,6 +53,9 @@ static char *opt_names[] = { "plan", "parse", "rewritten", + "pretty_plan", + "pretty_parse", + "pretty_rewritten", "parserstats", "plannerstats", "executorstats", diff --git a/src/include/utils/trace.h b/src/include/utils/trace.h index 52bc301a0a..4695e865aa 100644 --- a/src/include/utils/trace.h +++ b/src/include/utils/trace.h @@ -49,6 +49,9 @@ enum pg_option_enum TRACE_PLAN, TRACE_PARSE, TRACE_REWRITTEN, + TRACE_PRETTY_PLAN, /* indented multiline versions of trees */ + TRACE_PRETTY_PARSE, + TRACE_PRETTY_REWRITTEN, TRACE_PARSERSTATS, TRACE_PLANNERSTATS, TRACE_EXECUTORSTATS, -- 2.40.0