summaryrefslogtreecommitdiff
path: root/src/include/executor/execdebug.h
blob: c4ba3d1f5b6e8be8743d730f6d90e362d2980570 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
/*-------------------------------------------------------------------------
 *
 * execdebug.h
 *	  #defines governing debugging behaviour in the executor
 *
 *
 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * $Id: execdebug.h,v 1.14 2000/09/12 21:07:09 tgl Exp $
 *
 *-------------------------------------------------------------------------
 */
#ifndef EXECDEBUG_H
#define EXECDEBUG_H

#include "executor/executor.h"
#include "nodes/print.h"

/* ----------------------------------------------------------------
 *		debugging defines.
 *
 *		If you want certain debugging behaviour, then #define
 *		the variable to 1. No need to explicitly #undef by default,
 *		since we can use -D compiler options to enable features.
 *		- thomas 1999-02-20
 * ----------------------------------------------------------------
 */

/* ----------------
 *		EXEC_DEBUGSTORETUP is for tuple table debugging - this
 *		will print a message every time we call ExecStoreTuple.
 *		-cim 3/20/91
 * ----------------
#undef EXEC_DEBUGSTORETUP
 */

/* ----------------
 *		EXEC_TUPLECOUNT is a #define which causes the
 *		executor keep track of tuple counts.  This might be
 *		causing some problems with the decstation stuff so
 *		you might want to undefine this if you are doing work
 *		on the decs  - cim 10/20/89
 * ----------------
#undef EXEC_TUPLECOUNT
 */

/* ----------------
 *		EXEC_SHOWBUFSTATS controls whether or not buffer statistics
 *		are shown for each query.  -cim 2/9/89
 * ----------------
#undef EXEC_SHOWBUFSTATS
 */

/* ----------------
 *		EXEC_CONTEXTDEBUG turns on the printing of debugging information
 *		by CXT_printf() calls regarding which memory context is the
 *		CurrentMemoryContext for palloc() calls.
 * ----------------
#undef EXEC_CONTEXTDEBUG
 */

/* ----------------
 *		EXEC_RETURNSIZE is a compile flag governing the
 *		behaviour of lispFmgr..  See ExecMakeFunctionResult().
 *		Undefining this avoids a problem in the system cache.
 *
 *		Note: undefining this means that there is incorrect
 *			  information in the const nodes corresponding
 *			  to function (or operator) results.  The thing is,
 *			  99% of the time this is fine because when you do
 *			  something like x = emp.sal + 1, you already know
 *			  the type and size of x so the fact that + didn't
 *			  return the correct size doesn't matter.
 *			  With variable length stuff the size is stored in
 *			  the first few bytes of the data so again, it's
 *			  not likely to matter.
 * ----------------
#undef EXEC_RETURNSIZE
 */

/* ----------------
 *		EXEC_UTILSDEBUG is a flag which turns on debugging of the
 *		executor utilities by EU_printf() in eutils.c
 * ----------------
#undef EXEC_UTILSDEBUG
 */

/* ----------------
 *		EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
 *		nest loop node by NL_printf() and ENL_printf() in nestloop.c
 * ----------------
#undef EXEC_NESTLOOPDEBUG
 */

/* ----------------
 *		EXEC_PROCDEBUG is a flag which turns on debugging of
 *		ExecProcNode() by PN_printf() in procnode.c
 * ----------------
#undef EXEC_PROCDEBUG
 */

/* ----------------
 *		EXEC_EVALDEBUG is a flag which turns on debugging of
 *		ExecEval and ExecTargetList() stuff by EV_printf() in qual.c
 * ----------------
#undef EXEC_EVALDEBUG
 */

/* ----------------
 *		EXEC_SCANDEBUG is a flag which turns on debugging of
 *		the ExecSeqScan() stuff by S_printf() in seqscan.c
 * ----------------
#undef EXEC_SCANDEBUG
 */

/* ----------------
 *		EXEC_SORTDEBUG is a flag which turns on debugging of
 *		the ExecSort() stuff by SO_printf() in sort.c
 * ----------------
#undef EXEC_SORTDEBUG
 */

/* ----------------
 *		EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
 *		the ExecMergeJoin() stuff by MJ_printf() in mergejoin.c
 * ----------------
#undef EXEC_MERGEJOINDEBUG
 */

/* ----------------
 *		EXEC_DEBUGINTERACTIVE is a flag which enables the
 *		user to issue "DEBUG" commands from an interactive
 *		backend.
 * ----------------
#undef EXEC_DEBUGINTERACTIVE
 */

/* ----------------
 *		EXEC_DEBUGVARIABLEFILE is string, which if defined will
 *		be loaded when the executor is initialized.  If this
 *		string is not defined then nothing will be loaded..
 *
 *		Example:
 *
 * #define EXEC_DEBUGVARIABLEFILE "/a/postgres/cimarron/.pg_debugvars"
 #
 *		Note: since these variables are read at execution time,
 *		they can't affect the first query.. this hack should be
 *		replaced by something better sometime. -cim 11/2/89
 * ----------------
#undef EXEC_DEBUGVARIABLEFILE
 */

/* ----------------------------------------------------------------
 *		#defines controlled by above definitions
 *
 *		Note: most of these are "incomplete" because I didn't
 *			  need the ones not defined.  More should be added
 *			  only as necessary -cim 10/26/89
 * ----------------------------------------------------------------
 */
#define T_OR_F(b)				((b) ? "true" : "false")
#define NULL_OR_TUPLE(slot)		(TupIsNull(slot) ? "null" : "a tuple")


/* ----------------
 *		tuple count debugging defines
 * ----------------
 */
#ifdef EXEC_TUPLECOUNT
extern int	NTupleProcessed;
extern int	NTupleRetrieved;
extern int	NTupleReplaced;
extern int	NTupleAppended;
extern int	NTupleDeleted;
extern int	NIndexTupleProcessed;
extern int	NIndexTupleInserted;

#define IncrRetrieved()			NTupleRetrieved++
#define IncrAppended()			NTupleAppended++
#define IncrDeleted()			NTupleDeleted++
#define IncrReplaced()			NTupleReplaced++
#define IncrInserted()			NTupleInserted++
#define IncrProcessed()			NTupleProcessed++
#define IncrIndexProcessed()	NIndexTupleProcessed++
#define IncrIndexInserted()		NIndexTupleInserted++
#else
/*								stop compiler warnings */
#define IncrRetrieved()			(void)(0)
#define IncrAppended()			(void)(0)
#define IncrDeleted()			(void)(0)
#define IncrReplaced()			(void)(0)
#define IncrInserted()			(void)(0)
#define IncrProcessed()			(void)(0)
#define IncrIndexProcessed()	(void)(0)
#define IncrIndexInserted()		(void)(0)
#endif	 /* EXEC_TUPLECOUNT */

/* ----------------
 *		memory context debugging defines
 * ----------------
 */
#ifdef EXEC_CONTEXTDEBUG
#define CXT_printf(s)					printf(s)
#define CXT1_printf(s, a)				printf(s, a)
#else
#define CXT_printf(s)
#define CXT1_printf(s, a)
#endif	 /* EXEC_CONTEXTDEBUG */

/* ----------------
 *		eutils debugging defines
 * ----------------
 */
#ifdef EXEC_UTILSDEBUG
#define EU_nodeDisplay(l)				nodeDisplay(l)
#define EU_printf(s)					printf(s)
#define EU1_printf(s, a)				printf(s, a)
#define EU2_printf(s, a, b)				printf(s, a, b)
#define EU3_printf(s, a, b, c)			printf(s, a, b, c)
#define EU4_printf(s, a, b, c, d)		printf(s, a, b, c, d)
#else
#define EU_nodeDisplay(l)
#define EU_printf(s)
#define EU1_printf(s, a)
#define EU2_printf(s, a, b)
#define EU3_printf(s, a, b, c)
#define EU4_printf(s, a, b, c, d)
#endif	 /* EXEC_UTILSDEBUG */


/* ----------------
 *		nest loop debugging defines
 * ----------------
 */
#ifdef EXEC_NESTLOOPDEBUG
#define NL_nodeDisplay(l)				nodeDisplay(l)
#define NL_printf(s)					printf(s)
#define NL1_printf(s, a)				printf(s, a)
#define NL4_printf(s, a, b, c, d)		printf(s, a, b, c, d)
#define ENL1_printf(message)			printf("ExecNestLoop: %s\n", message)
#else
#define NL_nodeDisplay(l)
#define NL_printf(s)
#define NL1_printf(s, a)
#define NL4_printf(s, a, b, c, d)
#define ENL1_printf(message)
#endif	 /* EXEC_NESTLOOPDEBUG */

/* ----------------
 *		proc node debugging defines
 * ----------------
 */
#ifdef EXEC_PROCDEBUG
#define PN_printf(s)					printf(s)
#define PN1_printf(s, p)				printf(s, p)
#else
#define PN_printf(s)
#define PN1_printf(s, p)
#endif	 /* EXEC_PROCDEBUG */

/* ----------------
 *		exec eval / target list debugging defines
 * ----------------
 */
#ifdef EXEC_EVALDEBUG
#define EV_nodeDisplay(l)				nodeDisplay(l)
#define EV_printf(s)					printf(s)
#define EV1_printf(s, a)				printf(s, a)
#define EV5_printf(s, a, b, c, d, e)	printf(s, a, b, c, d, e)
#else
#define EV_nodeDisplay(l)
#define EV_printf(s)
#define EV1_printf(s, a)
#define EV5_printf(s, a, b, c, d, e)
#endif	 /* EXEC_EVALDEBUG */

/* ----------------
 *		scan debugging defines
 * ----------------
 */
#ifdef EXEC_SCANDEBUG
#define S_nodeDisplay(l)				nodeDisplay(l)
#define S_printf(s)						printf(s)
#define S1_printf(s, p)					printf(s, p)
#else
#define S_nodeDisplay(l)
#define S_printf(s)
#define S1_printf(s, p)
#endif	 /* EXEC_SCANDEBUG */

/* ----------------
 *		sort node debugging defines
 * ----------------
 */
#ifdef EXEC_SORTDEBUG
#define SO_nodeDisplay(l)				nodeDisplay(l)
#define SO_printf(s)					printf(s)
#define SO1_printf(s, p)				printf(s, p)
#else
#define SO_nodeDisplay(l)
#define SO_printf(s)
#define SO1_printf(s, p)
#endif	 /* EXEC_SORTDEBUG */

/* ----------------
 *		merge join debugging defines
 * ----------------
 */
#ifdef EXEC_MERGEJOINDEBUG

#define MJ_nodeDisplay(l)				nodeDisplay(l)
#define MJ_printf(s)					printf(s)
#define MJ1_printf(s, p)				printf(s, p)
#define MJ2_printf(s, p1, p2)			printf(s, p1, p2)
#define MJ_debugtup(tuple, type)		debugtup(tuple, type, NULL)
#define MJ_dump(state)					ExecMergeTupleDump(state)
#define MJ_DEBUG_QUAL(clause, res) \
  MJ2_printf("  ExecQual(%s, econtext) returns %s\n", \
			 CppAsString(clause), T_OR_F(res));

#define MJ_DEBUG_MERGE_COMPARE(qual, res) \
  MJ2_printf("  MergeCompare(mergeclauses, %s, ...) returns %s\n", \
			 CppAsString(qual), T_OR_F(res));

#define MJ_DEBUG_PROC_NODE(slot) \
  MJ2_printf("  %s = ExecProcNode(...) returns %s\n", \
			 CppAsString(slot), NULL_OR_TUPLE(slot));

#else

#define MJ_nodeDisplay(l)
#define MJ_printf(s)
#define MJ1_printf(s, p)
#define MJ2_printf(s, p1, p2)
#define MJ_debugtup(tuple, type)
#define MJ_dump(state)
#define MJ_DEBUG_QUAL(clause, res)
#define MJ_DEBUG_MERGE_COMPARE(qual, res)
#define MJ_DEBUG_PROC_NODE(slot)

#endif	 /* EXEC_MERGEJOINDEBUG */

/* ----------------------------------------------------------------
 *		DO NOT DEFINE THESE EVER OR YOU WILL BURN!
 * ----------------------------------------------------------------
 */
/* ----------------
 *		NOTYET is placed around any code not yet implemented
 *		in the executor.  Only remove these when actually implementing
 *		said code.
 * ----------------
 */
#undef NOTYET

extern long NDirectFileRead;
extern long NDirectFileWrite;

#endif	 /* ExecDebugIncluded */