Open my-vegetable-has-exploded opened 4 months ago
We are working on the necessary prerequisite code for making that sort of thing possible like right now. We can take a look at revising impl Aggregate
for that when it lands.
I would rather not add ad-hoc functionality like that to pg_extern
.
The relevant blocking work is most of https://github.com/pgcentralfoundation/pgrx/issues/1661
I want to use impl Aggregate to define aggregate function (to ensure it use aggregate context). But my input args is reference with lifetime, so it is hard to impl Aggregate trait.
Maybe it is another way to add a attr
aggcontext
forpg_extern
? And generate code likepgrx::pg_sys::submodules::panic::pgrx_extern_c_guard(move || { let mut agg_context: *mut ::pgrx::pg_sys::MemoryContextData = std::ptr::null_mut(); if ::pgrx::pg_sys::AggCheckCallContext(_fcinfo, &mut agg_context) == 0 { ::pgrx::error!("aggregate function called in non-aggregate context",); } let old_context = ::pgrx::pg_sys::MemoryContextSwitchTo(agg_context); let result = _vectors_vecf32_aggregate_avg_sum_sfunc_wrapper_inner(_fcinfo); ::pgrx::pg_sys::MemoryContextSwitchTo(old_context); result })
?Thanks for your great work.