Re: BUG #17570: Unrecognized node type for query with statistics on expressions

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Japin Li <japinli(at)hotmail(dot)com>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, a(dot)kozhemyakin(at)postgrespro(dot)ru, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17570: Unrecognized node type for query with statistics on expressions
Date: 2022-08-05 09:03:13
Message-ID: CAMbWs48FfgCZsA1URKboCHyNjXxDAZR=esFzwfRgqL+8H7+WBg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Aug 5, 2022 at 8:49 AM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:

> On Thu, Aug 4, 2022 at 11:42 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> * statext_is_compatible_clause_internal is not on board with
>> offsetting the attnums.
>
>
> Correct. Good catch! Fix this in v2 patch.
>

I realized the fix in v2 is not correct. The attnums generated by
statext_is_compatible_clause is expected to be NOT offsetting by its
caller, i.e. statext_mcv_clauselist_selectivity. Revise that in v3 patch
by doing the offsetting when composing clause_attnums that need to have
permission check.

> * Although the coverage report claims this code is exercised, the
>> fact that nothing failed when you made only a partial fix says it's
>> not exercised well enough.
>
>
> That's true. We need to provide a better test case to cover this.
>

Also I'm trying to provide a better test case and at last come up with a
case in v3 like:

SELECT * FROM tststats.priv_test_tbl where a = 1 and
tststats.priv_test_tbl.* > (1, 1) is not null;

For this case, the clause 'a = 1' would cover that the attnum comes from
statext_is_compatible_clause_internal. And the clause 'priv_test_tbl.* >
(1, 1) is not null' would cover that the attnum comes from 'exprs' and
it has a whole-row reference.

Thanks
Richard

Attachment Content-Type Size
v3-0001-fix-bug-17570.patch application/octet-stream 4.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message houzj.fnst@fujitsu.com 2022-08-05 09:30:00 RE: No-op updates with partitioning and logical replication started failing in version 13
Previous Message Richard Guo 2022-08-05 01:25:08 Re: BUG #17570: Unrecognized node type for query with statistics on expressions