]> granicus.if.org Git - postgresql/blob - src/include/executor/execdebug.h
Add:
[postgresql] / src / include / executor / execdebug.h
1 /*-------------------------------------------------------------------------
2  *
3  * execdebug.h
4  *        #defines governing debugging behaviour in the executor
5  *
6  *
7  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: execdebug.h,v 1.12 2000/01/26 05:58:05 momjian Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef EXECDEBUG_H
15 #define EXECDEBUG_H
16
17 #include "nodes/print.h"
18
19 /* ----------------------------------------------------------------
20  *              debugging defines.
21  *
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.
25  *              - thomas 1999-02-20
26  * ----------------------------------------------------------------
27  */
28
29 /* ----------------
30  *              EXEC_DEBUGSTORETUP is for tuple table debugging - this
31  *              will print a message every time we call ExecStoreTuple.
32  *              -cim 3/20/91
33  * ----------------
34 #undef EXEC_DEBUGSTORETUP
35  */
36
37 /* ----------------
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
43  * ----------------
44 #undef EXEC_TUPLECOUNT
45  */
46
47 /* ----------------
48  *              EXEC_SHOWBUFSTATS controls whether or not buffer statistics
49  *              are shown for each query.  -cim 2/9/89
50  * ----------------
51 #undef EXEC_SHOWBUFSTATS
52  */
53
54 /* ----------------
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.
58  * ----------------
59 #undef EXEC_CONTEXTDEBUG
60  */
61
62 /* ----------------
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.
66  *
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.
77  * ----------------
78 #undef EXEC_RETURNSIZE
79  */
80
81 /* ----------------
82  *              EXEC_UTILSDEBUG is a flag which turns on debugging of the
83  *              executor utilities by EU_printf() in eutils.c
84  * ----------------
85 #undef EXEC_UTILSDEBUG
86  */
87
88 /* ----------------
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
91  * ----------------
92 #undef EXEC_NESTLOOPDEBUG
93  */
94
95 /* ----------------
96  *              EXEC_PROCDEBUG is a flag which turns on debugging of
97  *              ExecProcNode() by PN_printf() in procnode.c
98  * ----------------
99 #undef EXEC_PROCDEBUG
100  */
101
102 /* ----------------
103  *              EXEC_EVALDEBUG is a flag which turns on debugging of
104  *              ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
105  * ----------------
106 #undef EXEC_EVALDEBUG
107  */
108
109 /* ----------------
110  *              EXEC_SCANDEBUG is a flag which turns on debugging of
111  *              the ExecSeqScan() stuff by S_printf() in seqscan.c
112  * ----------------
113 #undef EXEC_SCANDEBUG
114  */
115
116 /* ----------------
117  *              EXEC_SORTDEBUG is a flag which turns on debugging of
118  *              the ExecSort() stuff by SO_printf() in sort.c
119  * ----------------
120 #undef EXEC_SORTDEBUG
121  */
122
123 /* ----------------
124  *              EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
125  *              the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
126  * ----------------
127 #undef EXEC_MERGEJOINDEBUG
128  */
129
130 /* ----------------
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
136  * ----------------
137 #undef EXEC_MERGEJOINPFREE
138  */
139
140 /* ----------------
141  *              EXEC_DEBUGINTERACTIVE is a flag which enables the
142  *              user to issue "DEBUG" commands from an interactive
143  *              backend.
144  * ----------------
145 #undef EXEC_DEBUGINTERACTIVE
146  */
147
148 /* ----------------
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..
152  *
153  *              Example:
154  *
155  * #define EXEC_DEBUGVARIABLEFILE "/a/postgres/cimarron/.pg_debugvars"
156  #
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
160  * ----------------
161 #undef EXEC_DEBUGVARIABLEFILE
162  */
163
164 /* ----------------------------------------------------------------
165  *              #defines controlled by above definitions
166  *
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  * ----------------------------------------------------------------
171  */
172 #define T_OR_F(b)                               (b ? "true" : "false")
173 #define NULL_OR_TUPLE(slot)             (TupIsNull(slot) ? "null" : "a tuple")
174
175
176 /* #define EXEC_TUPLECOUNT - XXX take out for now for executor stubbing -- jolly*/
177 /* ----------------
178  *              tuple count debugging defines
179  * ----------------
180  */
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;
189
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++
198 #else
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 */
209
210 /* ----------------
211  *              memory context debugging defines
212  * ----------------
213  */
214 #ifdef EXEC_CONTEXTDEBUG
215 #define CXT_printf(s)                                   printf(s)
216 #define CXT1_printf(s, a)                               printf(s, a)
217 #else
218 #define CXT_printf(s)
219 #define CXT1_printf(s, a)
220 #endif   /* EXEC_CONTEXTDEBUG */
221
222 /* ----------------
223  *              eutils debugging defines
224  * ----------------
225  */
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)
233 #else
234 #define EU_nodeDisplay(l)
235 #define EU_printf(s)
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 */
241
242
243 /* ----------------
244  *              nest loop debugging defines
245  * ----------------
246  */
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)
253 #else
254 #define NL_nodeDisplay(l)
255 #define NL_printf(s)
256 #define NL1_printf(s, a)
257 #define NL4_printf(s, a, b, c, d)
258 #define ENL1_printf(message)
259 #endif   /* EXEC_NESTLOOPDEBUG */
260
261 /* ----------------
262  *              proc node debugging defines
263  * ----------------
264  */
265 #ifdef EXEC_PROCDEBUG
266 #define PN_printf(s)                                    printf(s)
267 #define PN1_printf(s, p)                                printf(s, p)
268 #else
269 #define PN_printf(s)
270 #define PN1_printf(s, p)
271 #endif   /* EXEC_PROCDEBUG */
272
273 /* ----------------
274  *              exec eval / target list debugging defines
275  * ----------------
276  */
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)
282 #else
283 #define EV_nodeDisplay(l)
284 #define EV_printf(s)
285 #define EV1_printf(s, a)
286 #define EV5_printf(s, a, b, c, d, e)
287 #endif   /* EXEC_EVALDEBUG */
288
289 /* ----------------
290  *              scan debugging defines
291  * ----------------
292  */
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)
297 #else
298 #define S_nodeDisplay(l)
299 #define S_printf(s)
300 #define S1_printf(s, p)
301 #endif   /* EXEC_SCANDEBUG */
302
303 /* ----------------
304  *              sort node debugging defines
305  * ----------------
306  */
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)
311 #else
312 #define SO_nodeDisplay(l)
313 #define SO_printf(s)
314 #define SO1_printf(s, p)
315 #endif   /* EXEC_SORTDEBUG */
316
317 /* ----------------
318  *              merge join debugging defines
319  * ----------------
320  */
321 #ifdef EXEC_MERGEJOINDEBUG
322
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));
332
333 #define MJ_DEBUG_MERGE_COMPARE(qual, res) \
334   MJ2_printf("  MergeCompare(mergeclauses, %s, ..) returns %s\n", \
335                          CppAsString(qual), T_OR_F(res));
336
337 #define MJ_DEBUG_PROC_NODE(slot) \
338   MJ2_printf("  %s = ExecProcNode(innerPlan) returns %s\n", \
339                          CppAsString(slot), NULL_OR_TUPLE(slot));
340 #else
341 #define MJ_nodeDisplay(l)
342 #define MJ_printf(s)
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 */
351
352 /* ----------------------------------------------------------------
353  *              DO NOT DEFINE THESE EVER OR YOU WILL BURN!
354  * ----------------------------------------------------------------
355  */
356 /* ----------------
357  *              NOTYET is placed around any code not yet implemented
358  *              in the executor.  Only remove these when actually implementing
359  *              said code.
360  * ----------------
361  */
362 #undef NOTYET
363
364 extern long NDirectFileRead;
365 extern long NDirectFileWrite;
366
367 #endif   /* ExecDebugIncluded */