Skip to content

Commit 2f10970

Browse files
committed
Fix incorrect mutability in GUC assign hook macro
The assign hook for strings requires a `const char *` rather than `char *`. This adds `RawConst` and `from_raw_const` to the `GucValue` trait for the `pg_guc_hook(assign)` macro to use. Tests for the `pg_guc_hook` macro are now generated in `pgrx-unit-tests` and include all `GucValue` types.
1 parent 58147f1 commit 2f10970

3 files changed

Lines changed: 309 additions & 201 deletions

File tree

pgrx-macros/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,13 +1596,13 @@ pub fn pg_guc_hook(attr: TokenStream, item: TokenStream) -> TokenStream {
15961596
quote! {
15971597
#[::pgrx::pg_guard]
15981598
#vis unsafe extern "C-unwind" fn #original_ident(
1599-
newval: <#arg_type as ::pgrx::guc::GucValue>::Raw,
1599+
newval: <#arg_type as ::pgrx::guc::GucValue>::RawConst,
16001600
extra: *mut ::core::ffi::c_void,
16011601
) {
16021602
#[inline(always)]
16031603
#inner_func
16041604

1605-
let value = unsafe { <#arg_type as ::pgrx::guc::GucValue>::from_raw(newval) };
1605+
let value = unsafe { <#arg_type as ::pgrx::guc::GucValue>::from_raw_const(newval) };
16061606
#inner_ident(value);
16071607
}
16081608
}

0 commit comments

Comments
 (0)