Re: Accessing base table relational names via RelOptInfo

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Accessing base table relational names via RelOptInfo
Дата
Msg-id CAKJS1f999TpXXPZjdyVajjd0PrE3pLDmA+Cz-BNJ8bZkHriOAQ@mail.gmail.com
обсуждение исходный текст
Ответ на Accessing base table relational names via RelOptInfo  (Walter Cai <wzcai92@gmail.com>)
Список pgsql-hackers
On 7 December 2017 at 09:26, Walter Cai <wzcai92@gmail.com> wrote:
> I want to be able to programmatically access the relation names inside from
> inside the calc_joinrel_size_estimate method (in costsize.c) using the
> RelOptInfo *outer_rel, RelOptInfo *inner_rel arguments. I'm pretty sure I
> need to use the Relids relids variables in the RelOptInfo struct but I'm not
> sure where to go from there.

If you loop through the RelOptInfo->relids with bms_next_member() and
lookup the RangeTblEntry from root->simple_rte_array[] you can get the
"relid", which is the Oid of the relation. You can then call
get_rel_name() on that Oid. You'll also need to ensure the relid
actually belongs to a relation, for this check that the
RangeTblEntry->rtekind is RTE_RELATION. You might also want to think
about schema names since two relations can share the same name in
different schemas.

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


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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: pgsql: When VACUUM or ANALYZE skips a concurrently dropped table,log i
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pgsql: When VACUUM or ANALYZE skips a concurrently dropped table, log i