Re: [RFC] Common object property boards

From: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kohei Kaigai <Kohei(dot)Kaigai(at)emea(dot)nec(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, "robertmhaas(at)gmail(dot)com" <robertmhaas(at)gmail(dot)com>
Subject: Re: [RFC] Common object property boards
Date: 2011-07-31 06:21:55
Message-ID: CADyhKSXGSLj9-C-J+stLLparShs3ZJASJmBTQendzz=dFmqurA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2011/7/29 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Kohei Kaigai <Kohei(dot)Kaigai(at)EMEA(dot)NEC(dot)COM> writes:
>> In addition to this suggestion, I think the big static array also contains
>> the following items:
>> - Text form of the object type (e.g, "table", "function", ...)
>
> What will you do with that that wouldn't be better done by calling
> getObjectDescription?  The latter's output is somewhat localizable, but
> individual words would be hard to translate.
>
The getObjectDescription() is good for existing object, but we cannot use
this interface to generate error messages of not exist object.

>> Does the main lookup function ought to return an entry of the big array?
>> If so, the definition of structure should be declared in objectaddress.h,
>> as follows:
>
> It would likely be better to not expose the struct type, just individual
> lookup functions.
>
If so, individual functions to expose a certain property of the supplied
object type should be provided.

int get_object_property_catid_oidlookup(ObjectType);
int get_object_property_catid_namelookup(ObjectType);
Oid get_object_property_relation_id(ObjectType);
AttrNumber get_object_property_nameattnum(ObjectType);
AttrNumber get_object_property_namespacenum(ObjectType);
AttrNumber get_object_property_ownershipnum(ObjectType);

I'm not a fun to invoke these functions more than once in a certain step.
For example, AlterObjectNamespace() wants to know attribute number
of name, namespace and ownership. In addition, it also want cache-id
of oid-loopup and name-lookup. Thus, it takes 5 times invocation of
these function, rather than one lookup for array.

Which is more preferable for programmer?

>> And, a translation from ObjectType to type name (e.g "table", "type", ...)
>> is helpful to generate error messages.
>
>>   const char *get_object_type_name(ObjectType objtype);
>
> Again, I think this is too low level because of message translation
> considerations.
>
OK.

Thanks,
--
KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)jp>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message daveg 2011-07-31 08:17:01 Re: error: could not find pg_class tuple for index 2662
Previous Message Robert Haas 2011-07-31 01:46:05 Re: pgbench internal contention