---------------- * CreateExecutorState * * Create and initialize an EState node, which is the root of * working storage for an entire Executor invocation. * * Principally, this creates the per-query memory context that will be * used to hold all working data that lives till the end of the query. * Note that the per-query context will become a child of the caller's * CurrentMemoryContex
| 121 | * ---------------- |
| 122 | */ |
| 123 | EState * |
| 124 | CreateExecutorState(void) |
| 125 | { |
| 126 | EState *estate; |
| 127 | MemoryContext qcontext; |
| 128 | MemoryContext oldcontext; |
| 129 | |
| 130 | /* |
| 131 | * Create the per-query context for this Executor run. |
| 132 | */ |
| 133 | qcontext = AllocSetContextCreate(CurrentMemoryContext, |
| 134 | "ExecutorState", |
| 135 | ALLOCSET_DEFAULT_SIZES); |
| 136 | MemoryContextDeclareAccountingRoot(qcontext); |
| 137 | |
| 138 | /* |
| 139 | * Make the EState node within the per-query context. This way, we don't |
| 140 | * need a separate pfree() operation for it at shutdown. |
| 141 | */ |
| 142 | oldcontext = MemoryContextSwitchTo(qcontext); |
| 143 | |
| 144 | estate = makeNode(EState); |
| 145 | |
| 146 | /* |
| 147 | * Initialize all fields of the Executor State structure |
| 148 | */ |
| 149 | estate->es_direction = ForwardScanDirection; |
| 150 | estate->es_snapshot = InvalidSnapshot; /* caller must initialize this */ |
| 151 | estate->es_crosscheck_snapshot = InvalidSnapshot; /* no crosscheck */ |
| 152 | estate->es_range_table = NIL; |
| 153 | estate->es_range_table_size = 0; |
| 154 | estate->es_relations = NULL; |
| 155 | estate->es_rowmarks = NULL; |
| 156 | estate->es_plannedstmt = NULL; |
| 157 | |
| 158 | estate->es_junkFilter = NULL; |
| 159 | |
| 160 | estate->es_output_cid = (CommandId) 0; |
| 161 | |
| 162 | estate->es_result_relations = NULL; |
| 163 | estate->es_opened_result_relations = NIL; |
| 164 | estate->es_tuple_routing_result_relations = NIL; |
| 165 | estate->es_trig_target_relations = NIL; |
| 166 | |
| 167 | estate->es_param_list_info = NULL; |
| 168 | estate->es_param_exec_vals = NULL; |
| 169 | |
| 170 | estate->es_queryEnv = NULL; |
| 171 | |
| 172 | estate->es_query_cxt = qcontext; |
| 173 | |
| 174 | estate->es_tupleTable = NIL; |
| 175 | |
| 176 | estate->es_processed = 0; |
| 177 | |
| 178 | estate->es_top_eflags = 0; |
| 179 | estate->es_instrument = 0; |
| 180 | estate->es_finished = false; |