mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Change bms_add_range to be a no-op for empty ranges
In commit 84940644de
, bms_add_range was added with an API to fail with
an error if an empty range was specified. This seems arbitrary and
unhelpful, so turn that case into a no-op instead. Callers that require
further verification on the arguments or result can apply them by
themselves.
This fixes the bug that partition pruning throws an API error for a case
involving the default partition of a default partition, as in the
included test case.
Reported-by: Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>
Diagnosed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/16590.1532622503@sss.pgh.pa.us
This commit is contained in:
@ -867,6 +867,10 @@ bms_add_range(Bitmapset *a, int lower, int upper)
|
||||
ushiftbits,
|
||||
wordnum;
|
||||
|
||||
/* do nothing if nothing is called for, without further checking */
|
||||
if (upper < lower)
|
||||
return a;
|
||||
|
||||
if (lower < 0 || upper < 0)
|
||||
elog(ERROR, "negative bitmapset member not allowed");
|
||||
if (lower > upper)
|
||||
@ -878,13 +882,12 @@ bms_add_range(Bitmapset *a, int lower, int upper)
|
||||
a = (Bitmapset *) palloc0(BITMAPSET_SIZE(uwordnum + 1));
|
||||
a->nwords = uwordnum + 1;
|
||||
}
|
||||
|
||||
/* ensure we have enough words to store the upper bit */
|
||||
else if (uwordnum >= a->nwords)
|
||||
{
|
||||
int oldnwords = a->nwords;
|
||||
int i;
|
||||
|
||||
/* ensure we have enough words to store the upper bit */
|
||||
a = (Bitmapset *) repalloc(a, BITMAPSET_SIZE(uwordnum + 1));
|
||||
a->nwords = uwordnum + 1;
|
||||
/* zero out the enlarged portion */
|
||||
|
Reference in New Issue
Block a user