Skip to content

Commit 5057010

Browse files
Jan WieckJan Wieck
authored andcommitted
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
1 parent 1ba362f commit 5057010

File tree

3 files changed

+59
-19
lines changed

3 files changed

+59
-19
lines changed

src/backend/tcop/postgres.c

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.111 1999/05/09 23:31:47 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.112 1999/05/11 09:06:31 wieck Exp $
1111
*
1212
* NOTES
1313
* this is the "main" module of the postgres backend and
@@ -103,11 +103,15 @@
103103
#define DebugPrintQuery pg_options[TRACE_QUERY]
104104
#define DebugPrintPlan pg_options[TRACE_PLAN]
105105
#define DebugPrintParse pg_options[TRACE_PARSE]
106+
#define DebugPrintRewrittenParsetree \
107+
pg_options[TRACE_REWRITTEN]
108+
#define DebugPPrintPlan pg_options[TRACE_PRETTY_PLAN]
109+
#define DebugPPrintParse pg_options[TRACE_PRETTY_PARSE]
110+
#define DebugPPrintRewrittenParsetree \
111+
pg_options[TRACE_PRETTY_REWRITTEN]
106112
#define ShowParserStats pg_options[TRACE_PARSERSTATS]
107113
#define ShowPlannerStats pg_options[TRACE_PLANNERSTATS]
108114
#define ShowExecutorStats pg_options[TRACE_EXECUTORSTATS]
109-
#define DebugPrintRewrittenParsetree \
110-
pg_options[TRACE_REWRITTEN]
111115
#ifdef LOCK_MGR_DEBUG
112116
#define LockDebug pg_options[TRACE_LOCKS]
113117
#endif
@@ -474,10 +478,15 @@ pg_parse_and_plan(char *query_string, /* string to execute */
474478
{
475479
querytree = querytree_list->qtrees[i];
476480

477-
if (DebugPrintParse)
481+
if (DebugPrintParse || DebugPPrintParse)
478482
{
479-
TPRINTF(TRACE_PARSE, "parser outputs:");
480-
nodeDisplay(querytree);
483+
if (DebugPPrintParse) {
484+
TPRINTF(TRACE_PRETTY_PARSE, "parser outputs:");
485+
nodeDisplay(querytree);
486+
} else {
487+
TPRINTF(TRACE_PARSE, "parser outputs:");
488+
printf("\n%s\n\n", nodeToString(querytree));
489+
}
481490
}
482491

483492
/* don't rewrite utilites, just dump 'em into new_list */
@@ -545,14 +554,23 @@ pg_parse_and_plan(char *query_string, /* string to execute */
545554
}
546555
}
547556

548-
if (DebugPrintRewrittenParsetree)
557+
if (DebugPrintRewrittenParsetree || DebugPPrintRewrittenParsetree)
549558
{
550-
TPRINTF(TRACE_REWRITTEN, "after rewriting:");
559+
if (DebugPPrintRewrittenParsetree) {
560+
TPRINTF(TRACE_PRETTY_REWRITTEN, "after rewriting:");
551561

552-
for (i = 0; i < querytree_list->len; i++)
553-
{
554-
nodeDisplay(querytree_list->qtrees[i]);
555-
printf("\n");
562+
for (i = 0; i < querytree_list->len; i++)
563+
{
564+
nodeDisplay(querytree_list->qtrees[i]);
565+
printf("\n");
566+
}
567+
} else {
568+
TPRINTF(TRACE_REWRITTEN, "after rewriting:");
569+
570+
for (i = 0; i < querytree_list->len; i++)
571+
{
572+
printf("\n%s\n\n", nodeToString(querytree_list->qtrees[i]));
573+
}
556574
}
557575
}
558576

@@ -608,10 +626,15 @@ pg_parse_and_plan(char *query_string, /* string to execute */
608626
* also for queries in functions. DZ - 27-8-1996
609627
* ----------------
610628
*/
611-
if (DebugPrintPlan)
629+
if (DebugPrintPlan || DebugPPrintPlan)
612630
{
613-
TPRINTF(TRACE_PLAN, "plan:");
614-
nodeDisplay(plan);
631+
if (DebugPPrintPlan) {
632+
TPRINTF(TRACE_PRETTY_PLAN, "plan:");
633+
nodeDisplay(plan);
634+
} else {
635+
TPRINTF(TRACE_PLAN, "plan:");
636+
printf("\n%s\n\n", nodeToString(plan));
637+
}
615638
}
616639
#endif
617640
}
@@ -747,10 +770,15 @@ pg_exec_query_dest(char *query_string, /* string to execute */
747770
* print plan if debugging
748771
* ----------------
749772
*/
750-
if (DebugPrintPlan)
773+
if (DebugPrintPlan || DebugPPrintPlan)
751774
{
752-
TPRINTF(TRACE_PLAN, "plan:");
753-
nodeDisplay(plan);
775+
if (DebugPPrintPlan) {
776+
TPRINTF(TRACE_PRETTY_PLAN, "plan:");
777+
nodeDisplay(plan);
778+
} else {
779+
TPRINTF(TRACE_PLAN, "plan:");
780+
printf("\n%s\n\n", nodeToString(plan));
781+
}
754782
}
755783
#endif
756784

@@ -1047,6 +1075,12 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
10471075
DebugPrintPlan = true;
10481076
DebugPrintRewrittenParsetree = true;
10491077
}
1078+
if (DebugLvl >= 5)
1079+
{
1080+
DebugPPrintParse = true;
1081+
DebugPPrintPlan = true;
1082+
DebugPPrintRewrittenParsetree = true;
1083+
}
10501084
break;
10511085

10521086
case 'E':
@@ -1510,7 +1544,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15101544
if (!IsUnderPostmaster)
15111545
{
15121546
puts("\nPOSTGRES backend interactive interface ");
1513-
puts("$Revision: 1.111 $ $Date: 1999/05/09 23:31:47 $\n");
1547+
puts("$Revision: 1.112 $ $Date: 1999/05/11 09:06:31 $\n");
15141548
}
15151549

15161550
/* ----------------

src/backend/utils/misc/trace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ static char *opt_names[] = {
5353
"plan",
5454
"parse",
5555
"rewritten",
56+
"pretty_plan",
57+
"pretty_parse",
58+
"pretty_rewritten",
5659
"parserstats",
5760
"plannerstats",
5861
"executorstats",

src/include/utils/trace.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ enum pg_option_enum
4949
TRACE_PLAN,
5050
TRACE_PARSE,
5151
TRACE_REWRITTEN,
52+
TRACE_PRETTY_PLAN, /* indented multiline versions of trees */
53+
TRACE_PRETTY_PARSE,
54+
TRACE_PRETTY_REWRITTEN,
5255
TRACE_PARSERSTATS,
5356
TRACE_PLANNERSTATS,
5457
TRACE_EXECUTORSTATS,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy