1 /*-------------------------------------------------------------------------
4 * #defines governing debugging behaviour in the executor
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: execdebug.h,v 1.2 1996/11/08 00:46:14 scrappy Exp $
11 *-------------------------------------------------------------------------
16 #include "access/printtup.h"
18 /* ----------------------------------------------------------------
21 * If you want certain debugging behaviour, then #define
22 * the variable to 1, else #undef it. -cim 10/26/89
23 * ----------------------------------------------------------------
27 * EXEC_DEBUGSTORETUP is for tuple table debugging - this
28 * will print a message every time we call ExecStoreTuple.
32 #undef EXEC_DEBUGSTORETUP
35 * EXEC_TUPLECOUNT is a #define which causes the
36 * executor keep track of tuple counts. This might be
37 * causing some problems with the decstation stuff so
38 * you might want to undefine this if you are doing work
39 * on the decs - cim 10/20/89
42 #undef EXEC_TUPLECOUNT
45 * EXEC_SHOWBUFSTATS controls whether or not buffer statistics
46 * are shown for each query. -cim 2/9/89
49 #undef EXEC_SHOWBUFSTATS
52 * EXEC_CONTEXTDEBUG turns on the printing of debugging information
53 * by CXT_printf() calls regarding which memory context is the
54 * CurrentMemoryContext for palloc() calls.
57 #undef EXEC_CONTEXTDEBUG
60 * EXEC_RETURNSIZE is a compile flag governing the
61 * behaviour of lispFmgr.. See ExecMakeFunctionResult().
62 * Undefining this avoids a problem in the system cache.
64 * Note: undefining this means that there is incorrect
65 * information in the const nodes corresponding
66 * to function (or operator) results. The thing is,
67 * 99% of the time this is fine because when you do
68 * something like x = emp.sal + 1, you already know
69 * the type and size of x so the fact that + didn't
70 * return the correct size doesn't matter.
71 * With variable length stuff the size is stored in
72 * the first few bytes of the data so again, it's
73 * not likely to matter.
76 #undef EXEC_RETURNSIZE
79 * EXEC_UTILSDEBUG is a flag which turns on debugging of the
80 * executor utilities by EU_printf() in eutils.c
83 #undef EXEC_UTILSDEBUG
86 * EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
87 * nest loop node by NL_printf() and ENL_printf() in nestloop.c
90 #undef EXEC_NESTLOOPDEBUG
93 * EXEC_PROCDEBUG is a flag which turns on debugging of
94 * ExecProcNode() by PN_printf() in procnode.c
100 * EXEC_EVALDEBUG is a flag which turns on debugging of
101 * ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
104 #undef EXEC_EVALDEBUG
107 * EXEC_SCANDEBUG is a flag which turns on debugging of
108 * the ExecSeqScan() stuff by S_printf() in seqscan.c
111 #undef EXEC_SCANDEBUG
114 * EXEC_SORTDEBUG is a flag which turns on debugging of
115 * the ExecSort() stuff by SO_printf() in sort.c
118 #undef EXEC_SORTDEBUG
121 * EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
122 * the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
125 #undef EXEC_MERGEJOINDEBUG
128 * EXEC_MERGEJOINPFREE is a flag which causes merge joins
129 * to pfree intermittant tuples (which is the proper thing)
130 * Not defining this means we avoid menory management problems
131 * at the cost of doing deallocation of stuff only at the
132 * end of the transaction
135 #undef EXEC_MERGEJOINPFREE
138 * EXEC_DEBUGINTERACTIVE is a flag which enables the
139 * user to issue "DEBUG" commands from an interactive
143 #undef EXEC_DEBUGINTERACTIVE
146 * EXEC_DEBUGVARIABLEFILE is string, which if defined will
147 * be loaded when the executor is initialized. If this
148 * string is not defined then nothing will be loaded..
152 * #define EXEC_DEBUGVARIABLEFILE "/a/postgres/cimarron/.pg_debugvars"
154 * Note: since these variables are read at execution time,
155 * they can't affect the first query.. this hack should be
156 * replaced by something better sometime. -cim 11/2/89
159 #undef EXEC_DEBUGVARIABLEFILE
161 /* ----------------------------------------------------------------
162 * #defines controlled by above definitions
164 * Note: most of these are "incomplete" because I didn't
165 * need the ones not defined. More should be added
166 * only as necessary -cim 10/26/89
167 * ----------------------------------------------------------------
169 #define T_OR_F(b) (b ? "true" : "false")
170 #define NULL_OR_TUPLE(slot) (TupIsNull(slot) ? "null" : "a tuple")
173 /* #define EXEC_TUPLECOUNT - XXX take out for now for executor stubbing -- jolly*/
175 * tuple count debugging defines
178 #ifdef EXEC_TUPLECOUNT
179 extern int NTupleProcessed;
180 extern int NTupleRetrieved;
181 extern int NTupleReplaced;
182 extern int NTupleAppended;
183 extern int NTupleDeleted;
184 extern int NIndexTupleProcessed;
185 extern int NIndexTupleInserted;
187 #define IncrRetrieved() NTupleRetrieved++
188 #define IncrAppended() NTupleAppended++
189 #define IncrDeleted() NTupleDeleted++
190 #define IncrReplaced() NTupleReplaced++
191 #define IncrInserted() NTupleInserted++
192 #define IncrProcessed() NTupleProcessed++
193 #define IncrIndexProcessed() NIndexTupleProcessed++
194 #define IncrIndexInserted() NIndexTupleInserted++
196 #define IncrRetrieved()
197 #define IncrAppended()
198 #define IncrDeleted()
199 #define IncrReplaced()
200 #define IncrInserted()
201 #define IncrProcessed()
202 #define IncrIndexProcessed()
203 #define IncrIndexInserted()
204 #endif /* EXEC_TUPLECOUNT */
207 * memory context debugging defines
210 #ifdef EXEC_CONTEXTDEBUG
211 #define CXT_printf(s) printf(s)
212 #define CXT1_printf(s, a) printf(s, a)
214 #define CXT_printf(s)
215 #define CXT1_printf(s, a)
216 #endif /* EXEC_CONTEXTDEBUG */
219 * eutils debugging defines
222 #ifdef EXEC_UTILSDEBUG
223 #define EU_nodeDisplay(l) nodeDisplay(l, 0)
224 #define EU_printf(s) printf(s)
225 #define EU1_printf(s, a) printf(s, a)
226 #define EU2_printf(s, a) printf(s, a, b)
227 #define EU3_printf(s, a) printf(s, a, b, c)
228 #define EU4_printf(s, a, b, c, d) printf(s, a, b, c, d)
230 #define EU_nodeDisplay(l)
232 #define EU1_printf(s, a)
233 #define EU2_printf(s, a, b)
234 #define EU3_printf(s, a, b, c)
235 #define EU4_printf(s, a, b, c, d)
236 #endif /* EXEC_UTILSDEBUG */
240 * nest loop debugging defines
243 #ifdef EXEC_NESTLOOPDEBUG
244 #define NL_nodeDisplay(l) nodeDisplay(l, 0)
245 #define NL_printf(s) printf(s)
246 #define NL1_printf(s, a) printf(s, a)
247 #define NL4_printf(s, a, b, c, d) printf(s, a, b, c, d)
248 #define ENL1_printf(message) printf("ExecNestLoop: %s\n", message)
250 #define NL_nodeDisplay(l)
252 #define NL1_printf(s, a)
253 #define NL4_printf(s, a, b, c, d)
254 #define ENL1_printf(message)
255 #endif /* EXEC_NESTLOOPDEBUG */
258 * proc node debugging defines
261 #ifdef EXEC_PROCDEBUG
262 #define PN_printf(s) printf(s)
263 #define PN1_printf(s, p) printf(s, p)
266 #define PN1_printf(s, p)
267 #endif /* EXEC_PROCDEBUG */
270 * exec eval / target list debugging defines
273 #ifdef EXEC_EVALDEBUG
274 #define EV_nodeDisplay(l) nodeDisplay(l, 0)
275 #define EV_printf(s) printf(s)
276 #define EV1_printf(s, a) printf(s, a)
277 #define EV5_printf(s, a, b, c, d, e) printf(s, a, b, c, d, e)
279 #define EV_nodeDisplay(l)
281 #define EV1_printf(s, a)
282 #define EV5_printf(s, a, b, c, d, e)
283 #endif /* EXEC_EVALDEBUG */
286 * scan debugging defines
289 #ifdef EXEC_SCANDEBUG
290 #define S_nodeDisplay(l) nodeDisplay(l, 0)
291 #define S_printf(s) printf(s)
292 #define S1_printf(s, p) printf(s, p)
294 #define S_nodeDisplay(l)
296 #define S1_printf(s, p)
297 #endif /* EXEC_SCANDEBUG */
300 * sort node debugging defines
303 #ifdef EXEC_SORTDEBUG
304 #define SO_nodeDisplay(l) nodeDisplay(l, 0)
305 #define SO_printf(s) printf(s)
306 #define SO1_printf(s, p) printf(s, p)
308 #define SO_nodeDisplay(l)
310 #define SO1_printf(s, p)
311 #endif /* EXEC_SORTDEBUG */
314 * merge join debugging defines
317 #ifdef EXEC_MERGEJOINDEBUG
318 #define MJ_nodeDisplay(l) nodeDisplay(l, 0)
319 #define MJ_printf(s) printf(s)
320 #define MJ1_printf(s, p) printf(s, p)
321 #define MJ2_printf(s, p1, p2) printf(s, p1, p2)
322 #define MJ_debugtup(tuple, type) debugtup(tuple, type)
323 #define MJ_dump(context, state) ExecMergeTupleDump(econtext, state)
324 #define MJ_DEBUG_QUAL(clause, res) \
325 MJ2_printf(" ExecQual(%s, econtext) returns %s\n", \
326 CppAsString(clause), T_OR_F(res));
328 #define MJ_DEBUG_MERGE_COMPARE(qual, res) \
329 MJ2_printf(" MergeCompare(mergeclauses, %s, ..) returns %s\n", \
330 CppAsString(qual), T_OR_F(res));
332 #define MJ_DEBUG_PROC_NODE(slot) \
333 MJ2_printf(" %s = ExecProcNode(innerPlan) returns %s\n", \
334 CppAsString(slot), NULL_OR_TUPLE(slot));
336 #define MJ_nodeDisplay(l)
338 #define MJ1_printf(s, p)
339 #define MJ2_printf(s, p1, p2)
340 #define MJ_debugtup(tuple, type)
341 #define MJ_dump(context, state)
342 #define MJ_DEBUG_QUAL(clause, res)
343 #define MJ_DEBUG_MERGE_COMPARE(qual, res)
344 #define MJ_DEBUG_PROC_NODE(slot)
345 #endif /* EXEC_MERGEJOINDEBUG */
347 /* ----------------------------------------------------------------
348 * DO NOT DEFINE THESE EVER OR YOU WILL BURN!
349 * ----------------------------------------------------------------
352 * DOESNOTWORK is currently placed around memory manager
353 * code that is known to cause problems. Code in between
354 * is likely not converted and probably won't work anyways.
360 * PERHAPSNEVER is placed around the "scan attribute"
361 * support code for the rule manager because for now we
362 * do things inefficiently. The correct solution to our
363 * problem is to add code to the parser/planner to save
364 * attribute information for the rule manager rather than
365 * have the executor have to grope through the entire plan
366 * for it so if we ever decide to make things better,
367 * we should probably delete the stuff in between PERHAPSNEVER..
373 * NOTYET is placed around any code not yet implemented
374 * in the executor. Only remove these when actually implementing
380 extern long NDirectFileRead;
381 extern long NDirectFileWrite;
383 #endif /* ExecDebugIncluded */