pgrx icon indicating copy to clipboard operation
pgrx copied to clipboard

[NEED HELP] How to use assign_hook on GucRegistry

Open k9982874 opened this issue 7 months ago • 0 comments

I want to listen to changes in variables created by GucRegistry. I checked the source there is no way to pass an assign_hook function with the define series functions. Could enlighten me how to done this work?

pub fn define_int_guc(
        name: &str,
        short_description: &str,
        long_description: &str,
        setting: &GucSetting<i32>,
        min_value: i32,
        max_value: i32,
        context: GucContext,
        flags: GucFlags,
    ) {
        unsafe {
            pg_sys::DefineCustomIntVariable(
                PgMemoryContexts::TopMemoryContext.pstrdup(name),
                PgMemoryContexts::TopMemoryContext.pstrdup(short_description),
                PgMemoryContexts::TopMemoryContext.pstrdup(long_description),
                setting.as_ptr(),
                setting.get(),
                min_value,
                max_value,
                context as isize as _,
                flags.bits(),
                None, <--- check_hook
                None, <--- assign_hook
                None,
            )
        }
    }

k9982874 avatar May 10 '25 06:05 k9982874