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.12 2000/01/26 05:58:05 momjian Exp $
12 *-------------------------------------------------------------------------
17 #include "nodes/print.h"
19 /* ----------------------------------------------------------------
22 * If you want certain debugging behaviour, then #define
23 * the variable to 1. No need to explicitly #undef by default,
24 * since we can use -D compiler options to enable features.
26 * ----------------------------------------------------------------
30 * EXEC_DEBUGSTORETUP is for tuple table debugging - this
31 * will print a message every time we call ExecStoreTuple.
34 #undef EXEC_DEBUGSTORETUP
38 * EXEC_TUPLECOUNT is a #define which causes the
39 * executor keep track of tuple counts. This might be
40 * causing some problems with the decstation stuff so
41 * you might want to undefine this if you are doing work
42 * on the decs - cim 10/20/89
44 #undef EXEC_TUPLECOUNT
48 * EXEC_SHOWBUFSTATS controls whether or not buffer statistics
49 * are shown for each query. -cim 2/9/89
51 #undef EXEC_SHOWBUFSTATS
55 * EXEC_CONTEXTDEBUG turns on the printing of debugging information
56 * by CXT_printf() calls regarding which memory context is the
57 * CurrentMemoryContext for palloc() calls.
59 #undef EXEC_CONTEXTDEBUG
63 * EXEC_RETURNSIZE is a compile flag governing the
64 * behaviour of lispFmgr.. See ExecMakeFunctionResult().
65 * Undefining this avoids a problem in the system cache.
67 * Note: undefining this means that there is incorrect
68 * information in the const nodes corresponding
69 * to function (or operator) results. The thing is,
70 * 99% of the time this is fine because when you do
71 * something like x = emp.sal + 1, you already know
72 * the type and size of x so the fact that + didn't
73 * return the correct size doesn't matter.
74 * With variable length stuff the size is stored in
75 * the first few bytes of the data so again, it's
76 * not likely to matter.
78 #undef EXEC_RETURNSIZE
82 * EXEC_UTILSDEBUG is a flag which turns on debugging of the
83 * executor utilities by EU_printf() in eutils.c
85 #undef EXEC_UTILSDEBUG
89 * EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
90 * nest loop node by NL_printf() and ENL_printf() in nestloop.c
92 #undef EXEC_NESTLOOPDEBUG
96 * EXEC_PROCDEBUG is a flag which turns on debugging of
97 * ExecProcNode() by PN_printf() in procnode.c
103 * EXEC_EVALDEBUG is a flag which turns on debugging of
104 * ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
106 #undef EXEC_EVALDEBUG
110 * EXEC_SCANDEBUG is a flag which turns on debugging of
111 * the ExecSeqScan() stuff by S_printf() in seqscan.c
113 #undef EXEC_SCANDEBUG
117 * EXEC_SORTDEBUG is a flag which turns on debugging of
118 * the ExecSort() stuff by SO_printf() in sort.c
120 #undef EXEC_SORTDEBUG
124 * EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
125 * the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
127 #undef EXEC_MERGEJOINDEBUG
131 * EXEC_MERGEJOINPFREE is a flag which causes merge joins
132 * to pfree intermittant tuples (which is the proper thing)
133 * Not defining this means we avoid menory management problems
134 * at the cost of doing deallocation of stuff only at the
135 * end of the transaction
137 #undef EXEC_MERGEJOINPFREE
141 * EXEC_DEBUGINTERACTIVE is a flag which enables the
142 * user to issue "DEBUG" commands from an interactive
145 #undef EXEC_DEBUGINTERACTIVE
149 * EXEC_DEBUGVARIABLEFILE is string, which if defined will
150 * be loaded when the executor is initialized. If this
151 * string is not defined then nothing will be loaded..
155 * #define EXEC_DEBUGVARIABLEFILE "/a/postgres/cimarron/.pg_debugvars"
157 * Note: since these variables are read at execution time,
158 * they can't affect the first query.. this hack should be
159 * replaced by something better sometime. -cim 11/2/89
161 #undef EXEC_DEBUGVARIABLEFILE
164 /* ----------------------------------------------------------------
165 * #defines controlled by above definitions
167 * Note: most of these are "incomplete" because I didn't
168 * need the ones not defined. More should be added
169 * only as necessary -cim 10/26/89
170 * ----------------------------------------------------------------
172 #define T_OR_F(b) (b ? "true" : "false")
173 #define NULL_OR_TUPLE(slot) (TupIsNull(slot) ? "null" : "a tuple")
176 /* #define EXEC_TUPLECOUNT - XXX take out for now for executor stubbing -- jolly*/
178 * tuple count debugging defines
181 #ifdef EXEC_TUPLECOUNT
182 extern int NTupleProcessed;
183 extern int NTupleRetrieved;
184 extern int NTupleReplaced;
185 extern int NTupleAppended;
186 extern int NTupleDeleted;
187 extern int NIndexTupleProcessed;
188 extern int NIndexTupleInserted;
190 #define IncrRetrieved() NTupleRetrieved++
191 #define IncrAppended() NTupleAppended++
192 #define IncrDeleted() NTupleDeleted++
193 #define IncrReplaced() NTupleReplaced++
194 #define IncrInserted() NTupleInserted++
195 #define IncrProcessed() NTupleProcessed++
196 #define IncrIndexProcessed() NIndexTupleProcessed++
197 #define IncrIndexInserted() NIndexTupleInserted++
199 /* stop compiler warnings */
200 #define IncrRetrieved() (void)(0)
201 #define IncrAppended() (void)(0)
202 #define IncrDeleted() (void)(0)
203 #define IncrReplaced() (void)(0)
204 #define IncrInserted() (void)(0)
205 #define IncrProcessed() (void)(0)
206 #define IncrIndexProcessed() (void)(0)
207 #define IncrIndexInserted() (void)(0)
208 #endif /* EXEC_TUPLECOUNT */
211 * memory context debugging defines
214 #ifdef EXEC_CONTEXTDEBUG
215 #define CXT_printf(s) printf(s)
216 #define CXT1_printf(s, a) printf(s, a)
218 #define CXT_printf(s)
219 #define CXT1_printf(s, a)
220 #endif /* EXEC_CONTEXTDEBUG */
223 * eutils debugging defines
226 #ifdef EXEC_UTILSDEBUG
227 #define EU_nodeDisplay(l) nodeDisplay(l)
228 #define EU_printf(s) printf(s)
229 #define EU1_printf(s, a) printf(s, a)
230 #define EU2_printf(s, a) printf(s, a, b)
231 #define EU3_printf(s, a) printf(s, a, b, c)
232 #define EU4_printf(s, a, b, c, d) printf(s, a, b, c, d)
234 #define EU_nodeDisplay(l)
236 #define EU1_printf(s, a)
237 #define EU2_printf(s, a, b)
238 #define EU3_printf(s, a, b, c)
239 #define EU4_printf(s, a, b, c, d)
240 #endif /* EXEC_UTILSDEBUG */
244 * nest loop debugging defines
247 #ifdef EXEC_NESTLOOPDEBUG
248 #define NL_nodeDisplay(l) nodeDisplay(l)
249 #define NL_printf(s) printf(s)
250 #define NL1_printf(s, a) printf(s, a)
251 #define NL4_printf(s, a, b, c, d) printf(s, a, b, c, d)
252 #define ENL1_printf(message) printf("ExecNestLoop: %s\n", message)
254 #define NL_nodeDisplay(l)
256 #define NL1_printf(s, a)
257 #define NL4_printf(s, a, b, c, d)
258 #define ENL1_printf(message)
259 #endif /* EXEC_NESTLOOPDEBUG */
262 * proc node debugging defines
265 #ifdef EXEC_PROCDEBUG
266 #define PN_printf(s) printf(s)
267 #define PN1_printf(s, p) printf(s, p)
270 #define PN1_printf(s, p)
271 #endif /* EXEC_PROCDEBUG */
274 * exec eval / target list debugging defines
277 #ifdef EXEC_EVALDEBUG
278 #define EV_nodeDisplay(l) nodeDisplay(l)
279 #define EV_printf(s) printf(s)
280 #define EV1_printf(s, a) printf(s, a)
281 #define EV5_printf(s, a, b, c, d, e) printf(s, a, b, c, d, e)
283 #define EV_nodeDisplay(l)
285 #define EV1_printf(s, a)
286 #define EV5_printf(s, a, b, c, d, e)
287 #endif /* EXEC_EVALDEBUG */
290 * scan debugging defines
293 #ifdef EXEC_SCANDEBUG
294 #define S_nodeDisplay(l) nodeDisplay(l)
295 #define S_printf(s) printf(s)
296 #define S1_printf(s, p) printf(s, p)
298 #define S_nodeDisplay(l)
300 #define S1_printf(s, p)
301 #endif /* EXEC_SCANDEBUG */
304 * sort node debugging defines
307 #ifdef EXEC_SORTDEBUG
308 #define SO_nodeDisplay(l) nodeDisplay(l)
309 #define SO_printf(s) printf(s)
310 #define SO1_printf(s, p) printf(s, p)
312 #define SO_nodeDisplay(l)
314 #define SO1_printf(s, p)
315 #endif /* EXEC_SORTDEBUG */
318 * merge join debugging defines
321 #ifdef EXEC_MERGEJOINDEBUG
323 #define MJ_nodeDisplay(l) nodeDisplay(l)
324 #define MJ_printf(s) printf(s)
325 #define MJ1_printf(s, p) printf(s, p)
326 #define MJ2_printf(s, p1, p2) printf(s, p1, p2)
327 #define MJ_debugtup(tuple, type) debugtup(tuple, type, NULL)
328 #define MJ_dump(context, state) ExecMergeTupleDump(econtext, state)
329 #define MJ_DEBUG_QUAL(clause, res) \
330 MJ2_printf(" ExecQual(%s, econtext) returns %s\n", \
331 CppAsString(clause), T_OR_F(res));
333 #define MJ_DEBUG_MERGE_COMPARE(qual, res) \
334 MJ2_printf(" MergeCompare(mergeclauses, %s, ..) returns %s\n", \
335 CppAsString(qual), T_OR_F(res));
337 #define MJ_DEBUG_PROC_NODE(slot) \
338 MJ2_printf(" %s = ExecProcNode(innerPlan) returns %s\n", \
339 CppAsString(slot), NULL_OR_TUPLE(slot));
341 #define MJ_nodeDisplay(l)
343 #define MJ1_printf(s, p)
344 #define MJ2_printf(s, p1, p2)
345 #define MJ_debugtup(tuple, type)
346 #define MJ_dump(context, state)
347 #define MJ_DEBUG_QUAL(clause, res)
348 #define MJ_DEBUG_MERGE_COMPARE(qual, res)
349 #define MJ_DEBUG_PROC_NODE(slot)
350 #endif /* EXEC_MERGEJOINDEBUG */
352 /* ----------------------------------------------------------------
353 * DO NOT DEFINE THESE EVER OR YOU WILL BURN!
354 * ----------------------------------------------------------------
357 * NOTYET is placed around any code not yet implemented
358 * in the executor. Only remove these when actually implementing
364 extern long NDirectFileRead;
365 extern long NDirectFileWrite;
367 #endif /* ExecDebugIncluded */