explain.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*-------------------------------------------------------------------------
  2. *
  3. * explain.h
  4. * prototypes for explain.c
  5. *
  6. * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
  7. * Portions Copyright (c) 1994-5, Regents of the University of California
  8. *
  9. * src/include/commands/explain.h
  10. *
  11. *-------------------------------------------------------------------------
  12. */
  13. #ifndef EXPLAIN_H
  14. #define EXPLAIN_H
  15. #include "executor/executor.h"
  16. #include "lib/stringinfo.h"
  17. typedef enum ExplainFormat
  18. {
  19. EXPLAIN_FORMAT_TEXT,
  20. EXPLAIN_FORMAT_XML,
  21. EXPLAIN_FORMAT_JSON,
  22. EXPLAIN_FORMAT_YAML
  23. } ExplainFormat;
  24. typedef struct ExplainState
  25. {
  26. StringInfo str; /* output buffer */
  27. /* options */
  28. bool verbose; /* be verbose */
  29. bool analyze; /* print actual times */
  30. bool costs; /* print estimated costs */
  31. bool buffers; /* print buffer usage */
  32. bool timing; /* print detailed node timing */
  33. bool summary; /* print total planning and execution timing */
  34. ExplainFormat format; /* output format */
  35. /* state for output formatting --- not reset for each new plan tree */
  36. int indent; /* current indentation level */
  37. List *grouping_stack; /* format-specific grouping state */
  38. /* state related to the current plan tree (filled by ExplainPrintPlan) */
  39. PlannedStmt *pstmt; /* top of plan */
  40. List *rtable; /* range table */
  41. List *rtable_names; /* alias names for RTEs */
  42. List *deparse_cxt; /* context list for deparsing expressions */
  43. Bitmapset *printed_subplans; /* ids of SubPlans we've printed */
  44. } ExplainState;
  45. /* Hook for plugins to get control in ExplainOneQuery() */
  46. typedef void (*ExplainOneQuery_hook_type) (Query *query,
  47. IntoClause *into,
  48. ExplainState *es,
  49. const char *queryString,
  50. ParamListInfo params);
  51. extern PGDLLIMPORT ExplainOneQuery_hook_type ExplainOneQuery_hook;
  52. /* Hook for plugins to get control in explain_get_index_name() */
  53. typedef const char *(*explain_get_index_name_hook_type) (Oid indexId);
  54. extern PGDLLIMPORT explain_get_index_name_hook_type explain_get_index_name_hook;
  55. extern void ExplainQuery(ExplainStmt *stmt, const char *queryString,
  56. ParamListInfo params, DestReceiver *dest);
  57. extern ExplainState *NewExplainState(void);
  58. extern TupleDesc ExplainResultDesc(ExplainStmt *stmt);
  59. extern void ExplainOneUtility(Node *utilityStmt, IntoClause *into,
  60. ExplainState *es,
  61. const char *queryString, ParamListInfo params);
  62. extern void ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into,
  63. ExplainState *es, const char *queryString,
  64. ParamListInfo params, const instr_time *planduration);
  65. extern void ExplainPrintPlan(ExplainState *es, QueryDesc *queryDesc);
  66. extern void ExplainPrintTriggers(ExplainState *es, QueryDesc *queryDesc);
  67. extern void ExplainQueryText(ExplainState *es, QueryDesc *queryDesc);
  68. extern void ExplainBeginOutput(ExplainState *es);
  69. extern void ExplainEndOutput(ExplainState *es);
  70. extern void ExplainSeparatePlans(ExplainState *es);
  71. extern void ExplainPropertyList(const char *qlabel, List *data,
  72. ExplainState *es);
  73. extern void ExplainPropertyListNested(const char *qlabel, List *data,
  74. ExplainState *es);
  75. extern void ExplainPropertyText(const char *qlabel, const char *value,
  76. ExplainState *es);
  77. extern void ExplainPropertyInteger(const char *qlabel, int value,
  78. ExplainState *es);
  79. extern void ExplainPropertyLong(const char *qlabel, long value,
  80. ExplainState *es);
  81. extern void ExplainPropertyFloat(const char *qlabel, double value, int ndigits,
  82. ExplainState *es);
  83. extern void ExplainPropertyBool(const char *qlabel, bool value,
  84. ExplainState *es);
  85. #endif /* EXPLAIN_H */