Re: negative bitmapset member not allowed Error with partition pruning

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: negative bitmapset member not allowed Error with partition pruning
Date: 2018-07-27 04:23:11
Message-ID: 3437ccf8-a144-55ff-1e2f-fc16b437823b@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2018/07/27 12:14, Tom Lane wrote:
> David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> writes:
>> On 27 July 2018 at 13:35, Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> wrote:
>>> On 2018/07/27 1:28, Tom Lane wrote:
>>>> (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?)
>
>>> FWIW, I was thankful that David those left those checks there, because it
>>> helped expose quite a few bugs when writing this code or perhaps that was
>>> his intention to begin with, but maybe he thinks differently now (?).
>
>> I think it's more useful to keep as a bug catcher, although I do
>> understand the thinking behind just having it be a no-op.
>
> Well, my thinking is that it helps nobody if call sites have to have
> explicit workarounds for a totally-arbitrary refusal to handle edge
> cases in the primitive functions. I do not think that is good software
> design. If you want to have assertions that particular call sites are
> specifying nonempty ranges, put those in the call sites where it's
> important. But as-is, this seems like, say, defining foreach() to
> blow up on an empty list.

How about adding Asserts to that effect in partprune.c and execPartition.c
where they're not present? These are the only two files where it's
currently being used, given that it was invented only recently and exactly
for use by the new pruning code. I updated the patch that I posted in the
last email to add those Asserts.

FWIW, I can see at least the guard against < 0 values in number of other
bms_* functions, but I won't be the one to make a call one way or the
other about whether to change bms_add_range() to cope with erroneous inputs.

Thanks,
Amit

Attachment Content-Type Size
partprune-check-zero-bounds-fix-v2.patch text/plain 4.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2018-07-27 04:34:40 Re: negative bitmapset member not allowed Error with partition pruning
Previous Message Michael Paquier 2018-07-27 04:15:42 Re: BUG #15182: Canceling authentication due to timeout aka Denial of Service Attack