MCPcopy Create free account
hub / github.com/apache/cloudberry / CreateExprContextInternal

Function CreateExprContextInternal

src/backend/executor/execUtils.c:287–342  ·  view source on GitHub ↗

* Internal implementation for CreateExprContext() and CreateWorkExprContext() * that allows control over the AllocSet parameters. */

Source from the content-addressed store, hash-verified

285 * that allows control over the AllocSet parameters.
286 */
287static ExprContext *
288CreateExprContextInternal(EState *estate, Size minContextSize,
289 Size initBlockSize, Size maxBlockSize)
290{
291 ExprContext *econtext;
292 MemoryContext oldcontext;
293
294 /* Create the ExprContext node within the per-query memory context */
295 oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
296
297 econtext = makeNode(ExprContext);
298
299 /* Initialize fields of ExprContext */
300 econtext->ecxt_scantuple = NULL;
301 econtext->ecxt_innertuple = NULL;
302 econtext->ecxt_outertuple = NULL;
303
304 econtext->ecxt_per_query_memory = estate->es_query_cxt;
305
306 /*
307 * Create working memory for expression evaluation in this context.
308 */
309 econtext->ecxt_per_tuple_memory =
310 AllocSetContextCreate(estate->es_query_cxt,
311 "ExprContext",
312 minContextSize,
313 initBlockSize,
314 maxBlockSize);
315
316 econtext->ecxt_param_exec_vals = estate->es_param_exec_vals;
317 econtext->ecxt_param_list_info = estate->es_param_list_info;
318
319 econtext->ecxt_aggvalues = NULL;
320 econtext->ecxt_aggnulls = NULL;
321
322 econtext->caseValue_datum = (Datum) 0;
323 econtext->caseValue_isNull = true;
324
325 econtext->domainValue_datum = (Datum) 0;
326 econtext->domainValue_isNull = true;
327
328 econtext->ecxt_estate = estate;
329
330 econtext->ecxt_callbacks = NULL;
331
332 /*
333 * Link the ExprContext into the EState to ensure it is shut down when the
334 * EState is freed. Because we use lcons(), shutdowns will occur in
335 * reverse order of creation, which may not be essential but can't hurt.
336 */
337 estate->es_exprcontexts = lcons(econtext, estate->es_exprcontexts);
338
339 MemoryContextSwitchTo(oldcontext);
340
341 return econtext;
342}
343
344/* ----------------

Callers 2

CreateExprContextFunction · 0.85
CreateWorkExprContextFunction · 0.85

Calls 2

MemoryContextSwitchToFunction · 0.85
lconsFunction · 0.85

Tested by

no test coverage detected