On 6 February 2018 at 10:11, Kyotaro HORIGUCHI <horiguchi.kyot...@lab.ntt.co.jp> wrote: >> At Mon, 5 Feb 2018 15:29:27 +0530, Amit Khandekar <amitdkhan...@gmail.com> >> wrote in >> > Attached is a patch that fixes this issue on the above lines. >> >> The patch adds two new variables and always sets them but warp >> around can happen at most once per call so I think it is enough >> to arrange to stop at the wrap around time. Addition to that the >> patch is forgetting the case of no partial plan. The loop can >> overrun on pa_finished in the case. > > Sorry, the patch works fine. But still the new variables don't > seem needed.
True, I could have set initially as_whichplan to pa_next_plan, and used as_whichplan instead of initial_plan. And, I could have used the condition initial_plan >= append->first_partial_plan instead of should_wrap_around. The reason I used these two variables is because I thought the logic would be more reader-friendly. (Also, should_wrap_around uses static values so using this variable avoids determining the condition (initial_plan >= append->first_partial_plan) at each iteration). -- Thanks, -Amit Khandekar EnterpriseDB Corporation The Postgres Database Company