]> granicus.if.org Git - postgresql/blob - src/include/executor/execdebug.h
D'Arcy's recent cleanups
[postgresql] / src / include / executor / execdebug.h
1 /*-------------------------------------------------------------------------
2  *
3  * execdebug.h--
4  *    #defines governing debugging behaviour in the executor
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: execdebug.h,v 1.2 1996/11/08 00:46:14 scrappy Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef EXECDEBUG_H
14 #define EXECDEBUG_H
15
16 #include "access/printtup.h"
17
18 /* ----------------------------------------------------------------
19  *      debugging defines.
20  *
21  *      If you want certain debugging behaviour, then #define
22  *      the variable to 1, else #undef it. -cim 10/26/89
23  * ----------------------------------------------------------------
24  */
25
26 /* ----------------
27  *      EXEC_DEBUGSTORETUP is for tuple table debugging - this
28  *      will print a message every time we call ExecStoreTuple.
29  *      -cim 3/20/91
30  * ----------------
31  */
32 #undef EXEC_DEBUGSTORETUP
33
34 /* ----------------
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
40  * ----------------
41  */
42 #undef EXEC_TUPLECOUNT
43
44 /* ----------------
45  *      EXEC_SHOWBUFSTATS controls whether or not buffer statistics
46  *      are shown for each query.  -cim 2/9/89
47  * ----------------
48  */
49 #undef EXEC_SHOWBUFSTATS
50
51 /* ----------------
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.  
55  * ----------------
56  */
57 #undef EXEC_CONTEXTDEBUG
58
59 /* ----------------
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.
63  *
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.
74  * ----------------
75  */
76 #undef EXEC_RETURNSIZE
77
78 /* ----------------
79  *      EXEC_UTILSDEBUG is a flag which turns on debugging of the
80  *      executor utilities by EU_printf() in eutils.c
81  * ----------------
82  */
83 #undef EXEC_UTILSDEBUG
84
85 /* ----------------
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
88  * ----------------
89  */
90 #undef EXEC_NESTLOOPDEBUG
91
92 /* ----------------
93  *      EXEC_PROCDEBUG is a flag which turns on debugging of
94  *      ExecProcNode() by PN_printf() in procnode.c
95  * ----------------
96  */
97 #undef EXEC_PROCDEBUG
98
99 /* ----------------
100  *      EXEC_EVALDEBUG is a flag which turns on debugging of
101  *      ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
102  * ----------------
103  */
104 #undef EXEC_EVALDEBUG
105
106 /* ----------------
107  *      EXEC_SCANDEBUG is a flag which turns on debugging of
108  *      the ExecSeqScan() stuff by S_printf() in seqscan.c
109  * ----------------
110  */
111 #undef EXEC_SCANDEBUG
112
113 /* ----------------
114  *      EXEC_SORTDEBUG is a flag which turns on debugging of
115  *      the ExecSort() stuff by SO_printf() in sort.c
116  * ----------------
117  */
118 #undef EXEC_SORTDEBUG
119
120 /* ----------------
121  *      EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
122  *      the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
123  * ----------------
124  */
125 #undef EXEC_MERGEJOINDEBUG
126
127 /* ----------------
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
133  * ----------------
134  */
135 #undef EXEC_MERGEJOINPFREE
136
137 /* ----------------
138  *      EXEC_DEBUGINTERACTIVE is a flag which enables the
139  *      user to issue "DEBUG" commands from an interactive
140  *      backend. 
141  * ----------------
142  */
143 #undef EXEC_DEBUGINTERACTIVE
144
145 /* ----------------
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..
149  *
150  *      Example:
151  *
152  * #define EXEC_DEBUGVARIABLEFILE "/a/postgres/cimarron/.pg_debugvars"
153  #
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
157  * ----------------
158  */
159 #undef EXEC_DEBUGVARIABLEFILE
160
161 /* ----------------------------------------------------------------
162  *      #defines controlled by above definitions
163  *
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  * ----------------------------------------------------------------
168  */
169 #define T_OR_F(b)               (b ? "true" : "false")
170 #define NULL_OR_TUPLE(slot)     (TupIsNull(slot) ? "null" : "a tuple")
171
172
173 /* #define EXEC_TUPLECOUNT - XXX take out for now for executor stubbing -- jolly*/
174 /* ----------------
175  *      tuple count debugging defines
176  * ----------------
177  */
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;
186
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++
195 #else
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 */
205
206 /* ----------------
207  *      memory context debugging defines
208  * ----------------
209  */
210 #ifdef EXEC_CONTEXTDEBUG
211 #define CXT_printf(s)                   printf(s)
212 #define CXT1_printf(s, a)               printf(s, a)
213 #else
214 #define CXT_printf(s)           
215 #define CXT1_printf(s, a)               
216 #endif /* EXEC_CONTEXTDEBUG */
217
218 /* ----------------
219  *      eutils debugging defines
220  * ----------------
221  */
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)
229 #else
230 #define EU_nodeDisplay(l)               
231 #define EU_printf(s)                    
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 */
237
238
239 /* ----------------
240  *      nest loop debugging defines
241  * ----------------
242  */
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)
249 #else
250 #define NL_nodeDisplay(l)               
251 #define NL_printf(s)                    
252 #define NL1_printf(s, a)                
253 #define NL4_printf(s, a, b, c, d)       
254 #define ENL1_printf(message)
255 #endif /* EXEC_NESTLOOPDEBUG */
256
257 /* ----------------
258  *      proc node debugging defines
259  * ----------------
260  */
261 #ifdef EXEC_PROCDEBUG
262 #define PN_printf(s)                    printf(s)
263 #define PN1_printf(s, p)                printf(s, p)
264 #else
265 #define PN_printf(s)            
266 #define PN1_printf(s, p)        
267 #endif /* EXEC_PROCDEBUG */
268
269 /* ----------------
270  *      exec eval / target list debugging defines
271  * ----------------
272  */
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)
278 #else
279 #define EV_nodeDisplay(l)               
280 #define EV_printf(s)                    
281 #define EV1_printf(s, a)                
282 #define EV5_printf(s, a, b, c, d, e)    
283 #endif /* EXEC_EVALDEBUG */
284
285 /* ----------------
286  *      scan debugging defines
287  * ----------------
288  */
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)
293 #else
294 #define S_nodeDisplay(l)        
295 #define S_printf(s)             
296 #define S1_printf(s, p)         
297 #endif /*  EXEC_SCANDEBUG */
298  
299 /* ----------------
300  *      sort node debugging defines
301  * ----------------
302  */
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)
307 #else
308 #define SO_nodeDisplay(l)       
309 #define SO_printf(s)            
310 #define SO1_printf(s, p)                
311 #endif /* EXEC_SORTDEBUG */
312
313 /* ----------------
314  *      merge join debugging defines
315  * ----------------
316  */
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));
327             
328 #define MJ_DEBUG_MERGE_COMPARE(qual, res) \
329   MJ2_printf("  MergeCompare(mergeclauses, %s, ..) returns %s\n", \
330              CppAsString(qual), T_OR_F(res));
331
332 #define MJ_DEBUG_PROC_NODE(slot) \
333   MJ2_printf("  %s = ExecProcNode(innerPlan) returns %s\n", \
334              CppAsString(slot), NULL_OR_TUPLE(slot));
335 #else
336 #define MJ_nodeDisplay(l)
337 #define MJ_printf(s)            
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 */
346
347 /* ----------------------------------------------------------------
348  *      DO NOT DEFINE THESE EVER OR YOU WILL BURN!
349  * ----------------------------------------------------------------
350  */
351 /* ----------------
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.
355  * ----------------
356  */
357 #undef DOESNOTWORK
358
359 /* ----------------
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..
368  * ----------------
369  */
370 #undef PERHAPSNEVER
371
372 /* ----------------
373  *      NOTYET is placed around any code not yet implemented
374  *      in the executor.  Only remove these when actually implementing
375  *      said code.
376  * ----------------
377  */
378 #undef NOTYET
379
380 extern long NDirectFileRead;
381 extern long NDirectFileWrite;
382
383 #endif /*  ExecDebugIncluded */