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
This commit is contained in:
Jan Wieck 1999-05-11 09:06:35 +00:00
parent 1ba362f567
commit 5057010944
3 changed files with 59 additions and 19 deletions

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
@ -103,11 +103,15 @@
#define DebugPrintQuery pg_options[TRACE_QUERY] #define DebugPrintQuery pg_options[TRACE_QUERY]
#define DebugPrintPlan pg_options[TRACE_PLAN] #define DebugPrintPlan pg_options[TRACE_PLAN]
#define DebugPrintParse pg_options[TRACE_PARSE] #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 ShowParserStats pg_options[TRACE_PARSERSTATS]
#define ShowPlannerStats pg_options[TRACE_PLANNERSTATS] #define ShowPlannerStats pg_options[TRACE_PLANNERSTATS]
#define ShowExecutorStats pg_options[TRACE_EXECUTORSTATS] #define ShowExecutorStats pg_options[TRACE_EXECUTORSTATS]
#define DebugPrintRewrittenParsetree \
pg_options[TRACE_REWRITTEN]
#ifdef LOCK_MGR_DEBUG #ifdef LOCK_MGR_DEBUG
#define LockDebug pg_options[TRACE_LOCKS] #define LockDebug pg_options[TRACE_LOCKS]
#endif #endif
@ -474,10 +478,15 @@ pg_parse_and_plan(char *query_string, /* string to execute */
{ {
querytree = querytree_list->qtrees[i]; querytree = querytree_list->qtrees[i];
if (DebugPrintParse) if (DebugPrintParse || DebugPPrintParse)
{ {
TPRINTF(TRACE_PARSE, "parser outputs:"); if (DebugPPrintParse) {
nodeDisplay(querytree); 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 */ /* 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++) for (i = 0; i < querytree_list->len; i++)
{ {
nodeDisplay(querytree_list->qtrees[i]); nodeDisplay(querytree_list->qtrees[i]);
printf("\n"); 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 * also for queries in functions. DZ - 27-8-1996
* ---------------- * ----------------
*/ */
if (DebugPrintPlan) if (DebugPrintPlan || DebugPPrintPlan)
{ {
TPRINTF(TRACE_PLAN, "plan:"); if (DebugPPrintPlan) {
nodeDisplay(plan); TPRINTF(TRACE_PRETTY_PLAN, "plan:");
nodeDisplay(plan);
} else {
TPRINTF(TRACE_PLAN, "plan:");
printf("\n%s\n\n", nodeToString(plan));
}
} }
#endif #endif
} }
@ -747,10 +770,15 @@ pg_exec_query_dest(char *query_string, /* string to execute */
* print plan if debugging * print plan if debugging
* ---------------- * ----------------
*/ */
if (DebugPrintPlan) if (DebugPrintPlan || DebugPPrintPlan)
{ {
TPRINTF(TRACE_PLAN, "plan:"); if (DebugPPrintPlan) {
nodeDisplay(plan); TPRINTF(TRACE_PRETTY_PLAN, "plan:");
nodeDisplay(plan);
} else {
TPRINTF(TRACE_PLAN, "plan:");
printf("\n%s\n\n", nodeToString(plan));
}
} }
#endif #endif
@ -1047,6 +1075,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
DebugPrintPlan = true; DebugPrintPlan = true;
DebugPrintRewrittenParsetree = true; DebugPrintRewrittenParsetree = true;
} }
if (DebugLvl >= 5)
{
DebugPPrintParse = true;
DebugPPrintPlan = true;
DebugPPrintRewrittenParsetree = true;
}
break; break;
case 'E': case 'E':
@ -1510,7 +1544,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster) if (!IsUnderPostmaster)
{ {
puts("\nPOSTGRES backend interactive interface "); 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");
} }
/* ---------------- /* ----------------

View File

@ -53,6 +53,9 @@ static char *opt_names[] = {
"plan", "plan",
"parse", "parse",
"rewritten", "rewritten",
"pretty_plan",
"pretty_parse",
"pretty_rewritten",
"parserstats", "parserstats",
"plannerstats", "plannerstats",
"executorstats", "executorstats",

View File

@ -49,6 +49,9 @@ enum pg_option_enum
TRACE_PLAN, TRACE_PLAN,
TRACE_PARSE, TRACE_PARSE,
TRACE_REWRITTEN, TRACE_REWRITTEN,
TRACE_PRETTY_PLAN, /* indented multiline versions of trees */
TRACE_PRETTY_PARSE,
TRACE_PRETTY_REWRITTEN,
TRACE_PARSERSTATS, TRACE_PARSERSTATS,
TRACE_PLANNERSTATS, TRACE_PLANNERSTATS,
TRACE_EXECUTORSTATS, TRACE_EXECUTORSTATS,