On 24.11.2022 06:16, Richard Guo wrote:
Regarding how to fix this problem, firstly I believe we need to evaluate
window functions in the per-tuple memory context, as the HEAD does.
When we decide we need to go into pass-through mode, I'm thinking that
we can just copy out the results of the last evaluation to the per-query
memory context, while still storing their pointers in ecxt_aggvalues.

Does this idea work?
Although I'm not familiar with the code, this makes sense to me.

You proposed:

+#ifdef USE_FLOAT8_BYVAL
+ evalWfuncContext = winstate->ss.ps.ps_ExprContext->ecxt_per_tuple_memory;
+#else
+ evalWfuncContext = winstate->ss.ps.ps_ExprContext->ecxt_per_query_memory;
+#endif

Shouldn't we handle any pass-by-reference type the same? I suppose, a user-defined window function can return some other type, not int8.

Best regards,

--
Sergey Shinderuk                https://postgrespro.com/



Reply via email to