Add missing PGDLLEXPORT markings in contrib/pg_prewarm.
authorTom Lane <[email protected]>
Wed, 27 Jul 2022 16:00:10 +0000 (12:00 -0400)
committerTom Lane <[email protected]>
Wed, 27 Jul 2022 16:00:10 +0000 (12:00 -0400)
After commit 089480c07, it's necessary for background worker entry
points to be marked PGDLLEXPORT, else they aren't findable by
LookupBackgroundWorkerFunction().  Since pg_prewarm lacks any
regression tests, it's not surprising its worker entry points were
overlooked.  (A quick search turned up no other such oversights.)

I added some documentation pointing out the need for this, too.

Robins Tharakan and Tom Lane

CAEP4nAzndnQv3-1QKb=D-hLoK3Rko12HHMFHHtdj2GQAUXO3gw@mail.gmail.com

contrib/pg_prewarm/autoprewarm.c
doc/src/sgml/bgworker.sgml

index b2d602609343ae60d09ffd6ed03f0cc1be4f701e..d9ab39dd900517f062feb567beb2a30f6df99f76 100644 (file)
@@ -82,8 +82,8 @@ typedef struct AutoPrewarmSharedState
    int         prewarmed_blocks;
 } AutoPrewarmSharedState;
 
-void       autoprewarm_main(Datum main_arg);
-void       autoprewarm_database_main(Datum main_arg);
+PGDLLEXPORT void autoprewarm_main(Datum main_arg);
+PGDLLEXPORT void autoprewarm_database_main(Datum main_arg);
 
 PG_FUNCTION_INFO_V1(autoprewarm_start_worker);
 PG_FUNCTION_INFO_V1(autoprewarm_dump_now);
index 73207f72fe17650f0c8f757106199974144ef438..3d4e4afcf9192018da73ac27681b748e3bd9b303 100644 (file)
@@ -141,14 +141,15 @@ typedef struct BackgroundWorker
    which the initial entry point for the background worker should be sought.
    The named library will be dynamically loaded by the worker process and
    <structfield>bgw_function_name</structfield> will be used to identify the
-   function to be called.  If loading a function from the core code, this must
-   be set to "postgres".
+   function to be called.  If calling a function in the core code, this must
+   be set to <literal>"postgres"</literal>.
   </para>
 
   <para>
-   <structfield>bgw_function_name</structfield> is the name of a function in
-   a dynamically loaded library which should be used as the initial entry point
-   for a new background worker.
+   <structfield>bgw_function_name</structfield> is the name of the function
+   to use as the initial entry point for the new background worker.  If
+   this function is in a dynamically loaded library, it must be marked
+   <literal>PGDLLEXPORT</literal> (and not <literal>static</literal>).
   </para>
 
   <para>