Retrieving Alias Name

Поиск
Список
Период
Сортировка
От Walter Cai
Тема Retrieving Alias Name
Дата
Msg-id CAE-8Rkn3O4XCuFcjVJJbu3dto03f_3+tjkKvWvbnmaGwRUqVRw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Retrieving Alias Name  (Julien Rouhaud <rjuju123@gmail.com>)
Список pgsql-hackers
Hi,

I'm currently using a (very rough) scheme to retrieve relation names from a PlannerInfo, and a RelOptInfo struct:

PlannerInfo *root
RelOptInfo *inner_rel

//...

RangeTblEntry *rte;
int x = -1;
while ((x = bms_next_member(inner_rel->relids, x)) >= 0)
{
    rte = root->simple_rte_array[x];
    if (rte->rtekind == RTE_RELATION)
    {
        char *rel_name = get_rel_name(rte->relid);
        // do stuff...
    }
}

However, I now realize it would be better to access aliases as they appear in the SQL query. For instance, if the query contains "... FROM rel_name AS rel_alias ..." I would like to retrieve `rel_alias` instead of `rel_name`.

Is it possible to derive the alias in a similar way?

For context: this code is being inserted into src/backend/optimizer/path/costsize.c and specifically in the calc_joinrel_size_estimate method.

Thanks in advance,
Walter

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

Предыдущее
От: Chapman Flack
Дата:
Сообщение: Re: Remove Deprecated Exclusive Backup Mode
Следующее
От: Robert Haas
Дата:
Сообщение: Re: ATTACH/DETACH PARTITION CONCURRENTLY