On 6 April 2018 at 01:20, Ernst-Georg Schmid
<ernst-georg.sch...@bayer.com> wrote:
>>If you want the relation name from the OID then you'll need something
>>like get_rel_name().
>
> Hm, lsyscache.c says for get_rel_name():
>
>   * NOTE: since relation name is not unique, be wary of code that uses this
>   * for anything except preparing error messages.
>
> How do I get the schema name too, then?
>
> Call get_rel_namespace() and then get_rel_name() again with the Oid that was 
> returned?

No, get_rel_name returns the relname from pg_class. What you need is
in pg_namespace:

namespace from relid: get_namespace_name(get_rel_namespace(relid))
relname from relid: get_rel_name(relid))));

If you're going to relation_open the rel, then you might want to use:

get_namespace_name(RelationGetNamespace(rel))

and

RelationGetRelationName(rel))));

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Reply via email to