Re: Plugins redux (was Re: [PATCHES] PL instrumentation - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: Plugins redux (was Re: [PATCHES] PL instrumentation
Date
Msg-id 1155147458.12968.147.camel@dogma.v10.wvs
Whole thread Raw
In response to Plugins redux (was Re: [PATCHES] PL instrumentation plugin support)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Plugins redux (was Re: [PATCHES] PL instrumentation plugin support)
List pgsql-hackers
On Wed, 2006-08-09 at 12:44 -0400, Tom Lane wrote:
> A plugin such as a plpgsql debugger would do this in its _PG_init()
> function:
> 
>     static PLpgSQL_plugin my_plugin = { ... function addresses ... };
> 
>     PLpgSQL_plugin **var_ptr;
> 
>     var_ptr = (PLpgSQL_plugin **) find_rendezvous_variable("PLpgSQL_plugin");
>     *var_ptr = &my_plugin;
> 
> and this in its _PG_fini() function:
> 
>     PLpgSQL_plugin **var_ptr;
> 
>     var_ptr = (PLpgSQL_plugin **) find_rendezvous_variable("PLpgSQL_plugin");
>     *var_ptr = NULL;
> 
> Meanwhile, plpgsql itself would do this in its _PG_init() function:
> 
>     static PLpgSQL_plugin **plugin_ptr = NULL;
> 
>     plugin_ptr = (PLpgSQL_plugin **) find_rendezvous_variable("PLpgSQL_plugin");
> 
> and in the places where it wants to pass control to the plugin, it'd do
> 
>     if (*plugin_ptr)
>         ((*plugin_ptr)->function_field) (... args ...);
> 

I know this is a trivial question, but is there some kind of lock that
would prevent the PG_fini for the plpgsql debugger from executing after
"if(*plugin_ptr)" and before "((*plugin_ptr)->function_field)(...)"?

Regards,Jeff Davis



pgsql-hackers by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: 8.2 features status
Next
From: Tom Lane
Date:
Subject: Re: Plugins redux (was Re: [PATCHES] PL instrumentation plugin support)