the call is however bypassed when the optimizer figures out that the JOIN
has "Impossible WHERE".
If we attempt to calculate the value of a window function afterwards,
we will get a crash when trying to create a temporary table.
So, put a call to calc_group_buffer() here as well. It's a bit surprising
that all these steps are done for a query that will produce zero rows
but we are just following the approach taken by the fix for mdev-11999
here.
MDEV-13351: Server crashes in st_select_lex::set_explain_type upon UNION with window function
Make st_select_lex::set_explain_type() take into account that JOIN_TABs
it is traversing may be also post-join aggregation JOIN_TABs (which
have pos_in_table_list=NULL, etc).
MDEV-13352: Server crashes in st_join_table::remove_duplicates
Do not run the window function computation step when the select
produces no rows (zero_result_cause!=NULL).
This may cause reads from uninitialized memory.
We still need to run the window function computation step when
the output includes just one row (for example
SELECT MAX(col), RANK() OVER (...) FROM t1 WHERE 1=0).
This fix also resolves an issue with queries with window functions
producing an output row where should be none, like in
SELECT ROW_NUMBER() FROM t1 WHERE 1=0.
Updated a few test results in the existing tests to reflect this.