Re: get_whatever_oid, part 1: object types with unqualifed names

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: KaiGai Kohei <kaigai(at)ak(dot)jp(dot)nec(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: get_whatever_oid, part 1: object types with unqualifed names
Date: 2010-06-28 16:27:39
Message-ID: AANLkTimrjZkL6UO9hsLRVxrzO8ZPP873hAefWdxBDLBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 28, 2010 at 12:17 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Mon, Jun 28, 2010 at 10:53 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> I'm not sure I agree that replacing SearchSysCacheExists calls (or
>>> things that should have been SearchSysCacheExists calls) with
>>> OidIsValid(get_whatever_oid()) is an improvement.  The Exists call
>>> tells what you're actually trying to accomplish.  The other way is
>>> an overspecification of the required result.
>
>> It is, but on the other hand it's only good fortune that testing
>> whether a schema exists is a one-liner even without using
>> get_namespace_oid().
>
> True.  Is it worth providing whatever_exists() macros that wrap
> get_whatever_oid() like this, just so that callers are a bit clearer as
> to what they're doing?  I'm not certain though how many places it could
> be used, since many callers probably actually do need the OID, and would
> have to write separate lines anyway:
>
>        objoid = get_whatever_oid(...);
>        if (!OidIsValid(objoid))
>                ereport(...);
>        ... code using objoid here ...
>
> But it's been useful to have the SearchSysCacheExists functions, even
> though they're just wrappers, so maybe whatever_exists() would be worth
> its keep.

I haven't made a detailed study of this issue, so I'm not 100% sure.
My gut feeling however is that nearly all of the callers need the OID,
and that some of the whatever_exists() functions wouldn't have any
callers at all. Which makes me pretty hesitant to add them,
especially given our decision not to centralize all the
get_whatever_oid() functions in one place.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-06-28 16:31:56 Re: get_whatever_oid, part 1: object types with unqualifed names
Previous Message Tom Lane 2010-06-28 16:17:45 Re: get_whatever_oid, part 1: object types with unqualifed names