Re: [RFC] Common object property boards - Mailing list pgsql-hackers

From Kohei KaiGai
Subject Re: [RFC] Common object property boards
Date
Msg-id CADyhKSXGSLj9-C-J+stLLparShs3ZJASJmBTQendzz=dFmqurA@mail.gmail.com
Whole thread Raw
In response to Re: [RFC] Common object property boards  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [RFC] Common object property boards
List pgsql-hackers
2011/7/29 Tom Lane <tgl@sss.pgh.pa.us>:
> Kohei Kaigai <Kohei.Kaigai@EMEA.NEC.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@kaigai.gr.jp>


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pgbench internal contention
Next
From: daveg
Date:
Subject: Re: error: could not find pg_class tuple for index 2662