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

From: Japin Li <japinli(at)hotmail(dot)com>
To: a(dot)kozhemyakin(at)postgrespro(dot)ru, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17570: Unrecognized node type for query with statistics on expressions
Date: 2022-08-04 10:33:35
Message-ID: MEYP282MB166998A90E685A09A9576F59B69F9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


On Thu, 04 Aug 2022 at 16:27, PG Bug reporting form <noreply(at)postgresql(dot)org> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 17570
> Logged by: Alexander Kozhemyakin
> Email address: a(dot)kozhemyakin(at)postgrespro(dot)ru
> PostgreSQL version: 14.4
> Operating system: ubunu 20.04
> Description:
>
> When executing the following script:
> CREATE TABLE t(a INT, b VARCHAR);
> INSERT INTO t(a, b) SELECT i, i FROM generate_series(1,100) s(i);
> CREATE STATISTICS t_stats (mcv) ON (a), (b) FROM t;
> ANALYZE t;
> CREATE ROLE u;
> --GRANT SELECT ON t TO u;
> SET SESSION AUTHORIZATION u;
> SELECT * FROM t WHERE a = 1 AND b::int = 1;
>
> I get:
> ERROR: unrecognized node type: 1697192808
>
> And it fails with error "permission denied for table t" when condition is
> just "a = 1" or "b::int = 1".
>
> The same query executed successfully, if the select permission is granted to
> user.
> The first bad commit is a4d75c86b

Yeah, it is a bug.

When we don't have table privilege, we check individual columns, however, it
passes a wrong pointer to pull_varattnos(), which leads to this error.

There has another bug when checking the attribute privilege, since the bitmap
contains the offset by FirstLowInvalidHeapAttributeNumber.

Attach a patch to fix it. Any thoughts?

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

Attachment Content-Type Size
fix-unrecognized-node-type-for-query-with-statistics.diff text/x-patch 1.0 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2022-08-04 10:37:43 Re: BUG #17570: Unrecognized node type for query with statistics on expressions
Previous Message Francisco Olarte 2022-08-04 10:27:04 Re: ERROR: unterminated dollar-quoted string at or near "$$"