1 /*-------------------------------------------------------------------------
2  *
3  * execdebug.h
4  *	  #defines governing debugging behaviour in the executor
5  *
6  * XXX this is all pretty old and crufty.  Newer code tends to use elog()
7  * for debug printouts, because that's more flexible than printf().
8  *
9  *
10  * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
11  * Portions Copyright (c) 1994, Regents of the University of California
12  *
13  * src/include/executor/execdebug.h
14  *
15  *-------------------------------------------------------------------------
16  */
17 #ifndef EXECDEBUG_H
18 #define EXECDEBUG_H
19 
20 #include "executor/executor.h"
21 #include "nodes/print.h"
22 
23 /* ----------------------------------------------------------------
24  *		debugging defines.
25  *
26  *		If you want certain debugging behaviour, then #define
27  *		the variable to 1. No need to explicitly #undef by default,
28  *		since we can use -D compiler options to enable features.
29  *		- thomas 1999-02-20
30  * ----------------------------------------------------------------
31  */
32 
33 /* ----------------
34  *		EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
35  *		nest loop node by NL_printf() and ENL_printf() in nodeNestloop.c
36  * ----------------
37 #undef EXEC_NESTLOOPDEBUG
38  */
39 
40 /* ----------------
41  *		EXEC_EVALDEBUG is a flag which turns on debugging of
42  *		ExecEval and ExecTargetList() stuff by EV_printf() in execQual.c
43  * ----------------
44 #undef EXEC_EVALDEBUG
45  */
46 
47 /* ----------------
48  *		EXEC_SORTDEBUG is a flag which turns on debugging of
49  *		the ExecSort() stuff by SO_printf() in nodeSort.c
50  * ----------------
51 #undef EXEC_SORTDEBUG
52  */
53 
54 /* ----------------
55  *		EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
56  *		the ExecMergeJoin() stuff by MJ_printf() in nodeMergejoin.c
57  * ----------------
58 #undef EXEC_MERGEJOINDEBUG
59  */
60 
61 /* ----------------------------------------------------------------
62  *		#defines controlled by above definitions
63  *
64  *		Note: most of these are "incomplete" because I didn't
65  *			  need the ones not defined.  More should be added
66  *			  only as necessary -cim 10/26/89
67  * ----------------------------------------------------------------
68  */
69 #define T_OR_F(b)				((b) ? "true" : "false")
70 #define NULL_OR_TUPLE(slot)		(TupIsNull(slot) ? "null" : "a tuple")
71 
72 /* ----------------
73  *		nest loop debugging defines
74  * ----------------
75  */
76 #ifdef EXEC_NESTLOOPDEBUG
77 #define NL_nodeDisplay(l)				nodeDisplay(l)
78 #define NL_printf(s)					printf(s)
79 #define NL1_printf(s, a)				printf(s, a)
80 #define ENL1_printf(message)			printf("ExecNestLoop: %s\n", message)
81 #else
82 #define NL_nodeDisplay(l)
83 #define NL_printf(s)
84 #define NL1_printf(s, a)
85 #define ENL1_printf(message)
86 #endif   /* EXEC_NESTLOOPDEBUG */
87 
88 /* ----------------
89  *		exec eval / target list debugging defines
90  * ----------------
91  */
92 #ifdef EXEC_EVALDEBUG
93 #define EV_nodeDisplay(l)				nodeDisplay(l)
94 #define EV_printf(s)					printf(s)
95 #define EV1_printf(s, a)				printf(s, a)
96 #else
97 #define EV_nodeDisplay(l)
98 #define EV_printf(s)
99 #define EV1_printf(s, a)
100 #endif   /* EXEC_EVALDEBUG */
101 
102 /* ----------------
103  *		sort node debugging defines
104  * ----------------
105  */
106 #ifdef EXEC_SORTDEBUG
107 #define SO_nodeDisplay(l)				nodeDisplay(l)
108 #define SO_printf(s)					printf(s)
109 #define SO1_printf(s, p)				printf(s, p)
110 #else
111 #define SO_nodeDisplay(l)
112 #define SO_printf(s)
113 #define SO1_printf(s, p)
114 #endif   /* EXEC_SORTDEBUG */
115 
116 /* ----------------
117  *		merge join debugging defines
118  * ----------------
119  */
120 #ifdef EXEC_MERGEJOINDEBUG
121 
122 #define MJ_nodeDisplay(l)				nodeDisplay(l)
123 #define MJ_printf(s)					printf(s)
124 #define MJ1_printf(s, p)				printf(s, p)
125 #define MJ2_printf(s, p1, p2)			printf(s, p1, p2)
126 #define MJ_debugtup(slot)				debugtup(slot, NULL)
127 #define MJ_dump(state)					ExecMergeTupleDump(state)
128 #define MJ_DEBUG_COMPARE(res) \
129   MJ1_printf("  MJCompare() returns %d\n", (res))
130 #define MJ_DEBUG_QUAL(clause, res) \
131   MJ2_printf("  ExecQual(%s, econtext) returns %s\n", \
132 			 CppAsString(clause), T_OR_F(res))
133 #define MJ_DEBUG_PROC_NODE(slot) \
134   MJ2_printf("  %s = ExecProcNode(...) returns %s\n", \
135 			 CppAsString(slot), NULL_OR_TUPLE(slot))
136 #else
137 
138 #define MJ_nodeDisplay(l)
139 #define MJ_printf(s)
140 #define MJ1_printf(s, p)
141 #define MJ2_printf(s, p1, p2)
142 #define MJ_debugtup(slot)
143 #define MJ_dump(state)
144 #define MJ_DEBUG_COMPARE(res)
145 #define MJ_DEBUG_QUAL(clause, res)
146 #define MJ_DEBUG_PROC_NODE(slot)
147 #endif   /* EXEC_MERGEJOINDEBUG */
148 
149 #endif   /* ExecDebugIncluded */
150