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

Function init_tuplestore_state

src/backend/executor/nodeShareInputScan.c:205–338  ·  view source on GitHub ↗

* init_tuplestore_state * Initialize the tuplestore state for the Shared node if the state * is not initialized. */

Source from the content-addressed store, hash-verified

203 * is not initialized.
204 */
205static void
206init_tuplestore_state(ShareInputScanState *node)
207{
208 EState *estate = node->ss.ps.state;
209 ShareInputScan *sisc = (ShareInputScan *) node->ss.ps.plan;
210 shareinput_local_state *local_state = node->local_state;
211 Tuplestorestate *ts;
212 int tsptrno;
213 TupleTableSlot *outerslot;
214
215 Assert(!node->isready);
216 Assert(node->ts_state == NULL);
217 Assert(node->ts_pos == -1);
218
219 if (sisc->cross_slice)
220 {
221 if (!node->ref)
222 elog(ERROR, "cannot execute ShareInputScan that was not initialized");
223 }
224
225 if (!local_state->ready)
226 {
227 if (currentSliceId == sisc->producer_slice_id || estate->es_plannedstmt->numSlices == 1)
228 {
229 /* We are the producer */
230 if (sisc->cross_slice)
231 {
232 char rwfile_prefix[100];
233
234 elog((Debug_shareinput_xslice ? LOG : DEBUG1), "SISC WRITER (shareid=%d, slice=%d): No tuplestore yet, creating tuplestore",
235 sisc->share_id, currentSliceId);
236
237 ts = tuplestore_begin_heap(true, /* randomAccess */
238 false, /* interXact */
239 10); /* maxKBytes FIXME */
240
241 shareinput_create_bufname_prefix(rwfile_prefix, sizeof(rwfile_prefix), sisc->share_id);
242 tuplestore_make_shared(ts,
243 get_shareinput_fileset(),
244 rwfile_prefix);
245#ifdef FAULT_INJECTOR
246 if (SIMPLE_FAULT_INJECTOR("sisc_xslice_temp_files") == FaultInjectorTypeSkip)
247 {
248 const char *filename = tuplestore_get_buffilename(ts);
249 if (!filename)
250 ereport(NOTICE, (errmsg("sisc_xslice: buffilename is null")));
251 else if (strstr(filename, "base/" PG_TEMP_FILES_DIR) == filename)
252 ereport(NOTICE, (errmsg("sisc_xslice: Use default tablespace")));
253 else if (strstr(filename, "pg_tblspc/") == filename)
254 ereport(NOTICE, (errmsg("sisc_xslice: Use temp tablespace")));
255 else
256 ereport(NOTICE, (errmsg("sisc_xslice: Unexpected prefix of the tablespace path")));
257 }
258#endif
259 }
260 else
261 {
262 /* intra-slice */

Callers 4

ExecShareInputScanFunction · 0.85
ExecEndShareInputScanFunction · 0.85
ExecReScanShareInputScanFunction · 0.85

Calls 15

tuplestore_begin_heapFunction · 0.85
tuplestore_make_sharedFunction · 0.85
get_shareinput_filesetFunction · 0.85
PlanStateOperatorMemKBFunction · 0.85
ExecProcNodeFunction · 0.85
tuplestore_puttupleslotFunction · 0.85
tuplestore_freezeFunction · 0.85
tuplestore_rescanFunction · 0.85

Tested by

no test coverage detected