Re: BUG #14676: neqsel is NULL dumb

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: marko(at)joh(dot)to
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14676: neqsel is NULL dumb
Date: 2017-06-01 16:22:53
Message-ID: 4698.1496334173@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

marko(at)joh(dot)to writes:
> This seems to be because neqsel() doesn't take at all into account that both
> operators will exclude NULL rows, and does a simple 1.0 - eqsel().

Yeah, that's clearly broken. A localized fix would be to re-fetch the
nullfrac statistic and subtract it off, but that seems pretty inefficient.
I'd be inclined to refactor things so that eqsel() and neqsel() call a
common routine that takes a "bool negate" argument, about like the way the
patternsel() functions work, and then the common routine could handle
the nullfrac correctly for both cases.

Hmm ... actually, I think patternsel() is broken for this case too ---
it has the information to do the right thing, but it doesn't look like
it actually is doing it:
return negate ? (1.0 - result) : result;
should be more like
return negate ? (1.0 - result - nullfrac) : result;

neqjoinsel has a similar issue, and I'm not sure what else.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Petr Jelinek 2017-06-01 17:08:33 Re: [BUGS] Concurrent ALTER SEQUENCE RESTART Regression
Previous Message Robert Haas 2017-06-01 14:51:10 Re: [HACKERS] Concurrent ALTER SEQUENCE RESTART Regression