forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit166f943
committed
Clarify the logic in a few places in the new balanced merge code.
In selectnewtape(), use 'nOutputTapes' rather than 'nOutputRuns' in thecheck for whether to start a new tape or to append a new run to anexisting tape. Until 'maxTapes' is reached, nOutputTapes is always equalto nOutputRuns, so it doesn't change the logic, but it seems more logicalto compare # of tapes with # of tapes. Also, currently maxTapes is nevermodified after the merging begins, but written this way, the code wouldstill work if it was. (Although the nOutputRuns == nOutputTapes assertionwould need to be removed and using nOutputRuns % nOutputTapes todistribute the runs evenly across the tapes wouldn't do a good jobanymore).Similarly in mergeruns(), change to USEMEM(state->tape_buffer_mem) toaccount for the memory used for tape buffers. It's equal to availMemcurrently, but tape_buffer_mem is more direct and future-proof. Forexample, if we changed the logic to only allocate half of the remainingmemory to tape buffers, USEMEM(state->tape_buffer_mem) would still becorrect.Coverity complained about these. Hopefully this patch helps it tounderstand the logic better. Thanks to Tom Lane for initial analysis.1 parentb4ada4e commit166f943
1 file changed
+9
-3
lines changedLines changed: 9 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2773 | 2773 |
| |
2774 | 2774 |
| |
2775 | 2775 |
| |
2776 |
| - | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
2777 | 2783 |
| |
2778 | 2784 |
| |
2779 | 2785 |
| |
2780 | 2786 |
| |
2781 | 2787 |
| |
2782 |
| - | |
| 2788 | + | |
2783 | 2789 |
| |
2784 | 2790 |
| |
2785 | 2791 |
| |
| |||
2908 | 2914 |
| |
2909 | 2915 |
| |
2910 | 2916 |
| |
2911 |
| - | |
| 2917 | + | |
2912 | 2918 |
| |
2913 | 2919 |
| |
2914 | 2920 |
| |
|
0 commit comments
Comments
(0)