pgrx
pgrx copied to clipboard
Question: Hooks and executor_start
Hi! I'm trying to replicate a common pattern in some Postgres extensions, for example something like:
static void
pgss_ExecutorStart(QueryDesc *queryDesc, int eflags)
{
if (prev_ExecutorStart)
prev_ExecutorStart(queryDesc, eflags);
else
standard_ExecutorStart(queryDesc, eflags);
// use queryDesc
I tried using prev_hook
and standard_ExecutorStart
but i don't understand fully the pgx flow of hooks, also I always end with errors with the borrow checker because of this:
fn executor_start(
&mut self,
query_desc: PgBox<QueryDesc>,
eflags: i32,
prev_hook: fn(PgBox<QueryDesc>, i32) -> HookResult<()>,
) -> HookResult<()> {
prev_hook(query_desc, eflags)
if query_desc.totaltime.is_null() { // value borrowed here after move blabla
.......
}
If this is the correct place to ask, any help would be appreciate. Thanks!
This is the best documentation on hooks that I've seen:
https://github.com/taminomara/psql-hooks
There is some decent sample code in C that you might be able to adapt.