Re: [Patch] Invalid permission check in pg_stats for functional indexes - Mailing list pgsql-hackers

From Pierre Ducroquet
Subject Re: [Patch] Invalid permission check in pg_stats for functional indexes
Date
Msg-id 20359573.oNSXtjVHDr@peanuts2
Whole thread Raw
In response to Re: [Patch] Invalid permission check in pg_stats for functional indexes  (Kuntal Ghosh <kuntalghosh.2007@gmail.com>)
Responses Re: [Patch] Invalid permission check in pg_stats for functional indexes
Re: [Patch] Invalid permission check in pg_stats for functionalindexes
List pgsql-hackers
On Tuesday, September 3, 2019 12:39:51 PM CEST Kuntal Ghosh wrote:
> Hello Pierre,

Hello Kuntal
> 
> > When using a functional index on a table, we realized that the permission
> > check done in pg_stats was incorrect and thus preventing valid access to
> > the statistics from users.
> > 
> > The attached patch fixes this by introducing a second path in privilege
> > check in pg_stats view.
> 
> The patch doesn't apply on the latest HEAD [1].

All my apologies for that. I submitted this patch some time ago but forgot to 
add it to the commit fest. Attached to this mail is a rebased version.

> IIUC, the patch introduces an additional privilege check for the
> underlying objects involved in the expression/functional index. If the
> user has 'select' privileges on all of the columns/objects included in
> the expression/functional index, then it should be visible in pg_stats
> view. I've applied the patch manually and tested the feature. It works
> as expected.

Indeed, you understood correctly. I have not digged around to find out the 
origin of the current situation, but it does not look like an intentional 
behaviour, more like a small oversight.

> > I have not written a regression test yet, mainly because I'm not 100%
> > certain where to write it. Given some hints, I would happily add it to
> > this patch.
> Yeah, it'll be good to have some regression tests for the same. I'm
> also not sure which regression file best suites for these tests.



Thank you very much for your review

 Pierre

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: remove "msg" parameter from convert_tuples_by_name
Next
From: Stephen Frost
Date:
Subject: Re: add a MAC check for TRUNCATE