* Main entrypoint for parallel query worker processes. * * We reach this function from ParallelWorkerMain, so the setup necessary to * create a sensible parallel environment has already been done; * ParallelWorkerMain worries about stuff like the transaction state, combo * CID mappings, and GUC values, so we don't need to deal with any of that * here. * * Our job is to deal with concerns s
| 1394 | * the shm_toc. |
| 1395 | */ |
| 1396 | void |
| 1397 | ParallelQueryMain(dsm_segment *seg, shm_toc *toc) |
| 1398 | { |
| 1399 | FixedParallelExecutorState *fpes; |
| 1400 | BufferUsage *buffer_usage; |
| 1401 | WalUsage *wal_usage; |
| 1402 | DestReceiver *receiver; |
| 1403 | QueryDesc *queryDesc; |
| 1404 | SharedExecutorInstrumentation *instrumentation; |
| 1405 | SharedJitInstrumentation *jit_instrumentation; |
| 1406 | int instrument_options = 0; |
| 1407 | void *area_space; |
| 1408 | dsa_area *area; |
| 1409 | ParallelWorkerContext pwcxt; |
| 1410 | |
| 1411 | /* Get fixed-size state. */ |
| 1412 | fpes = shm_toc_lookup(toc, PARALLEL_KEY_EXECUTOR_FIXED, false); |
| 1413 | |
| 1414 | /* Set up DestReceiver, SharedExecutorInstrumentation, and QueryDesc. */ |
| 1415 | receiver = ExecParallelGetReceiver(seg, toc); |
| 1416 | instrumentation = shm_toc_lookup(toc, PARALLEL_KEY_INSTRUMENTATION, true); |
| 1417 | if (instrumentation != NULL) |
| 1418 | instrument_options = instrumentation->instrument_options; |
| 1419 | jit_instrumentation = shm_toc_lookup(toc, PARALLEL_KEY_JIT_INSTRUMENTATION, |
| 1420 | true); |
| 1421 | queryDesc = ExecParallelGetQueryDesc(toc, receiver, instrument_options); |
| 1422 | |
| 1423 | /* Setting debug_query_string for individual workers */ |
| 1424 | debug_query_string = queryDesc->sourceText; |
| 1425 | |
| 1426 | /* Report workers' query and queryId for monitoring purposes */ |
| 1427 | pgstat_report_activity(STATE_RUNNING, debug_query_string); |
| 1428 | |
| 1429 | /* Attach to the dynamic shared memory area. */ |
| 1430 | area_space = shm_toc_lookup(toc, PARALLEL_KEY_DSA, false); |
| 1431 | area = dsa_attach_in_place(area_space, seg); |
| 1432 | |
| 1433 | /* Start up the executor */ |
| 1434 | queryDesc->plannedstmt->jitFlags = fpes->jit_flags; |
| 1435 | ExecutorStart(queryDesc, fpes->eflags); |
| 1436 | |
| 1437 | /* Special executor initialization steps for parallel workers */ |
| 1438 | queryDesc->planstate->state->es_query_dsa = area; |
| 1439 | if (DsaPointerIsValid(fpes->param_exec)) |
| 1440 | { |
| 1441 | char *paramexec_space; |
| 1442 | |
| 1443 | paramexec_space = dsa_get_address(area, fpes->param_exec); |
| 1444 | RestoreParamExecParams(paramexec_space, queryDesc->estate); |
| 1445 | |
| 1446 | } |
| 1447 | pwcxt.toc = toc; |
| 1448 | pwcxt.seg = seg; |
| 1449 | ExecParallelInitializeWorker(queryDesc->planstate, &pwcxt); |
| 1450 | |
| 1451 | /* Pass down any tuple bound */ |
| 1452 | ExecSetTupleBound(fpes->tuples_needed, queryDesc->planstate); |
| 1453 |
nothing calls this directly
no test coverage detected