mirror of
https://github.com/postgres/postgres.git
synced 2025-11-28 11:44:57 +03:00
Assert that cutoffs are provided if freezing will be attempted
heap_page_prune_and_freeze() requires the caller to initialize
PruneFreezeParams->cutoffs so that the function can correctly evaluate
whether tuples should be frozen. This requirement previously existed
only in comments and was easy to miss, especially after “cutoffs” was
converted from a direct function parameter to a field of the newly
introduced PruneFreezeParams struct (added in 1937ed7062). Adding an
assert makes this requirement explicit and harder to violate.
Also, fix a minor typo while we're at it.
Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/0AC177F5-5E26-45EE-B273-357C51212AC5%40gmail.com
This commit is contained in:
@@ -461,7 +461,7 @@ heap_page_will_freeze(Relation relation, Buffer buffer,
|
|||||||
* 'new_relmin_mxid' arguments are required when freezing. When
|
* 'new_relmin_mxid' arguments are required when freezing. When
|
||||||
* HEAP_PAGE_PRUNE_FREEZE option is passed, we also set presult->all_visible
|
* HEAP_PAGE_PRUNE_FREEZE option is passed, we also set presult->all_visible
|
||||||
* and presult->all_frozen after determining whether or not to
|
* and presult->all_frozen after determining whether or not to
|
||||||
* opporunistically freeze, to indicate if the VM bits can be set. They are
|
* opportunistically freeze, to indicate if the VM bits can be set. They are
|
||||||
* always set to false when the HEAP_PAGE_PRUNE_FREEZE option is not passed,
|
* always set to false when the HEAP_PAGE_PRUNE_FREEZE option is not passed,
|
||||||
* because at the moment only callers that also freeze need that information.
|
* because at the moment only callers that also freeze need that information.
|
||||||
*
|
*
|
||||||
@@ -504,6 +504,9 @@ heap_page_prune_and_freeze(PruneFreezeParams *params,
|
|||||||
prstate.vistest = params->vistest;
|
prstate.vistest = params->vistest;
|
||||||
prstate.mark_unused_now =
|
prstate.mark_unused_now =
|
||||||
(params->options & HEAP_PAGE_PRUNE_MARK_UNUSED_NOW) != 0;
|
(params->options & HEAP_PAGE_PRUNE_MARK_UNUSED_NOW) != 0;
|
||||||
|
|
||||||
|
/* cutoffs must be provided if we will attempt freezing */
|
||||||
|
Assert(!(params->options & HEAP_PAGE_PRUNE_FREEZE) || params->cutoffs);
|
||||||
prstate.attempt_freeze = (params->options & HEAP_PAGE_PRUNE_FREEZE) != 0;
|
prstate.attempt_freeze = (params->options & HEAP_PAGE_PRUNE_FREEZE) != 0;
|
||||||
prstate.cutoffs = params->cutoffs;
|
prstate.cutoffs = params->cutoffs;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user