From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | "Hsu, John" <hsuchen(at)amazon(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
Subject: | Re: Include RELKIND_TOASTVALUE in get_relkind_objtype |
Date: | 2019-10-03 13:52:34 |
Message-ID: | 29637.1570110754@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Michael Paquier <michael(at)paquier(dot)xyz> writes:
> On Tue, Oct 01, 2019 at 12:10:50AM +0000, Hsu, John wrote:
>> get_relkind_objtype(...) was introduced as part of 8b9e9644dc, and it doesn't include
>> RELKIND_TOASTVALUE. As a result when a user who has usage rights on schema pg_toast
>> and attempts to reindex a table it is not the owner of it fails with the wrong error
>> message.
> (Adding Peter E. in CC)
> Sure. However this implies that the user doing the reindex not only
> has ownership of the relation worked on, but is also able to work
> directly on the schema pg_toast. Should we really encourage people to
> do that with non-superusers?
FWIW, I really dislike this patch, mainly because it is based on the
assumption (as John said) that get_relkind_objtype is used only
in aclcheck_error calls. However it's not obvious why that should
be true, and there certainly is no documentation suggesting that
it needs to be true. That's mainly because get_relkind_objtype has no
documentation period, which if you ask me is flat out unacceptable
for a globally-exposed function. (Same comment about its wrapper
get_object_type.)
The patch also falsifies the comment just a few lines away that
/*
* other relkinds are not supported here because they don't map to
* OBJECT_* values
*/
without doing anything about that.
I'm inclined to think that we should redefine the charter of
get_relkind_objtype/get_object_type to be that they'll produce
some OBJECT_* value for any relkind whatever, on the grounds
that throwing an error here isn't a particularly useful behavior;
we'd rather come out with a possibly-slightly-inaccurate generic
message about a "table". And they need to be documented that way.
Alternatively, instead of mapping other relkinds to OBJECT_TABLE,
we could invent a new enum entry OBJECT_RELATION. There's precedent
for that in OBJECT_ROUTINE ... but I don't know that we want to
build out all the other infrastructure for a new ObjectType right now.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Euler Taveira | 2019-10-03 14:01:00 | Re: Regarding extension |
Previous Message | Robert Haas | 2019-10-03 13:48:32 | Re: pgsql: Implement jsonpath .datetime() method |