Re: Proving IS NOT NULL inference for ScalarArrayOpExpr's

James Coleman <jtc331@gmail.com>

From: James Coleman <jtc331@gmail.com>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2019-01-13T19:12:38Z
Lists: pgsql-hackers

Attachments

On Sat, Jan 12, 2019 at 8:52 PM David Rowley
<david.rowley@2ndquadrant.com> wrote:
>
> Basically, the planner assumes that the WHERE a IS NOT NULL index
> implies WHERE b IN(1,...,101), which is definitely not the case.
>
> Probably your new code needs to be expanded to become:
>
> if (IsA(clause, ScalarArrayOpExpr))
> {
>     ScalarArrayOpExpr *saop = (ScalarArrayOpExpr *) clause;
>     if (op_strict(saop->opno) &&
>         clause_is_strict_for((Node *) linitial(saop->args), subexpr))
>         return true;
> }

I've updated the code as well as included the sad path test in
addition to my original happy path test.

Patch v3 attached.

James Coleman

Commits

  1. Teach optimizer's predtest.c more things about ScalarArrayOpExpr.