execdesc.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*-------------------------------------------------------------------------
  2. *
  3. * execdesc.h
  4. * plan and query descriptor accessor macros used by the executor
  5. * and related modules.
  6. *
  7. *
  8. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  9. * Portions Copyright (c) 1994, Regents of the University of California
  10. *
  11. * src/include/executor/execdesc.h
  12. *
  13. *-------------------------------------------------------------------------
  14. */
  15. #ifndef EXECDESC_H
  16. #define EXECDESC_H
  17. #include "nodes/execnodes.h"
  18. #include "tcop/dest.h"
  19. /* ----------------
  20. * query descriptor:
  21. *
  22. * a QueryDesc encapsulates everything that the executor
  23. * needs to execute the query.
  24. *
  25. * For the convenience of SQL-language functions, we also support QueryDescs
  26. * containing utility statements; these must not be passed to the executor
  27. * however.
  28. * ---------------------
  29. */
  30. typedef struct QueryDesc
  31. {
  32. /* These fields are provided by CreateQueryDesc */
  33. CmdType operation; /* CMD_SELECT, CMD_UPDATE, etc. */
  34. PlannedStmt *plannedstmt; /* planner's output (could be utility, too) */
  35. const char *sourceText; /* source text of the query */
  36. Snapshot snapshot; /* snapshot to use for query */
  37. Snapshot crosscheck_snapshot; /* crosscheck for RI update/delete */
  38. DestReceiver *dest; /* the destination for tuple output */
  39. ParamListInfo params; /* param values being passed in */
  40. QueryEnvironment *queryEnv; /* query environment passed in */
  41. int instrument_options; /* OR of InstrumentOption flags */
  42. /* These fields are set by ExecutorStart */
  43. TupleDesc tupDesc; /* descriptor for result tuples */
  44. EState *estate; /* executor's query-wide state */
  45. PlanState *planstate; /* tree of per-plan-node state */
  46. /* This field is set by ExecutorRun */
  47. bool already_executed; /* true if previously executed */
  48. /* This is always set NULL by the core system, but plugins can change it */
  49. struct Instrumentation *totaltime; /* total time spent in ExecutorRun */
  50. } QueryDesc;
  51. /* in pquery.c */
  52. extern QueryDesc *CreateQueryDesc(PlannedStmt *plannedstmt,
  53. const char *sourceText,
  54. Snapshot snapshot,
  55. Snapshot crosscheck_snapshot,
  56. DestReceiver *dest,
  57. ParamListInfo params,
  58. QueryEnvironment *queryEnv,
  59. int instrument_options);
  60. extern void FreeQueryDesc(QueryDesc *qdesc);
  61. #endif /* EXECDESC_H */