OSDN Git Service

Update copyrights to 2003.
[pg-rex/syncrep.git] / 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-2003, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: execdebug.h,v 1.21 2003/08/04 02:40:13 momjian 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_TUPLECOUNT is a #define which causes the
32  *              executor keep track of tuple counts.  This might be
33  *              causing some problems with the decstation stuff so
34  *              you might want to undefine this if you are doing work
35  *              on the decs  - cim 10/20/89
36  * ----------------
37 #undef EXEC_TUPLECOUNT
38  */
39
40 /* ----------------
41  *              EXEC_CONTEXTDEBUG turns on the printing of debugging information
42  *              by CXT_printf() calls regarding which memory context is the
43  *              CurrentMemoryContext for palloc() calls.
44  * ----------------
45 #undef EXEC_CONTEXTDEBUG
46  */
47
48 /* ----------------
49  *              EXEC_UTILSDEBUG is a flag which turns on debugging of the
50  *              executor utilities by EU_printf() in eutils.c
51  * ----------------
52 #undef EXEC_UTILSDEBUG
53  */
54
55 /* ----------------
56  *              EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
57  *              nest loop node by NL_printf() and ENL_printf() in nestloop.c
58  * ----------------
59 #undef EXEC_NESTLOOPDEBUG
60  */
61
62 /* ----------------
63  *              EXEC_PROCDEBUG is a flag which turns on debugging of
64  *              ExecProcNode() by PN_printf() in procnode.c
65  * ----------------
66 #undef EXEC_PROCDEBUG
67  */
68
69 /* ----------------
70  *              EXEC_EVALDEBUG is a flag which turns on debugging of
71  *              ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
72  * ----------------
73 #undef EXEC_EVALDEBUG
74  */
75
76 /* ----------------
77  *              EXEC_SCANDEBUG is a flag which turns on debugging of
78  *              the ExecSeqScan() stuff by S_printf() in seqscan.c
79  * ----------------
80 #undef EXEC_SCANDEBUG
81  */
82
83 /* ----------------
84  *              EXEC_SORTDEBUG is a flag which turns on debugging of
85  *              the ExecSort() stuff by SO_printf() in sort.c
86  * ----------------
87 #undef EXEC_SORTDEBUG
88  */
89
90 /* ----------------
91  *              EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
92  *              the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
93  * ----------------
94 #undef EXEC_MERGEJOINDEBUG
95  */
96
97 /* ----------------------------------------------------------------
98  *              #defines controlled by above definitions
99  *
100  *              Note: most of these are "incomplete" because I didn't
101  *                        need the ones not defined.  More should be added
102  *                        only as necessary -cim 10/26/89
103  * ----------------------------------------------------------------
104  */
105 #define T_OR_F(b)                               ((b) ? "true" : "false")
106 #define NULL_OR_TUPLE(slot)             (TupIsNull(slot) ? "null" : "a tuple")
107
108
109 /* ----------------
110  *              tuple count debugging defines
111  * ----------------
112  */
113 #ifdef EXEC_TUPLECOUNT
114 extern int      NTupleProcessed;
115 extern int      NTupleRetrieved;
116 extern int      NTupleReplaced;
117 extern int      NTupleAppended;
118 extern int      NTupleDeleted;
119 extern int      NIndexTupleProcessed;
120 extern int      NIndexTupleInserted;
121
122 #define IncrRetrieved()                 NTupleRetrieved++
123 #define IncrAppended()                  NTupleAppended++
124 #define IncrDeleted()                   NTupleDeleted++
125 #define IncrReplaced()                  NTupleReplaced++
126 #define IncrInserted()                  NTupleInserted++
127 #define IncrProcessed()                 NTupleProcessed++
128 #define IncrIndexProcessed()    NIndexTupleProcessed++
129 #define IncrIndexInserted()             NIndexTupleInserted++
130 #else
131 /*                                                              stop compiler warnings */
132 #define IncrRetrieved()                 (void)(0)
133 #define IncrAppended()                  (void)(0)
134 #define IncrDeleted()                   (void)(0)
135 #define IncrReplaced()                  (void)(0)
136 #define IncrInserted()                  (void)(0)
137 #define IncrProcessed()                 (void)(0)
138 #define IncrIndexProcessed()    (void)(0)
139 #define IncrIndexInserted()             (void)(0)
140 #endif   /* EXEC_TUPLECOUNT */
141
142 /* ----------------
143  *              memory context debugging defines
144  * ----------------
145  */
146 #ifdef EXEC_CONTEXTDEBUG
147 #define CXT_printf(s)                                   printf(s)
148 #define CXT1_printf(s, a)                               printf(s, a)
149 #else
150 #define CXT_printf(s)
151 #define CXT1_printf(s, a)
152 #endif   /* EXEC_CONTEXTDEBUG */
153
154 /* ----------------
155  *              eutils debugging defines
156  * ----------------
157  */
158 #ifdef EXEC_UTILSDEBUG
159 #define EU_nodeDisplay(l)                               nodeDisplay(l)
160 #define EU_printf(s)                                    printf(s)
161 #define EU1_printf(s, a)                                printf(s, a)
162 #define EU2_printf(s, a, b)                             printf(s, a, b)
163 #define EU3_printf(s, a, b, c)                  printf(s, a, b, c)
164 #define EU4_printf(s, a, b, c, d)               printf(s, a, b, c, d)
165 #else
166 #define EU_nodeDisplay(l)
167 #define EU_printf(s)
168 #define EU1_printf(s, a)
169 #define EU2_printf(s, a, b)
170 #define EU3_printf(s, a, b, c)
171 #define EU4_printf(s, a, b, c, d)
172 #endif   /* EXEC_UTILSDEBUG */
173
174
175 /* ----------------
176  *              nest loop debugging defines
177  * ----------------
178  */
179 #ifdef EXEC_NESTLOOPDEBUG
180 #define NL_nodeDisplay(l)                               nodeDisplay(l)
181 #define NL_printf(s)                                    printf(s)
182 #define NL1_printf(s, a)                                printf(s, a)
183 #define NL4_printf(s, a, b, c, d)               printf(s, a, b, c, d)
184 #define ENL1_printf(message)                    printf("ExecNestLoop: %s\n", message)
185 #else
186 #define NL_nodeDisplay(l)
187 #define NL_printf(s)
188 #define NL1_printf(s, a)
189 #define NL4_printf(s, a, b, c, d)
190 #define ENL1_printf(message)
191 #endif   /* EXEC_NESTLOOPDEBUG */
192
193 /* ----------------
194  *              proc node debugging defines
195  * ----------------
196  */
197 #ifdef EXEC_PROCDEBUG
198 #define PN_printf(s)                                    printf(s)
199 #define PN1_printf(s, p)                                printf(s, p)
200 #else
201 #define PN_printf(s)
202 #define PN1_printf(s, p)
203 #endif   /* EXEC_PROCDEBUG */
204
205 /* ----------------
206  *              exec eval / target list debugging defines
207  * ----------------
208  */
209 #ifdef EXEC_EVALDEBUG
210 #define EV_nodeDisplay(l)                               nodeDisplay(l)
211 #define EV_printf(s)                                    printf(s)
212 #define EV1_printf(s, a)                                printf(s, a)
213 #define EV5_printf(s, a, b, c, d, e)    printf(s, a, b, c, d, e)
214 #else
215 #define EV_nodeDisplay(l)
216 #define EV_printf(s)
217 #define EV1_printf(s, a)
218 #define EV5_printf(s, a, b, c, d, e)
219 #endif   /* EXEC_EVALDEBUG */
220
221 /* ----------------
222  *              scan debugging defines
223  * ----------------
224  */
225 #ifdef EXEC_SCANDEBUG
226 #define S_nodeDisplay(l)                                nodeDisplay(l)
227 #define S_printf(s)                                             printf(s)
228 #define S1_printf(s, p)                                 printf(s, p)
229 #else
230 #define S_nodeDisplay(l)
231 #define S_printf(s)
232 #define S1_printf(s, p)
233 #endif   /* EXEC_SCANDEBUG */
234
235 /* ----------------
236  *              sort node debugging defines
237  * ----------------
238  */
239 #ifdef EXEC_SORTDEBUG
240 #define SO_nodeDisplay(l)                               nodeDisplay(l)
241 #define SO_printf(s)                                    printf(s)
242 #define SO1_printf(s, p)                                printf(s, p)
243 #else
244 #define SO_nodeDisplay(l)
245 #define SO_printf(s)
246 #define SO1_printf(s, p)
247 #endif   /* EXEC_SORTDEBUG */
248
249 /* ----------------
250  *              merge join debugging defines
251  * ----------------
252  */
253 #ifdef EXEC_MERGEJOINDEBUG
254
255 #define MJ_nodeDisplay(l)                               nodeDisplay(l)
256 #define MJ_printf(s)                                    printf(s)
257 #define MJ1_printf(s, p)                                printf(s, p)
258 #define MJ2_printf(s, p1, p2)                   printf(s, p1, p2)
259 #define MJ_debugtup(tuple, type)                debugtup(tuple, type, NULL)
260 #define MJ_dump(state)                                  ExecMergeTupleDump(state)
261 #define MJ_DEBUG_QUAL(clause, res) \
262   MJ2_printf("  ExecQual(%s, econtext) returns %s\n", \
263                          CppAsString(clause), T_OR_F(res));
264
265 #define MJ_DEBUG_MERGE_COMPARE(qual, res) \
266   MJ2_printf("  MergeCompare(mergeclauses, %s, ...) returns %s\n", \
267                          CppAsString(qual), T_OR_F(res));
268
269 #define MJ_DEBUG_PROC_NODE(slot) \
270   MJ2_printf("  %s = ExecProcNode(...) returns %s\n", \
271                          CppAsString(slot), NULL_OR_TUPLE(slot));
272
273 #else
274
275 #define MJ_nodeDisplay(l)
276 #define MJ_printf(s)
277 #define MJ1_printf(s, p)
278 #define MJ2_printf(s, p1, p2)
279 #define MJ_debugtup(tuple, type)
280 #define MJ_dump(state)
281 #define MJ_DEBUG_QUAL(clause, res)
282 #define MJ_DEBUG_MERGE_COMPARE(qual, res)
283 #define MJ_DEBUG_PROC_NODE(slot)
284 #endif   /* EXEC_MERGEJOINDEBUG */
285
286 /* ----------------------------------------------------------------
287  *              DO NOT DEFINE THESE EVER OR YOU WILL BURN!
288  * ----------------------------------------------------------------
289  */
290 /* ----------------
291  *              NOTYET is placed around any code not yet implemented
292  *              in the executor.  Only remove these when actually implementing
293  *              said code.
294  * ----------------
295  */
296 #undef NOTYET
297
298 extern long NDirectFileRead;
299 extern long NDirectFileWrite;
300
301 #endif   /* ExecDebugIncluded */