|
78 | 78 | #define PARALLEL_KEY_UNCOMMITTEDENUMS UINT64CONST(0xFFFFFFFFFFFF000E)
|
79 | 79 | #define PARALLEL_KEY_CLIENTCONNINFO UINT64CONST(0xFFFFFFFFFFFF000F)
|
80 | 80 |
|
| 81 | +/* Hooks for communicating babelfish related information to parallel worker */ |
| 82 | +bbf_InitializeParallelDSM_hook_type bbf_InitializeParallelDSM_hook = NULL; |
| 83 | +bbf_ParallelWorkerMain_hook_type bbf_ParallelWorkerMain_hook = NULL; |
| 84 | + |
81 | 85 | /* Fixed-size parallel state. */
|
82 | 86 | typedef struct FixedParallelState
|
83 | 87 | {
|
@@ -295,6 +299,10 @@ InitializeParallelDSM(ParallelContext *pcxt)
|
295 | 299 | shm_toc_estimate_chunk(&pcxt->estimator, strlen(pcxt->library_name) +
|
296 | 300 | strlen(pcxt->function_name) + 2);
|
297 | 301 | shm_toc_estimate_keys(&pcxt->estimator, 1);
|
| 302 | + |
| 303 | + /* Estimate how much we'll need for the babelfish fixed parallel state */ |
| 304 | + if (MyProcPort->is_tds_conn && bbf_InitializeParallelDSM_hook) |
| 305 | + (*bbf_InitializeParallelDSM_hook) (pcxt, true); |
298 | 306 | }
|
299 | 307 |
|
300 | 308 | /*
|
@@ -476,6 +484,10 @@ InitializeParallelDSM(ParallelContext *pcxt)
|
476 | 484 | strcpy(entrypointstate, pcxt->library_name);
|
477 | 485 | strcpy(entrypointstate + lnamelen + 1, pcxt->function_name);
|
478 | 486 | shm_toc_insert(pcxt->toc, PARALLEL_KEY_ENTRYPOINT, entrypointstate);
|
| 487 | + |
| 488 | + /* Initialize babelfish fixed-size state in shared memory. */ |
| 489 | + if (MyProcPort->is_tds_conn && bbf_InitializeParallelDSM_hook) |
| 490 | + (*bbf_InitializeParallelDSM_hook) (pcxt, false); |
479 | 491 | }
|
480 | 492 |
|
481 | 493 | /* Restore previous memory context. */
|
@@ -1508,6 +1520,10 @@ ParallelWorkerMain(Datum main_arg)
|
1508 | 1520 | InitializeSystemUser(MyClientConnectionInfo.authn_id,
|
1509 | 1521 | hba_authname(MyClientConnectionInfo.auth_method));
|
1510 | 1522 |
|
| 1523 | + /* Hook for babelfish to restore babelfish fixed parallel state */ |
| 1524 | + if (MyFixedParallelState->babelfish_context && bbf_ParallelWorkerMain_hook) |
| 1525 | + (*bbf_ParallelWorkerMain_hook) (toc); |
| 1526 | + |
1511 | 1527 | /* Attach to the leader's serializable transaction, if SERIALIZABLE. */
|
1512 | 1528 | AttachSerializableXact(fps->serializable_xact_handle);
|
1513 | 1529 |
|
|
0 commit comments