Current code assumes that window function computation is a once-in-a-query
event. It creates Item and Cached_item objects, and allocates things on
This task is separate the computations into
- Stage #1: a part that is done once
- Stage #2: a part that is re-run for every select re-execution.
Also, all 'cursor' objects must be created at stage #1.