* init_tuplestore_state * Initialize the tuplestore state for the Shared node if the state * is not initialized. */
| 203 | * is not initialized. |
| 204 | */ |
| 205 | static void |
| 206 | init_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 */ |
no test coverage detected