execdesc.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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-2016, 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, or null if utility */
  35. Node *utilitystmt; /* utility statement, or null */
  36. const char *sourceText; /* source text of the query */
  37. Snapshot snapshot; /* snapshot to use for query */
  38. Snapshot crosscheck_snapshot; /* crosscheck for RI update/delete */
  39. DestReceiver *dest; /* the destination for tuple output */
  40. ParamListInfo params; /* param values being 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 is always set NULL by the core system, but plugins can change it */
  47. struct Instrumentation *totaltime; /* total time spent in ExecutorRun */
  48. } QueryDesc;
  49. /* in pquery.c */
  50. extern QueryDesc *CreateQueryDesc(PlannedStmt *plannedstmt,
  51. const char *sourceText,
  52. Snapshot snapshot,
  53. Snapshot crosscheck_snapshot,
  54. DestReceiver *dest,
  55. ParamListInfo params,
  56. int instrument_options);
  57. extern QueryDesc *CreateUtilityQueryDesc(Node *utilitystmt,
  58. const char *sourceText,
  59. Snapshot snapshot,
  60. DestReceiver *dest,
  61. ParamListInfo params);
  62. extern void FreeQueryDesc(QueryDesc *qdesc);
  63. #endif /* EXECDESC_H */