Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reference type for Aggregate::Args? #1719

Open
my-vegetable-has-exploded opened this issue May 28, 2024 · 2 comments
Open

Support reference type for Aggregate::Args? #1719

my-vegetable-has-exploded opened this issue May 28, 2024 · 2 comments
Labels

Comments

@my-vegetable-has-exploded
Copy link
Contributor

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 for pg_extern? And generate code like
pgrx::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.

@workingjubilee
Copy link
Member

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.

@workingjubilee
Copy link
Member

The relevant blocking work is most of #1661

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants