Re: negative bitmapset member not allowed Error with partition pruning

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: negative bitmapset member not allowed Error with partition pruning
Date: 2018-07-26 16:28:23
Message-ID: 16590.1532622503@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com> writes:
> I am getting "ERROR: negative bitmapset member not allowed" when
> enable_partition_pruning set to true with below test case.

Confirmed here. It's failing in perform_pruning_combine_step,
which reaches this:

result->bound_offsets = bms_add_range(NULL, 0, boundinfo->ndatums - 1);

with boundinfo->ndatums == 0. It's not clear to me whether that situation
should be impossible or not. If it is valid, perhaps all we need is
something like

if (boundinfo->ndatums > 0)
result->bound_offsets = bms_add_range(NULL, 0, boundinfo->ndatums - 1);
else
result->bound_offsets = NULL;

although that then opens the question of whether downstream code is
OK with bound_offsets being empty.

(BTW, I'm not sure that it was wise to design bms_add_range to fail for
empty ranges. Maybe it'd be better to redefine it as a no-op for
upper < lower?)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jesper Pedersen 2018-07-26 16:30:38 Re: partition tree inspection functions
Previous Message David Rowley 2018-07-26 16:19:34 Re: Speeding up INSERTs and UPDATEs to partitioned tables