2
0

execdebug.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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-2022, 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_SORTDEBUG is a flag which turns on debugging of
  38. * the ExecSort() stuff by SO_printf() in nodeSort.c
  39. * ----------------
  40. #undef EXEC_SORTDEBUG
  41. */
  42. /* ----------------
  43. * EXEC_MERGEJOINDEBUG is a flag which turns on debugging of
  44. * the ExecMergeJoin() stuff by MJ_printf() in nodeMergejoin.c
  45. * ----------------
  46. #undef EXEC_MERGEJOINDEBUG
  47. */
  48. /* ----------------------------------------------------------------
  49. * #defines controlled by above definitions
  50. *
  51. * Note: most of these are "incomplete" because I didn't
  52. * need the ones not defined. More should be added
  53. * only as necessary -cim 10/26/89
  54. * ----------------------------------------------------------------
  55. */
  56. #define T_OR_F(b) ((b) ? "true" : "false")
  57. #define NULL_OR_TUPLE(slot) (TupIsNull(slot) ? "null" : "a tuple")
  58. /* ----------------
  59. * nest loop debugging defines
  60. * ----------------
  61. */
  62. #ifdef EXEC_NESTLOOPDEBUG
  63. #define NL_nodeDisplay(l) nodeDisplay(l)
  64. #define NL_printf(s) printf(s)
  65. #define NL1_printf(s, a) printf(s, a)
  66. #define ENL1_printf(message) printf("ExecNestLoop: %s\n", message)
  67. #else
  68. #define NL_nodeDisplay(l)
  69. #define NL_printf(s)
  70. #define NL1_printf(s, a)
  71. #define ENL1_printf(message)
  72. #endif /* EXEC_NESTLOOPDEBUG */
  73. /* ----------------
  74. * sort node debugging defines
  75. * ----------------
  76. */
  77. #ifdef EXEC_SORTDEBUG
  78. #define SO_nodeDisplay(l) nodeDisplay(l)
  79. #define SO_printf(s) printf(s)
  80. #define SO1_printf(s, p) printf(s, p)
  81. #define SO2_printf(s, p1, p2) printf(s, p1, p2)
  82. #else
  83. #define SO_nodeDisplay(l)
  84. #define SO_printf(s)
  85. #define SO1_printf(s, p)
  86. #define SO2_printf(s, p1, p2)
  87. #endif /* EXEC_SORTDEBUG */
  88. /* ----------------
  89. * merge join debugging defines
  90. * ----------------
  91. */
  92. #ifdef EXEC_MERGEJOINDEBUG
  93. #define MJ_nodeDisplay(l) nodeDisplay(l)
  94. #define MJ_printf(s) printf(s)
  95. #define MJ1_printf(s, p) printf(s, p)
  96. #define MJ2_printf(s, p1, p2) printf(s, p1, p2)
  97. #define MJ_debugtup(slot) debugtup(slot, NULL)
  98. #define MJ_dump(state) ExecMergeTupleDump(state)
  99. #define MJ_DEBUG_COMPARE(res) \
  100. MJ1_printf(" MJCompare() returns %d\n", (res))
  101. #define MJ_DEBUG_QUAL(clause, res) \
  102. MJ2_printf(" ExecQual(%s, econtext) returns %s\n", \
  103. CppAsString(clause), T_OR_F(res))
  104. #define MJ_DEBUG_PROC_NODE(slot) \
  105. MJ2_printf(" %s = ExecProcNode(...) returns %s\n", \
  106. CppAsString(slot), NULL_OR_TUPLE(slot))
  107. #else
  108. #define MJ_nodeDisplay(l)
  109. #define MJ_printf(s)
  110. #define MJ1_printf(s, p)
  111. #define MJ2_printf(s, p1, p2)
  112. #define MJ_debugtup(slot)
  113. #define MJ_dump(state)
  114. #define MJ_DEBUG_COMPARE(res)
  115. #define MJ_DEBUG_QUAL(clause, res)
  116. #define MJ_DEBUG_PROC_NODE(slot)
  117. #endif /* EXEC_MERGEJOINDEBUG */
  118. #endif /* EXECDEBUG_H */