]> granicus.if.org Git - postgresql/blob - src/include/executor/execdebug.h
First cut at full support for OUTER JOINs. There are still a few loose
[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.14 2000/09/12 21:07:09 tgl Exp $
11  *
12  *-------------------------------------------------------------------------
13  */
14 #ifndef EXECDEBUG_H
15 #define EXECDEBUG_H
16
17 #include "executor/executor.h"
18 #include "nodes/print.h"
19
20 /* ----------------------------------------------------------------
21  *              debugging defines.
22  *
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.
26  *              - thomas 1999-02-20
27  * ----------------------------------------------------------------
28  */
29
30 /* ----------------
31  *              EXEC_DEBUGSTORETUP is for tuple table debugging - this
32  *              will print a message every time we call ExecStoreTuple.
33  *              -cim 3/20/91
34  * ----------------
35 #undef EXEC_DEBUGSTORETUP
36  */
37
38 /* ----------------
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
44  * ----------------
45 #undef EXEC_TUPLECOUNT
46  */
47
48 /* ----------------
49  *              EXEC_SHOWBUFSTATS controls whether or not buffer statistics
50  *              are shown for each query.  -cim 2/9/89
51  * ----------------
52 #undef EXEC_SHOWBUFSTATS
53  */
54
55 /* ----------------
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.
59  * ----------------
60 #undef EXEC_CONTEXTDEBUG
61  */
62
63 /* ----------------
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.
67  *
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.
78  * ----------------
79 #undef EXEC_RETURNSIZE
80  */
81
82 /* ----------------
83  *              EXEC_UTILSDEBUG is a flag which turns on debugging of the
84  *              executor utilities by EU_printf() in eutils.c
85  * ----------------
86 #undef EXEC_UTILSDEBUG
87  */
88
89 /* ----------------
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
92  * ----------------
93 #undef EXEC_NESTLOOPDEBUG
94  */
95
96 /* ----------------
97  *              EXEC_PROCDEBUG is a flag which turns on debugging of
98  *              ExecProcNode() by PN_printf() in procnode.c
99  * ----------------
100 #undef EXEC_PROCDEBUG
101  */
102
103 /* ----------------
104  *              EXEC_EVALDEBUG is a flag which turns on debugging of
105  *              ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
106  * ----------------
107 #undef EXEC_EVALDEBUG
108  */
109
110 /* ----------------
111  *              EXEC_SCANDEBUG is a flag which turns on debugging of
112  *              the ExecSeqScan() stuff by S_printf() in seqscan.c
113  * ----------------
114 #undef EXEC_SCANDEBUG
115  */
116
117 /* ----------------
118  *              EXEC_SORTDEBUG is a flag which turns on debugging of
119  *              the ExecSort() stuff by SO_printf() in sort.c
120  * ----------------
121 #undef EXEC_SORTDEBUG
122  */
123
124 /* ----------------
125  *              EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
126  *              the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
127  * ----------------
128 #undef EXEC_MERGEJOINDEBUG
129  */
130
131 /* ----------------
132  *              EXEC_DEBUGINTERACTIVE is a flag which enables the
133  *              user to issue "DEBUG" commands from an interactive
134  *              backend.
135  * ----------------
136 #undef EXEC_DEBUGINTERACTIVE
137  */
138
139 /* ----------------
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..
143  *
144  *              Example:
145  *
146  * #define EXEC_DEBUGVARIABLEFILE "/a/postgres/cimarron/.pg_debugvars"
147  #
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
151  * ----------------
152 #undef EXEC_DEBUGVARIABLEFILE
153  */
154
155 /* ----------------------------------------------------------------
156  *              #defines controlled by above definitions
157  *
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  * ----------------------------------------------------------------
162  */
163 #define T_OR_F(b)                               ((b) ? "true" : "false")
164 #define NULL_OR_TUPLE(slot)             (TupIsNull(slot) ? "null" : "a tuple")
165
166
167 /* ----------------
168  *              tuple count debugging defines
169  * ----------------
170  */
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;
179
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++
188 #else
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 */
199
200 /* ----------------
201  *              memory context debugging defines
202  * ----------------
203  */
204 #ifdef EXEC_CONTEXTDEBUG
205 #define CXT_printf(s)                                   printf(s)
206 #define CXT1_printf(s, a)                               printf(s, a)
207 #else
208 #define CXT_printf(s)
209 #define CXT1_printf(s, a)
210 #endif   /* EXEC_CONTEXTDEBUG */
211
212 /* ----------------
213  *              eutils debugging defines
214  * ----------------
215  */
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)
223 #else
224 #define EU_nodeDisplay(l)
225 #define EU_printf(s)
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 */
231
232
233 /* ----------------
234  *              nest loop debugging defines
235  * ----------------
236  */
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)
243 #else
244 #define NL_nodeDisplay(l)
245 #define NL_printf(s)
246 #define NL1_printf(s, a)
247 #define NL4_printf(s, a, b, c, d)
248 #define ENL1_printf(message)
249 #endif   /* EXEC_NESTLOOPDEBUG */
250
251 /* ----------------
252  *              proc node debugging defines
253  * ----------------
254  */
255 #ifdef EXEC_PROCDEBUG
256 #define PN_printf(s)                                    printf(s)
257 #define PN1_printf(s, p)                                printf(s, p)
258 #else
259 #define PN_printf(s)
260 #define PN1_printf(s, p)
261 #endif   /* EXEC_PROCDEBUG */
262
263 /* ----------------
264  *              exec eval / target list debugging defines
265  * ----------------
266  */
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)
272 #else
273 #define EV_nodeDisplay(l)
274 #define EV_printf(s)
275 #define EV1_printf(s, a)
276 #define EV5_printf(s, a, b, c, d, e)
277 #endif   /* EXEC_EVALDEBUG */
278
279 /* ----------------
280  *              scan debugging defines
281  * ----------------
282  */
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)
287 #else
288 #define S_nodeDisplay(l)
289 #define S_printf(s)
290 #define S1_printf(s, p)
291 #endif   /* EXEC_SCANDEBUG */
292
293 /* ----------------
294  *              sort node debugging defines
295  * ----------------
296  */
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)
301 #else
302 #define SO_nodeDisplay(l)
303 #define SO_printf(s)
304 #define SO1_printf(s, p)
305 #endif   /* EXEC_SORTDEBUG */
306
307 /* ----------------
308  *              merge join debugging defines
309  * ----------------
310  */
311 #ifdef EXEC_MERGEJOINDEBUG
312
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));
322
323 #define MJ_DEBUG_MERGE_COMPARE(qual, res) \
324   MJ2_printf("  MergeCompare(mergeclauses, %s, ...) returns %s\n", \
325                          CppAsString(qual), T_OR_F(res));
326
327 #define MJ_DEBUG_PROC_NODE(slot) \
328   MJ2_printf("  %s = ExecProcNode(...) returns %s\n", \
329                          CppAsString(slot), NULL_OR_TUPLE(slot));
330
331 #else
332
333 #define MJ_nodeDisplay(l)
334 #define MJ_printf(s)
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)
342
343 #endif   /* EXEC_MERGEJOINDEBUG */
344
345 /* ----------------------------------------------------------------
346  *              DO NOT DEFINE THESE EVER OR YOU WILL BURN!
347  * ----------------------------------------------------------------
348  */
349 /* ----------------
350  *              NOTYET is placed around any code not yet implemented
351  *              in the executor.  Only remove these when actually implementing
352  *              said code.
353  * ----------------
354  */
355 #undef NOTYET
356
357 extern long NDirectFileRead;
358 extern long NDirectFileWrite;
359
360 #endif   /* ExecDebugIncluded */