Verify range bounds to bms_add_range when necessary
Now that the bms_add_range boundary protections are gone, some alternative ones are needed in a few places. Author: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> Discussion: https://postgr.es/m/3437ccf8-a144-55ff-1e2f-fc16b437823b@lab.ntt.co.jp
This commit is contained in:
parent
192d1bbf99
commit
a0655ba68f
@ -171,6 +171,7 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
|
|||||||
{
|
{
|
||||||
/* We'll need to initialize all subplans */
|
/* We'll need to initialize all subplans */
|
||||||
nplans = list_length(node->appendplans);
|
nplans = list_length(node->appendplans);
|
||||||
|
Assert(nplans > 0);
|
||||||
validsubplans = bms_add_range(NULL, 0, nplans - 1);
|
validsubplans = bms_add_range(NULL, 0, nplans - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +180,10 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
|
|||||||
* immediately, preventing later calls to ExecFindMatchingSubPlans.
|
* immediately, preventing later calls to ExecFindMatchingSubPlans.
|
||||||
*/
|
*/
|
||||||
if (!prunestate->do_exec_prune)
|
if (!prunestate->do_exec_prune)
|
||||||
|
{
|
||||||
|
Assert(nplans > 0);
|
||||||
appendstate->as_valid_subplans = bms_add_range(NULL, 0, nplans - 1);
|
appendstate->as_valid_subplans = bms_add_range(NULL, 0, nplans - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -189,6 +193,7 @@ ExecInitAppend(Append *node, EState *estate, int eflags)
|
|||||||
* When run-time partition pruning is not enabled we can just mark all
|
* When run-time partition pruning is not enabled we can just mark all
|
||||||
* subplans as valid; they must also all be initialized.
|
* subplans as valid; they must also all be initialized.
|
||||||
*/
|
*/
|
||||||
|
Assert(nplans > 0);
|
||||||
appendstate->as_valid_subplans = validsubplans =
|
appendstate->as_valid_subplans = validsubplans =
|
||||||
bms_add_range(NULL, 0, nplans - 1);
|
bms_add_range(NULL, 0, nplans - 1);
|
||||||
appendstate->as_prune_state = NULL;
|
appendstate->as_prune_state = NULL;
|
||||||
|
@ -486,7 +486,10 @@ get_matching_partitions(PartitionPruneContext *context, List *pruning_steps)
|
|||||||
|
|
||||||
/* If there are no pruning steps then all partitions match. */
|
/* If there are no pruning steps then all partitions match. */
|
||||||
if (num_steps == 0)
|
if (num_steps == 0)
|
||||||
|
{
|
||||||
|
Assert(context->nparts > 0);
|
||||||
return bms_add_range(NULL, 0, context->nparts - 1);
|
return bms_add_range(NULL, 0, context->nparts - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate space for individual pruning steps to store its result. Each
|
* Allocate space for individual pruning steps to store its result. Each
|
||||||
@ -2048,8 +2051,12 @@ get_matching_hash_bounds(PartitionPruneContext *context,
|
|||||||
bms_make_singleton(rowHash % greatest_modulus);
|
bms_make_singleton(rowHash % greatest_modulus);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/* Getting here means at least one hash partition exists. */
|
||||||
|
Assert(boundinfo->ndatums > 0);
|
||||||
result->bound_offsets = bms_add_range(NULL, 0,
|
result->bound_offsets = bms_add_range(NULL, 0,
|
||||||
boundinfo->ndatums - 1);
|
boundinfo->ndatums - 1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There is neither a special hash null partition or the default hash
|
* There is neither a special hash null partition or the default hash
|
||||||
@ -2128,6 +2135,7 @@ get_matching_list_bounds(PartitionPruneContext *context,
|
|||||||
*/
|
*/
|
||||||
if (nvalues == 0)
|
if (nvalues == 0)
|
||||||
{
|
{
|
||||||
|
Assert(boundinfo->ndatums > 0);
|
||||||
result->bound_offsets = bms_add_range(NULL, 0,
|
result->bound_offsets = bms_add_range(NULL, 0,
|
||||||
boundinfo->ndatums - 1);
|
boundinfo->ndatums - 1);
|
||||||
result->scan_default = partition_bound_has_default(boundinfo);
|
result->scan_default = partition_bound_has_default(boundinfo);
|
||||||
@ -2140,6 +2148,7 @@ get_matching_list_bounds(PartitionPruneContext *context,
|
|||||||
/*
|
/*
|
||||||
* First match to all bounds. We'll remove any matching datums below.
|
* First match to all bounds. We'll remove any matching datums below.
|
||||||
*/
|
*/
|
||||||
|
Assert(boundinfo->ndatums > 0);
|
||||||
result->bound_offsets = bms_add_range(NULL, 0,
|
result->bound_offsets = bms_add_range(NULL, 0,
|
||||||
boundinfo->ndatums - 1);
|
boundinfo->ndatums - 1);
|
||||||
|
|
||||||
@ -2250,6 +2259,7 @@ get_matching_list_bounds(PartitionPruneContext *context,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Assert(minoff >= 0 && maxoff >= 0);
|
||||||
result->bound_offsets = bms_add_range(NULL, minoff, maxoff);
|
result->bound_offsets = bms_add_range(NULL, minoff, maxoff);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2327,6 +2337,7 @@ get_matching_range_bounds(PartitionPruneContext *context,
|
|||||||
maxoff--;
|
maxoff--;
|
||||||
|
|
||||||
result->scan_default = partition_bound_has_default(boundinfo);
|
result->scan_default = partition_bound_has_default(boundinfo);
|
||||||
|
Assert(minoff >= 0 && maxoff >= 0);
|
||||||
result->bound_offsets = bms_add_range(NULL, minoff, maxoff);
|
result->bound_offsets = bms_add_range(NULL, minoff, maxoff);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user