execdebug.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*-------------------------------------------------------------------------
  2. *
  3. * execdebug.h
  4. * #defines governing debugging behaviour in the executor
  5. *
  6. * XXX this is all pretty old and crufty. Newer code tends to use elog()
  7. * for debug printouts, because that's more flexible than printf().
  8. *
  9. *
  10. * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
  11. * Portions Copyright (c) 1994, Regents of the University of California
  12. *
  13. * src/include/executor/execdebug.h
  14. *
  15. *-------------------------------------------------------------------------
  16. */
  17. #ifndef EXECDEBUG_H
  18. #define EXECDEBUG_H
  19. #include "executor/executor.h"
  20. #include "nodes/print.h"
  21. /* ----------------------------------------------------------------
  22. * debugging defines.
  23. *
  24. * If you want certain debugging behaviour, then #define
  25. * the variable to 1. No need to explicitly #undef by default,
  26. * since we can use -D compiler options to enable features.
  27. * - thomas 1999-02-20
  28. * ----------------------------------------------------------------
  29. */
  30. /* ----------------
  31. * EXEC_NESTLOOPDEBUG is a flag which turns on debugging of the
  32. * nest loop node by NL_printf() and ENL_printf() in nodeNestloop.c
  33. * ----------------
  34. #undef EXEC_NESTLOOPDEBUG
  35. */
  36. /* ----------------
  37. * EXEC_EVALDEBUG is a flag which turns on debugging of
  38. * ExecEval and ExecTargetList() stuff by EV_printf() in execQual.c
  39. * ----------------
  40. #undef EXEC_EVALDEBUG
  41. */
  42. /* ----------------
  43. * EXEC_SORTDEBUG is a flag which turns on debugging of
  44. * the ExecSort() stuff by SO_printf() in nodeSort.c
  45. * ----------------
  46. #undef EXEC_SORTDEBUG
  47. */
  48. /* ----------------
  49. * EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
  50. * the ExecMergeJoin() stuff by MJ_printf() in nodeMergejoin.c
  51. * ----------------
  52. #undef EXEC_MERGEJOINDEBUG
  53. */
  54. /* ----------------------------------------------------------------
  55. * #defines controlled by above definitions
  56. *
  57. * Note: most of these are "incomplete" because I didn't
  58. * need the ones not defined. More should be added
  59. * only as necessary -cim 10/26/89
  60. * ----------------------------------------------------------------
  61. */
  62. #define T_OR_F(b) ((b) ? "true" : "false")
  63. #define NULL_OR_TUPLE(slot) (TupIsNull(slot) ? "null" : "a tuple")
  64. /* ----------------
  65. * nest loop debugging defines
  66. * ----------------
  67. */
  68. #ifdef EXEC_NESTLOOPDEBUG
  69. #define NL_nodeDisplay(l) nodeDisplay(l)
  70. #define NL_printf(s) printf(s)
  71. #define NL1_printf(s, a) printf(s, a)
  72. #define ENL1_printf(message) printf("ExecNestLoop: %s\n", message)
  73. #else
  74. #define NL_nodeDisplay(l)
  75. #define NL_printf(s)
  76. #define NL1_printf(s, a)
  77. #define ENL1_printf(message)
  78. #endif /* EXEC_NESTLOOPDEBUG */
  79. /* ----------------
  80. * exec eval / target list debugging defines
  81. * ----------------
  82. */
  83. #ifdef EXEC_EVALDEBUG
  84. #define EV_nodeDisplay(l) nodeDisplay(l)
  85. #define EV_printf(s) printf(s)
  86. #define EV1_printf(s, a) printf(s, a)
  87. #else
  88. #define EV_nodeDisplay(l)
  89. #define EV_printf(s)
  90. #define EV1_printf(s, a)
  91. #endif /* EXEC_EVALDEBUG */
  92. /* ----------------
  93. * sort node debugging defines
  94. * ----------------
  95. */
  96. #ifdef EXEC_SORTDEBUG
  97. #define SO_nodeDisplay(l) nodeDisplay(l)
  98. #define SO_printf(s) printf(s)
  99. #define SO1_printf(s, p) printf(s, p)
  100. #else
  101. #define SO_nodeDisplay(l)
  102. #define SO_printf(s)
  103. #define SO1_printf(s, p)
  104. #endif /* EXEC_SORTDEBUG */
  105. /* ----------------
  106. * merge join debugging defines
  107. * ----------------
  108. */
  109. #ifdef EXEC_MERGEJOINDEBUG
  110. #define MJ_nodeDisplay(l) nodeDisplay(l)
  111. #define MJ_printf(s) printf(s)
  112. #define MJ1_printf(s, p) printf(s, p)
  113. #define MJ2_printf(s, p1, p2) printf(s, p1, p2)
  114. #define MJ_debugtup(slot) debugtup(slot, NULL)
  115. #define MJ_dump(state) ExecMergeTupleDump(state)
  116. #define MJ_DEBUG_COMPARE(res) \
  117. MJ1_printf(" MJCompare() returns %d\n", (res))
  118. #define MJ_DEBUG_QUAL(clause, res) \
  119. MJ2_printf(" ExecQual(%s, econtext) returns %s\n", \
  120. CppAsString(clause), T_OR_F(res))
  121. #define MJ_DEBUG_PROC_NODE(slot) \
  122. MJ2_printf(" %s = ExecProcNode(...) returns %s\n", \
  123. CppAsString(slot), NULL_OR_TUPLE(slot))
  124. #else
  125. #define MJ_nodeDisplay(l)
  126. #define MJ_printf(s)
  127. #define MJ1_printf(s, p)
  128. #define MJ2_printf(s, p1, p2)
  129. #define MJ_debugtup(slot)
  130. #define MJ_dump(state)
  131. #define MJ_DEBUG_COMPARE(res)
  132. #define MJ_DEBUG_QUAL(clause, res)
  133. #define MJ_DEBUG_PROC_NODE(slot)
  134. #endif /* EXEC_MERGEJOINDEBUG */
  135. #endif /* ExecDebugIncluded */