@@ -33,6 +33,7 @@ struct TPgKernelState : arrow::compute::KernelState {
3333 bool IsFixedResult;
3434 i32 TypeLen;
3535 std::shared_ptr<void > FmgrDataHolder;
36+ const NPg::TProcDesc* ProcDesc;
3637};
3738
3839template <PGFunction PgFunc>
@@ -356,7 +357,7 @@ struct TGenericExec {
356357 fcinfo->context = state.context ;
357358 fcinfo->resultinfo = state.resultinfo ;
358359 fcinfo->fncollation = state.fncollation ;
359- fcinfo->nargs = batch.values .size ();
360+ fcinfo->nargs = batch.values .size ();
360361
361362 TInputArgsAccessor<TArgsPolicy> inputArgsAccessor;
362363 inputArgsAccessor.Bind (batch.values );
@@ -371,6 +372,7 @@ struct TGenericExec {
371372
372373 for (size_t i = 0 ; i < length; ++i) {
373374 Datum ret;
375+ bool needToFree = false ;
374376 if constexpr (!TArgsPolicy::VarArgs) {
375377 if (!constexpr_for_tuple ([&](auto const & j, auto const & v) {
376378 NullableDatum d;
@@ -438,7 +440,17 @@ struct TGenericExec {
438440 }
439441
440442 fcinfo->isnull = false ;
443+ if constexpr (TArgsPolicy::VarArgs) {
444+ needToFree = PrepareVariadicArray (*fcinfo, *state.ProcDesc );
445+ }
446+
441447 ret = Func (fcinfo);
448+ if constexpr (TArgsPolicy::VarArgs) {
449+ if (needToFree) {
450+ FreeVariadicArray (*fcinfo, batch.values .size ());
451+ }
452+ }
453+
442454 if constexpr (IsFixedResult) {
443455 fixedResultData[i] = ui64 (ret);
444456 fixedResultValidMask[i] = !fcinfo->isnull ;
0 commit comments