* Main entrypoint for parallel workers. */
| 1297 | * Main entrypoint for parallel workers. |
| 1298 | */ |
| 1299 | void |
| 1300 | ParallelWorkerMain(Datum main_arg) |
| 1301 | { |
| 1302 | dsm_segment *seg; |
| 1303 | shm_toc *toc; |
| 1304 | FixedParallelState *fps; |
| 1305 | char *error_queue_space; |
| 1306 | shm_mq *mq; |
| 1307 | shm_mq_handle *mqh; |
| 1308 | char *libraryspace; |
| 1309 | char *entrypointstate; |
| 1310 | char *library_name; |
| 1311 | char *function_name; |
| 1312 | parallel_worker_main_type entrypt; |
| 1313 | char *gucspace; |
| 1314 | char *combocidspace; |
| 1315 | char *tsnapspace; |
| 1316 | char *asnapspace; |
| 1317 | char *tstatespace; |
| 1318 | char *pendingsyncsspace; |
| 1319 | char *reindexspace; |
| 1320 | char *relmapperspace; |
| 1321 | char *uncommittedenumsspace; |
| 1322 | StringInfoData msgbuf; |
| 1323 | char *session_dsm_handle_space; |
| 1324 | Snapshot tsnapshot; |
| 1325 | Snapshot asnapshot; |
| 1326 | |
| 1327 | /* Set flag to indicate that we're initializing a parallel worker. */ |
| 1328 | InitializingParallelWorker = true; |
| 1329 | |
| 1330 | /* Establish signal handlers. */ |
| 1331 | pqsignal(SIGTERM, die); |
| 1332 | BackgroundWorkerUnblockSignals(); |
| 1333 | |
| 1334 | /* Determine and set our parallel worker number. */ |
| 1335 | Assert(ParallelWorkerNumber == -1); |
| 1336 | memcpy(&ParallelWorkerNumber, MyBgworkerEntry->bgw_extra, sizeof(int)); |
| 1337 | |
| 1338 | /* Set up a memory context to work in, just for cleanliness. */ |
| 1339 | CurrentMemoryContext = AllocSetContextCreate(TopMemoryContext, |
| 1340 | "Parallel worker", |
| 1341 | ALLOCSET_DEFAULT_SIZES); |
| 1342 | |
| 1343 | /* |
| 1344 | * Attach to the dynamic shared memory segment for the parallel query, and |
| 1345 | * find its table of contents. |
| 1346 | * |
| 1347 | * Note: at this point, we have not created any ResourceOwner in this |
| 1348 | * process. This will result in our DSM mapping surviving until process |
| 1349 | * exit, which is fine. If there were a ResourceOwner, it would acquire |
| 1350 | * ownership of the mapping, but we have no need for that. |
| 1351 | */ |
| 1352 | seg = dsm_attach(DatumGetUInt32(main_arg)); |
| 1353 | if (seg == NULL) |
| 1354 | ereport(ERROR, |
| 1355 | (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), |
| 1356 | errmsg("could not map dynamic shared memory segment"))); |
nothing calls this directly
no test coverage detected