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