@@ -47,15 +47,19 @@ PG_FUNCTION_INFO_V1( show_concurrent_part_tasks_internal );
47
47
PG_FUNCTION_INFO_V1 ( stop_concurrent_part_task );
48
48
49
49
50
+ /*
51
+ * Dynamically resolve functions (for BGW API).
52
+ */
53
+ extern PGDLLEXPORT void bgw_main_spawn_partitions (Datum main_arg );
54
+ extern PGDLLEXPORT void bgw_main_concurrent_part (Datum main_arg );
55
+
56
+
50
57
static void handle_sigterm (SIGNAL_ARGS );
51
58
static void bg_worker_load_config (const char * bgw_name );
52
59
static void start_bg_worker (const char bgworker_name [BGW_MAXLEN ],
53
- bgworker_main_type bgw_main_func ,
60
+ const char bgworker_proc [ BGW_MAXLEN ] ,
54
61
Datum bgw_arg , bool wait_for_shutdown );
55
62
56
- static void bgw_main_spawn_partitions (Datum main_arg );
57
- static void bgw_main_concurrent_part (Datum main_arg );
58
-
59
63
60
64
/*
61
65
* Function context for concurrent_part_tasks_internal() SRF.
@@ -157,7 +161,7 @@ bg_worker_load_config(const char *bgw_name)
157
161
*/
158
162
static void
159
163
start_bg_worker (const char bgworker_name [BGW_MAXLEN ],
160
- bgworker_main_type bgw_main_func ,
164
+ const char bgworker_proc [ BGW_MAXLEN ] ,
161
165
Datum bgw_arg , bool wait_for_shutdown )
162
166
{
163
167
#define HandleError (condition , new_state ) \
@@ -179,12 +183,16 @@ start_bg_worker(const char bgworker_name[BGW_MAXLEN],
179
183
180
184
/* Initialize worker struct */
181
185
memcpy (worker .bgw_name , bgworker_name , BGW_MAXLEN );
182
- worker .bgw_flags = BGWORKER_SHMEM_ACCESS | BGWORKER_BACKEND_DATABASE_CONNECTION ;
183
- worker .bgw_start_time = BgWorkerStart_RecoveryFinished ;
184
- worker .bgw_restart_time = BGW_NEVER_RESTART ;
185
- worker .bgw_main = bgw_main_func ;
186
- worker .bgw_main_arg = bgw_arg ;
187
- worker .bgw_notify_pid = MyProcPid ;
186
+ memcpy (worker .bgw_function_name , bgworker_proc , BGW_MAXLEN );
187
+ memcpy (worker .bgw_library_name , "pg_pathman" , BGW_MAXLEN );
188
+
189
+ worker .bgw_flags = BGWORKER_SHMEM_ACCESS |
190
+ BGWORKER_BACKEND_DATABASE_CONNECTION ;
191
+ worker .bgw_start_time = BgWorkerStart_RecoveryFinished ;
192
+ worker .bgw_restart_time = BGW_NEVER_RESTART ;
193
+ worker .bgw_main = NULL ;
194
+ worker .bgw_main_arg = bgw_arg ;
195
+ worker .bgw_notify_pid = MyProcPid ;
188
196
189
197
/* Start dynamic worker */
190
198
bgw_started = RegisterDynamicBackgroundWorker (& worker , & bgw_handle );
@@ -301,7 +309,7 @@ create_partitions_for_value_bg_worker(Oid relid, Datum value, Oid value_type)
301
309
302
310
/* Start worker and wait for it to finish */
303
311
start_bg_worker (spawn_partitions_bgw ,
304
- bgw_main_spawn_partitions ,
312
+ CppAsString ( bgw_main_spawn_partitions ) ,
305
313
UInt32GetDatum (segment_handle ),
306
314
true);
307
315
@@ -323,7 +331,7 @@ create_partitions_for_value_bg_worker(Oid relid, Datum value, Oid value_type)
323
331
/*
324
332
* Entry point for SpawnPartitionsWorker's process.
325
333
*/
326
- static void
334
+ void
327
335
bgw_main_spawn_partitions (Datum main_arg )
328
336
{
329
337
dsm_handle handle = DatumGetUInt32 (main_arg );
@@ -403,7 +411,7 @@ bgw_main_spawn_partitions(Datum main_arg)
403
411
/*
404
412
* Entry point for ConcurrentPartWorker's process.
405
413
*/
406
- static void
414
+ void
407
415
bgw_main_concurrent_part (Datum main_arg )
408
416
{
409
417
int rows ;
@@ -671,7 +679,7 @@ partition_table_concurrently(PG_FUNCTION_ARGS)
671
679
672
680
/* Start worker (we should not wait) */
673
681
start_bg_worker (concurrent_part_bgw ,
674
- bgw_main_concurrent_part ,
682
+ CppAsString ( bgw_main_concurrent_part ) ,
675
683
Int32GetDatum (empty_slot_idx ),
676
684
false);
677
685
0 commit comments