1 /*-------------------------------------------------------------------------
4 * #defines governing debugging behaviour in the executor
7 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $Id: execdebug.h,v 1.14 2000/09/12 21:07:09 tgl 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_DEBUGSTORETUP is for tuple table debugging - this
32 * will print a message every time we call ExecStoreTuple.
35 #undef EXEC_DEBUGSTORETUP
39 * EXEC_TUPLECOUNT is a #define which causes the
40 * executor keep track of tuple counts. This might be
41 * causing some problems with the decstation stuff so
42 * you might want to undefine this if you are doing work
43 * on the decs - cim 10/20/89
45 #undef EXEC_TUPLECOUNT
49 * EXEC_SHOWBUFSTATS controls whether or not buffer statistics
50 * are shown for each query. -cim 2/9/89
52 #undef EXEC_SHOWBUFSTATS
56 * EXEC_CONTEXTDEBUG turns on the printing of debugging information
57 * by CXT_printf() calls regarding which memory context is the
58 * CurrentMemoryContext for palloc() calls.
60 #undef EXEC_CONTEXTDEBUG
64 * EXEC_RETURNSIZE is a compile flag governing the
65 * behaviour of lispFmgr.. See ExecMakeFunctionResult().
66 * Undefining this avoids a problem in the system cache.
68 * Note: undefining this means that there is incorrect
69 * information in the const nodes corresponding
70 * to function (or operator) results. The thing is,
71 * 99% of the time this is fine because when you do
72 * something like x = emp.sal + 1, you already know
73 * the type and size of x so the fact that + didn't
74 * return the correct size doesn't matter.
75 * With variable length stuff the size is stored in
76 * the first few bytes of the data so again, it's
77 * not likely to matter.
79 #undef EXEC_RETURNSIZE
83 * EXEC_UTILSDEBUG is a flag which turns on debugging of the
84 * executor utilities by EU_printf() in eutils.c
86 #undef EXEC_UTILSDEBUG
90 * EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
91 * nest loop node by NL_printf() and ENL_printf() in nestloop.c
93 #undef EXEC_NESTLOOPDEBUG
97 * EXEC_PROCDEBUG is a flag which turns on debugging of
98 * ExecProcNode() by PN_printf() in procnode.c
100 #undef EXEC_PROCDEBUG
104 * EXEC_EVALDEBUG is a flag which turns on debugging of
105 * ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
107 #undef EXEC_EVALDEBUG
111 * EXEC_SCANDEBUG is a flag which turns on debugging of
112 * the ExecSeqScan() stuff by S_printf() in seqscan.c
114 #undef EXEC_SCANDEBUG
118 * EXEC_SORTDEBUG is a flag which turns on debugging of
119 * the ExecSort() stuff by SO_printf() in sort.c
121 #undef EXEC_SORTDEBUG
125 * EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
126 * the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
128 #undef EXEC_MERGEJOINDEBUG
132 * EXEC_DEBUGINTERACTIVE is a flag which enables the
133 * user to issue "DEBUG" commands from an interactive
136 #undef EXEC_DEBUGINTERACTIVE
140 * EXEC_DEBUGVARIABLEFILE is string, which if defined will
141 * be loaded when the executor is initialized. If this
142 * string is not defined then nothing will be loaded..
146 * #define EXEC_DEBUGVARIABLEFILE "/a/postgres/cimarron/.pg_debugvars"
148 * Note: since these variables are read at execution time,
149 * they can't affect the first query.. this hack should be
150 * replaced by something better sometime. -cim 11/2/89
152 #undef EXEC_DEBUGVARIABLEFILE
155 /* ----------------------------------------------------------------
156 * #defines controlled by above definitions
158 * Note: most of these are "incomplete" because I didn't
159 * need the ones not defined. More should be added
160 * only as necessary -cim 10/26/89
161 * ----------------------------------------------------------------
163 #define T_OR_F(b) ((b) ? "true" : "false")
164 #define NULL_OR_TUPLE(slot) (TupIsNull(slot) ? "null" : "a tuple")
168 * tuple count debugging defines
171 #ifdef EXEC_TUPLECOUNT
172 extern int NTupleProcessed;
173 extern int NTupleRetrieved;
174 extern int NTupleReplaced;
175 extern int NTupleAppended;
176 extern int NTupleDeleted;
177 extern int NIndexTupleProcessed;
178 extern int NIndexTupleInserted;
180 #define IncrRetrieved() NTupleRetrieved++
181 #define IncrAppended() NTupleAppended++
182 #define IncrDeleted() NTupleDeleted++
183 #define IncrReplaced() NTupleReplaced++
184 #define IncrInserted() NTupleInserted++
185 #define IncrProcessed() NTupleProcessed++
186 #define IncrIndexProcessed() NIndexTupleProcessed++
187 #define IncrIndexInserted() NIndexTupleInserted++
189 /* stop compiler warnings */
190 #define IncrRetrieved() (void)(0)
191 #define IncrAppended() (void)(0)
192 #define IncrDeleted() (void)(0)
193 #define IncrReplaced() (void)(0)
194 #define IncrInserted() (void)(0)
195 #define IncrProcessed() (void)(0)
196 #define IncrIndexProcessed() (void)(0)
197 #define IncrIndexInserted() (void)(0)
198 #endif /* EXEC_TUPLECOUNT */
201 * memory context debugging defines
204 #ifdef EXEC_CONTEXTDEBUG
205 #define CXT_printf(s) printf(s)
206 #define CXT1_printf(s, a) printf(s, a)
208 #define CXT_printf(s)
209 #define CXT1_printf(s, a)
210 #endif /* EXEC_CONTEXTDEBUG */
213 * eutils debugging defines
216 #ifdef EXEC_UTILSDEBUG
217 #define EU_nodeDisplay(l) nodeDisplay(l)
218 #define EU_printf(s) printf(s)
219 #define EU1_printf(s, a) printf(s, a)
220 #define EU2_printf(s, a, b) printf(s, a, b)
221 #define EU3_printf(s, a, b, c) printf(s, a, b, c)
222 #define EU4_printf(s, a, b, c, d) printf(s, a, b, c, d)
224 #define EU_nodeDisplay(l)
226 #define EU1_printf(s, a)
227 #define EU2_printf(s, a, b)
228 #define EU3_printf(s, a, b, c)
229 #define EU4_printf(s, a, b, c, d)
230 #endif /* EXEC_UTILSDEBUG */
234 * nest loop debugging defines
237 #ifdef EXEC_NESTLOOPDEBUG
238 #define NL_nodeDisplay(l) nodeDisplay(l)
239 #define NL_printf(s) printf(s)
240 #define NL1_printf(s, a) printf(s, a)
241 #define NL4_printf(s, a, b, c, d) printf(s, a, b, c, d)
242 #define ENL1_printf(message) printf("ExecNestLoop: %s\n", message)
244 #define NL_nodeDisplay(l)
246 #define NL1_printf(s, a)
247 #define NL4_printf(s, a, b, c, d)
248 #define ENL1_printf(message)
249 #endif /* EXEC_NESTLOOPDEBUG */
252 * proc node debugging defines
255 #ifdef EXEC_PROCDEBUG
256 #define PN_printf(s) printf(s)
257 #define PN1_printf(s, p) printf(s, p)
260 #define PN1_printf(s, p)
261 #endif /* EXEC_PROCDEBUG */
264 * exec eval / target list debugging defines
267 #ifdef EXEC_EVALDEBUG
268 #define EV_nodeDisplay(l) nodeDisplay(l)
269 #define EV_printf(s) printf(s)
270 #define EV1_printf(s, a) printf(s, a)
271 #define EV5_printf(s, a, b, c, d, e) printf(s, a, b, c, d, e)
273 #define EV_nodeDisplay(l)
275 #define EV1_printf(s, a)
276 #define EV5_printf(s, a, b, c, d, e)
277 #endif /* EXEC_EVALDEBUG */
280 * scan debugging defines
283 #ifdef EXEC_SCANDEBUG
284 #define S_nodeDisplay(l) nodeDisplay(l)
285 #define S_printf(s) printf(s)
286 #define S1_printf(s, p) printf(s, p)
288 #define S_nodeDisplay(l)
290 #define S1_printf(s, p)
291 #endif /* EXEC_SCANDEBUG */
294 * sort node debugging defines
297 #ifdef EXEC_SORTDEBUG
298 #define SO_nodeDisplay(l) nodeDisplay(l)
299 #define SO_printf(s) printf(s)
300 #define SO1_printf(s, p) printf(s, p)
302 #define SO_nodeDisplay(l)
304 #define SO1_printf(s, p)
305 #endif /* EXEC_SORTDEBUG */
308 * merge join debugging defines
311 #ifdef EXEC_MERGEJOINDEBUG
313 #define MJ_nodeDisplay(l) nodeDisplay(l)
314 #define MJ_printf(s) printf(s)
315 #define MJ1_printf(s, p) printf(s, p)
316 #define MJ2_printf(s, p1, p2) printf(s, p1, p2)
317 #define MJ_debugtup(tuple, type) debugtup(tuple, type, NULL)
318 #define MJ_dump(state) ExecMergeTupleDump(state)
319 #define MJ_DEBUG_QUAL(clause, res) \
320 MJ2_printf(" ExecQual(%s, econtext) returns %s\n", \
321 CppAsString(clause), T_OR_F(res));
323 #define MJ_DEBUG_MERGE_COMPARE(qual, res) \
324 MJ2_printf(" MergeCompare(mergeclauses, %s, ...) returns %s\n", \
325 CppAsString(qual), T_OR_F(res));
327 #define MJ_DEBUG_PROC_NODE(slot) \
328 MJ2_printf(" %s = ExecProcNode(...) returns %s\n", \
329 CppAsString(slot), NULL_OR_TUPLE(slot));
333 #define MJ_nodeDisplay(l)
335 #define MJ1_printf(s, p)
336 #define MJ2_printf(s, p1, p2)
337 #define MJ_debugtup(tuple, type)
338 #define MJ_dump(state)
339 #define MJ_DEBUG_QUAL(clause, res)
340 #define MJ_DEBUG_MERGE_COMPARE(qual, res)
341 #define MJ_DEBUG_PROC_NODE(slot)
343 #endif /* EXEC_MERGEJOINDEBUG */
345 /* ----------------------------------------------------------------
346 * DO NOT DEFINE THESE EVER OR YOU WILL BURN!
347 * ----------------------------------------------------------------
350 * NOTYET is placed around any code not yet implemented
351 * in the executor. Only remove these when actually implementing
357 extern long NDirectFileRead;
358 extern long NDirectFileWrite;
360 #endif /* ExecDebugIncluded */