execdebug.h 6.1 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * execdebug.h
4
 *	  #defines governing debugging behaviour in the executor
5
 *
6 7 8
 * XXX this is all pretty old and crufty.  Newer code tends to use elog()
 * for debug printouts, because that's more flexible than printf().
 *
9
 *
10
 * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
B
Add:  
Bruce Momjian 已提交
11
 * Portions Copyright (c) 1994, Regents of the University of California
12
 *
13
 * $PostgreSQL: pgsql/src/include/executor/execdebug.h,v 1.30 2006/05/23 15:21:52 tgl Exp $
14 15 16 17 18 19
 *
 *-------------------------------------------------------------------------
 */
#ifndef EXECDEBUG_H
#define EXECDEBUG_H

B
Bruce Momjian 已提交
20
#include "executor/executor.h"
21
#include "nodes/print.h"
22

23
/* ----------------------------------------------------------------
24
 *		debugging defines.
25
 *
26
 *		If you want certain debugging behaviour, then #define
27 28 29
 *		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
30 31 32 33
 * ----------------------------------------------------------------
 */

/* ----------------
34
 *		EXEC_TUPLECOUNT is a #define which causes the
35
 *		executor to keep track of tuple counts.  This might be
36 37 38
 *		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
39 40
 * ----------------
#undef EXEC_TUPLECOUNT
41
 */
42 43

/* ----------------
44
 *		EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
45
 *		nest loop node by NL_printf() and ENL_printf() in nodeNestloop.c
46 47
 * ----------------
#undef EXEC_NESTLOOPDEBUG
48
 */
49 50

/* ----------------
51
 *		EXEC_EVALDEBUG is a flag which turns on debugging of
52
 *		ExecEval and ExecTargetList() stuff by EV_printf() in execQual.c
53 54
 * ----------------
#undef EXEC_EVALDEBUG
55
 */
56 57

/* ----------------
58
 *		EXEC_SORTDEBUG is a flag which turns on debugging of
59
 *		the ExecSort() stuff by SO_printf() in nodeSort.c
60 61
 * ----------------
#undef EXEC_SORTDEBUG
62
 */
63 64

/* ----------------
65
 *		EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
66
 *		the ExecMergeJoin() stuff by MJ_printf() in nodeMergejoin.c
67 68
 * ----------------
#undef EXEC_MERGEJOINDEBUG
69
 */
70 71

/* ----------------------------------------------------------------
72
 *		#defines controlled by above definitions
73
 *
74 75 76
 *		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
77 78
 * ----------------------------------------------------------------
 */
79
#define T_OR_F(b)				((b) ? "true" : "false")
80
#define NULL_OR_TUPLE(slot)		(TupIsNull(slot) ? "null" : "a tuple")
81 82 83


/* ----------------
84
 *		tuple count debugging defines
85 86 87
 * ----------------
 */
#ifdef EXEC_TUPLECOUNT
88 89 90 91 92 93 94
extern int	NTupleProcessed;
extern int	NTupleRetrieved;
extern int	NTupleReplaced;
extern int	NTupleAppended;
extern int	NTupleDeleted;
extern int	NIndexTupleProcessed;
extern int	NIndexTupleInserted;
95 96 97 98 99 100 101

#define IncrRetrieved()			NTupleRetrieved++
#define IncrAppended()			NTupleAppended++
#define IncrDeleted()			NTupleDeleted++
#define IncrReplaced()			NTupleReplaced++
#define IncrInserted()			NTupleInserted++
#define IncrProcessed()			NTupleProcessed++
102
#define IncrIndexProcessed()	NIndexTupleProcessed++
103
#define IncrIndexInserted()		NIndexTupleInserted++
104
#else
105
/* stop compiler warnings */
106 107 108 109 110 111 112 113
#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)
114
#endif   /* EXEC_TUPLECOUNT */
115 116

/* ----------------
117
 *		nest loop debugging defines
118 119 120
 * ----------------
 */
#ifdef EXEC_NESTLOOPDEBUG
121
#define NL_nodeDisplay(l)				nodeDisplay(l)
122 123 124
#define NL_printf(s)					printf(s)
#define NL1_printf(s, a)				printf(s, a)
#define ENL1_printf(message)			printf("ExecNestLoop: %s\n", message)
125
#else
126 127 128
#define NL_nodeDisplay(l)
#define NL_printf(s)
#define NL1_printf(s, a)
129
#define ENL1_printf(message)
130
#endif   /* EXEC_NESTLOOPDEBUG */
131 132

/* ----------------
133
 *		exec eval / target list debugging defines
134 135 136
 * ----------------
 */
#ifdef EXEC_EVALDEBUG
137
#define EV_nodeDisplay(l)				nodeDisplay(l)
138 139
#define EV_printf(s)					printf(s)
#define EV1_printf(s, a)				printf(s, a)
140
#else
141 142 143
#define EV_nodeDisplay(l)
#define EV_printf(s)
#define EV1_printf(s, a)
144
#endif   /* EXEC_EVALDEBUG */
145 146

/* ----------------
147
 *		sort node debugging defines
148 149 150
 * ----------------
 */
#ifdef EXEC_SORTDEBUG
151
#define SO_nodeDisplay(l)				nodeDisplay(l)
152 153
#define SO_printf(s)					printf(s)
#define SO1_printf(s, p)				printf(s, p)
154
#else
155 156 157
#define SO_nodeDisplay(l)
#define SO_printf(s)
#define SO1_printf(s, p)
158
#endif   /* EXEC_SORTDEBUG */
159 160

/* ----------------
161
 *		merge join debugging defines
162 163 164
 * ----------------
 */
#ifdef EXEC_MERGEJOINDEBUG
165 166

#define MJ_nodeDisplay(l)				nodeDisplay(l)
167 168 169
#define MJ_printf(s)					printf(s)
#define MJ1_printf(s, p)				printf(s, p)
#define MJ2_printf(s, p1, p2)			printf(s, p1, p2)
170
#define MJ_debugtup(slot)				debugtup(slot, NULL)
171
#define MJ_dump(state)					ExecMergeTupleDump(state)
172 173
#define MJ_DEBUG_COMPARE(res) \
  MJ1_printf("  MJCompare() returns %d\n", (res))
174 175
#define MJ_DEBUG_QUAL(clause, res) \
  MJ2_printf("  ExecQual(%s, econtext) returns %s\n", \
176
			 CppAsString(clause), T_OR_F(res))
177
#define MJ_DEBUG_PROC_NODE(slot) \
178
  MJ2_printf("  %s = ExecProcNode(...) returns %s\n", \
179
			 CppAsString(slot), NULL_OR_TUPLE(slot))
180
#else
181

182
#define MJ_nodeDisplay(l)
183 184
#define MJ_printf(s)
#define MJ1_printf(s, p)
185
#define MJ2_printf(s, p1, p2)
186
#define MJ_debugtup(slot)
187
#define MJ_dump(state)
188
#define MJ_DEBUG_COMPARE(res)
189 190
#define MJ_DEBUG_QUAL(clause, res)
#define MJ_DEBUG_PROC_NODE(slot)
191
#endif   /* EXEC_MERGEJOINDEBUG */
192 193

/* ----------------------------------------------------------------
194
 *		DO NOT DEFINE THESE EVER OR YOU WILL BURN!
195 196 197
 * ----------------------------------------------------------------
 */
/* ----------------
198 199 200
 *		NOTYET is placed around any code not yet implemented
 *		in the executor.  Only remove these when actually implementing
 *		said code.
201 202 203 204
 * ----------------
 */
#undef NOTYET

205 206
extern long NDirectFileRead;
extern long NDirectFileWrite;
207

208
#endif   /* ExecDebugIncluded */