1 /*-------------------------------------------------------------------------
4 * #defines governing debugging behaviour in the executor
7 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: execdebug.h,v 1.21 2003/08/04 02:40:13 momjian Exp $
12 *-------------------------------------------------------------------------
17 #include "executor/executor.h"
18 #include "nodes/print.h"
20 /* ----------------------------------------------------------------
23 * If you want certain debugging behaviour, then #define
24 * the variable to 1. No need to explicitly #undef by default,
25 * since we can use -D compiler options to enable features.
27 * ----------------------------------------------------------------
31 * EXEC_TUPLECOUNT is a #define which causes the
32 * executor keep track of tuple counts. This might be
33 * causing some problems with the decstation stuff so
34 * you might want to undefine this if you are doing work
35 * on the decs - cim 10/20/89
37 #undef EXEC_TUPLECOUNT
41 * EXEC_CONTEXTDEBUG turns on the printing of debugging information
42 * by CXT_printf() calls regarding which memory context is the
43 * CurrentMemoryContext for palloc() calls.
45 #undef EXEC_CONTEXTDEBUG
49 * EXEC_UTILSDEBUG is a flag which turns on debugging of the
50 * executor utilities by EU_printf() in eutils.c
52 #undef EXEC_UTILSDEBUG
56 * EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
57 * nest loop node by NL_printf() and ENL_printf() in nestloop.c
59 #undef EXEC_NESTLOOPDEBUG
63 * EXEC_PROCDEBUG is a flag which turns on debugging of
64 * ExecProcNode() by PN_printf() in procnode.c
70 * EXEC_EVALDEBUG is a flag which turns on debugging of
71 * ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
77 * EXEC_SCANDEBUG is a flag which turns on debugging of
78 * the ExecSeqScan() stuff by S_printf() in seqscan.c
84 * EXEC_SORTDEBUG is a flag which turns on debugging of
85 * the ExecSort() stuff by SO_printf() in sort.c
91 * EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
92 * the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
94 #undef EXEC_MERGEJOINDEBUG
97 /* ----------------------------------------------------------------
98 * #defines controlled by above definitions
100 * Note: most of these are "incomplete" because I didn't
101 * need the ones not defined. More should be added
102 * only as necessary -cim 10/26/89
103 * ----------------------------------------------------------------
105 #define T_OR_F(b) ((b) ? "true" : "false")
106 #define NULL_OR_TUPLE(slot) (TupIsNull(slot) ? "null" : "a tuple")
110 * tuple count debugging defines
113 #ifdef EXEC_TUPLECOUNT
114 extern int NTupleProcessed;
115 extern int NTupleRetrieved;
116 extern int NTupleReplaced;
117 extern int NTupleAppended;
118 extern int NTupleDeleted;
119 extern int NIndexTupleProcessed;
120 extern int NIndexTupleInserted;
122 #define IncrRetrieved() NTupleRetrieved++
123 #define IncrAppended() NTupleAppended++
124 #define IncrDeleted() NTupleDeleted++
125 #define IncrReplaced() NTupleReplaced++
126 #define IncrInserted() NTupleInserted++
127 #define IncrProcessed() NTupleProcessed++
128 #define IncrIndexProcessed() NIndexTupleProcessed++
129 #define IncrIndexInserted() NIndexTupleInserted++
131 /* stop compiler warnings */
132 #define IncrRetrieved() (void)(0)
133 #define IncrAppended() (void)(0)
134 #define IncrDeleted() (void)(0)
135 #define IncrReplaced() (void)(0)
136 #define IncrInserted() (void)(0)
137 #define IncrProcessed() (void)(0)
138 #define IncrIndexProcessed() (void)(0)
139 #define IncrIndexInserted() (void)(0)
140 #endif /* EXEC_TUPLECOUNT */
143 * memory context debugging defines
146 #ifdef EXEC_CONTEXTDEBUG
147 #define CXT_printf(s) printf(s)
148 #define CXT1_printf(s, a) printf(s, a)
150 #define CXT_printf(s)
151 #define CXT1_printf(s, a)
152 #endif /* EXEC_CONTEXTDEBUG */
155 * eutils debugging defines
158 #ifdef EXEC_UTILSDEBUG
159 #define EU_nodeDisplay(l) nodeDisplay(l)
160 #define EU_printf(s) printf(s)
161 #define EU1_printf(s, a) printf(s, a)
162 #define EU2_printf(s, a, b) printf(s, a, b)
163 #define EU3_printf(s, a, b, c) printf(s, a, b, c)
164 #define EU4_printf(s, a, b, c, d) printf(s, a, b, c, d)
166 #define EU_nodeDisplay(l)
168 #define EU1_printf(s, a)
169 #define EU2_printf(s, a, b)
170 #define EU3_printf(s, a, b, c)
171 #define EU4_printf(s, a, b, c, d)
172 #endif /* EXEC_UTILSDEBUG */
176 * nest loop debugging defines
179 #ifdef EXEC_NESTLOOPDEBUG
180 #define NL_nodeDisplay(l) nodeDisplay(l)
181 #define NL_printf(s) printf(s)
182 #define NL1_printf(s, a) printf(s, a)
183 #define NL4_printf(s, a, b, c, d) printf(s, a, b, c, d)
184 #define ENL1_printf(message) printf("ExecNestLoop: %s\n", message)
186 #define NL_nodeDisplay(l)
188 #define NL1_printf(s, a)
189 #define NL4_printf(s, a, b, c, d)
190 #define ENL1_printf(message)
191 #endif /* EXEC_NESTLOOPDEBUG */
194 * proc node debugging defines
197 #ifdef EXEC_PROCDEBUG
198 #define PN_printf(s) printf(s)
199 #define PN1_printf(s, p) printf(s, p)
202 #define PN1_printf(s, p)
203 #endif /* EXEC_PROCDEBUG */
206 * exec eval / target list debugging defines
209 #ifdef EXEC_EVALDEBUG
210 #define EV_nodeDisplay(l) nodeDisplay(l)
211 #define EV_printf(s) printf(s)
212 #define EV1_printf(s, a) printf(s, a)
213 #define EV5_printf(s, a, b, c, d, e) printf(s, a, b, c, d, e)
215 #define EV_nodeDisplay(l)
217 #define EV1_printf(s, a)
218 #define EV5_printf(s, a, b, c, d, e)
219 #endif /* EXEC_EVALDEBUG */
222 * scan debugging defines
225 #ifdef EXEC_SCANDEBUG
226 #define S_nodeDisplay(l) nodeDisplay(l)
227 #define S_printf(s) printf(s)
228 #define S1_printf(s, p) printf(s, p)
230 #define S_nodeDisplay(l)
232 #define S1_printf(s, p)
233 #endif /* EXEC_SCANDEBUG */
236 * sort node debugging defines
239 #ifdef EXEC_SORTDEBUG
240 #define SO_nodeDisplay(l) nodeDisplay(l)
241 #define SO_printf(s) printf(s)
242 #define SO1_printf(s, p) printf(s, p)
244 #define SO_nodeDisplay(l)
246 #define SO1_printf(s, p)
247 #endif /* EXEC_SORTDEBUG */
250 * merge join debugging defines
253 #ifdef EXEC_MERGEJOINDEBUG
255 #define MJ_nodeDisplay(l) nodeDisplay(l)
256 #define MJ_printf(s) printf(s)
257 #define MJ1_printf(s, p) printf(s, p)
258 #define MJ2_printf(s, p1, p2) printf(s, p1, p2)
259 #define MJ_debugtup(tuple, type) debugtup(tuple, type, NULL)
260 #define MJ_dump(state) ExecMergeTupleDump(state)
261 #define MJ_DEBUG_QUAL(clause, res) \
262 MJ2_printf(" ExecQual(%s, econtext) returns %s\n", \
263 CppAsString(clause), T_OR_F(res));
265 #define MJ_DEBUG_MERGE_COMPARE(qual, res) \
266 MJ2_printf(" MergeCompare(mergeclauses, %s, ...) returns %s\n", \
267 CppAsString(qual), T_OR_F(res));
269 #define MJ_DEBUG_PROC_NODE(slot) \
270 MJ2_printf(" %s = ExecProcNode(...) returns %s\n", \
271 CppAsString(slot), NULL_OR_TUPLE(slot));
275 #define MJ_nodeDisplay(l)
277 #define MJ1_printf(s, p)
278 #define MJ2_printf(s, p1, p2)
279 #define MJ_debugtup(tuple, type)
280 #define MJ_dump(state)
281 #define MJ_DEBUG_QUAL(clause, res)
282 #define MJ_DEBUG_MERGE_COMPARE(qual, res)
283 #define MJ_DEBUG_PROC_NODE(slot)
284 #endif /* EXEC_MERGEJOINDEBUG */
286 /* ----------------------------------------------------------------
287 * DO NOT DEFINE THESE EVER OR YOU WILL BURN!
288 * ----------------------------------------------------------------
291 * NOTYET is placed around any code not yet implemented
292 * in the executor. Only remove these when actually implementing
298 extern long NDirectFileRead;
299 extern long NDirectFileWrite;
301 #endif /* ExecDebugIncluded */