Re: [HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Eric Ridge
On Thu, Jun 18, 2015 at 8:07 PM, Eric Ridge wrote: > > According to pg_proc.probin, all 32 of my C language functions point > to $libdir/my_extension_lib, That's a damn lie. The deployment server has a number of databases that have this extension installed and some of them have probin set to jus

Re: [HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Eric Ridge
On Thu, Jun 18, 2015 at 6:04 PM, Tom Lane wrote: > What we were expecting I guess is that such functions would be declared > to reference the library underneath $libdir/plugins, not that you'd use > a symlink. According to pg_proc.probin, all 32 of my C language functions point to $libdir/my_ext

Re: [HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Tom Lane
Eric Ridge writes: > On Thu, Jun 18, 2015 at 5:30 PM, Tom Lane wrote: >>> As a data point, that might be interesting to know, but I'd still be >>> scratching my head about how it happened. Postgres doesn't load an >>> extension library more than once per backend session, does it? >> It's not su

Re: [HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Eric Ridge
On Thu, Jun 18, 2015 at 5:39 PM, Tom Lane wrote: > BTW, if it didn't occur to you already --- next time you see this, > you could try examining dfmgr.c's DynamicFileList data structure > using gdb. That might help illuminate what Postgres thinks it > loaded and why. Hmm, okay. I'll not check fo

Re: [HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Eric Ridge
On Thu, Jun 18, 2015 at 5:30 PM, Tom Lane wrote: > > If that's broken, then so are most of our contrib modules. > Certainly none of them have an extra check as suggested by Andres. I'm putting it in anyways, along with a guard in the actual hook function to ERROR if prev_hook == my_hook. At leas

Re: [HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Tom Lane
I wrote: > Eric Ridge writes: >> As a data point, that might be interesting to know, but I'd still be >> scratching my head about how it happened. Postgres doesn't load an >> extension library more than once per backend session, does it? > It's not supposed to, and AFAICS internal_load_library()

Re: [HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Tom Lane
Eric Ridge writes: > On Thu, Jun 18, 2015 at 4:42 PM, Andres Freund wrote: >> How does your _PG_init() actually look like? > static ExecutorStart_hook_type prev_ExecutorStartHook = NULL; > static ExecutorEnd_hook_type prev_ExecutorEndHook = NULL; > void _PG_init(void) > { >prev_ExecutorSta

Re: [HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Eric Ridge
On Thu, Jun 18, 2015 at 4:42 PM, Andres Freund wrote: > > > How does your _PG_init() actually look like? static ExecutorStart_hook_type prev_ExecutorStartHook = NULL; static ExecutorEnd_hook_type prev_ExecutorEndHook = NULL; void _PG_init(void) { prev_ExecutorStartHook = ExecutorStart_hook;

Re: [HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Andres Freund
Hi, On 2015-06-18 16:36:17 -0400, Eric Ridge wrote: > I've written an extension that hooks ExecutorStart_hook and > ExecutorEnd_hook. The hooks are assigned in _PG_init() (and the previous > ones saved to static vars) and reset to the previous values in _PG_fini(). > Maybe also of interest is the

[HACKERS] Weirdness using Executor Hooks

2015-06-18 Thread Eric Ridge
I've written an extension that hooks ExecutorStart_hook and ExecutorEnd_hook. The hooks are assigned in _PG_init() (and the previous ones saved to static vars) and reset to the previous values in _PG_fini(). Maybe also of interest is the extension library is set in postgresql.conf as a local_prelo