Re: Get the name of the target Relation from Query struct?

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Get the name of the target Relation from Query struct?
Дата
Msg-id CAKJS1f8i+RhW8FXPgvTJP1JfVJHbhED1N4f4CtfEPehfVaGVBw@mail.gmail.com
обсуждение исходный текст
Ответ на AW: Get the name of the target Relation from Query struct?  (Ernst-Georg Schmid <ernst-georg.schmid@bayer.com>)
Список pgsql-hackers
On 6 April 2018 at 01:20, Ernst-Georg Schmid
<ernst-georg.schmid@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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Excessive PostmasterIsAlive calls slow down WAL redo
Следующее
От: Dmitry Dolgov
Дата:
Сообщение: Re: typcategory for regconfig