Re: BUG #4350: 'select' acess given to views containing "union all" even though user has no grants

From: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Brendan O'Shea" <boshea(at)akamai(dot)com>, <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #4350: 'select' acess given to views containing "union all" even though user has no grants
Date: 2008-08-12 07:47:28
Message-ID: 48A14010.4010607@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tom Lane wrote:
> I wrote:
>> That's one heck of a scary patch: nowhere in list_union's API is there
>> any guarantee that it preserves list ordering, but we *must not* change
>> the positions of the existing rtable entries.

Good point.

> Actually there's a more fundamental problem, namely that pulled-up
> subqueries aren't necessarily equal() to the originals. They will
> definitely be different if there were any uplevel Var references.

Another good point. I just saw that they're copied with copyObject and
are thus equal, but missed the IncrementVarSublevelsUp call.

> While you could argue that it doesn't matter because we'll only
> end up redundantly checking permissions on multiple copies of the
> RTEs, that's a bit beyond my threshold of ugliness...

Yeah, that wasn't the intention.

Attached is a patch with slightly different approach. Instead of
list_union, I'm keeping track of which rtes are copied by
pull_up_union_leaf_queries in a bitmapset.

BTW, I wonder if it's possible to end up with multiple copies of the
same RTE anyway, if there's multiple references to the same RTE. I'm
guessing that it's either not possible or we don't care, because that
can happen without the patch just as well.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

Attachment Content-Type Size
fix-union-all-view-perm-2.patch text/x-diff 4.4 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2008-08-12 07:53:45 Re: BUG #4350: 'select' acess given to views containing "union all" even though user has no grants
Previous Message Dave Page 2008-08-12 07:24:57 Re: BUG #4321: 8.3 installer shortens allowable BASE_DIR path length?