Re: [HACKERS] Make subquery alias optional in FROM clause

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] Make subquery alias optional in FROM clause
Дата
Msg-id 4533.1487859658@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] Make subquery alias optional in FROM clause  (Bernd Helmle <mailings@oopsware.de>)
Ответы Re: [HACKERS] Make subquery alias optional in FROM clause  (Robert Haas <robertmhaas@gmail.com>)
Re: [HACKERS] Make subquery alias optional in FROM clause  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
Bernd Helmle <mailings@oopsware.de> writes:
> Right, i'm going to give it a try then. Currently i see these options:

> * Validate any generated alias against a list of explicit alias names.

> This means we have to collect explicit alias names in, say a hashtable,
> and validate a generated name against potential collisions and retry.

TBH I think a hashtable is overkill.  You could just run through the FROM
clause and see what's there (compare what happens in ruleutils.c when it
has to invent an alias).  The difficulty is not so much with time taken
as that it's not very clear how to manage things when the querytree is
only half-transformed.  You don't really want this code having to deal
with both transformed and untransformed querytrees, much less knowing
which parts are where.

Maybe the best answer is to not do it immediately when transforming the
subselect's RTE, but to go back after we've finished transforming the
entire FROM clause and add aliases to any RTEs that lack them.  I think
probably at that point you could just examine the RTE list and not worry
about any jointree data structures at all.  It might be worth adding a
flag to ParseState to remember whether any aliases require assignment, so
that you could skip looking in the standard case.

> * Don't force/generate an alias at all.

> I've no idea for this yet and Tom already was concerned what this might
> break. There are several places in the transform phase where the
> refnames are required (e.g. isLockedRefname()).

Yeah.  This would be cleaner in some sense but also a lot more delicate.
Not sure it's worth the trouble.
        regards, tom lane



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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: [HACKERS] Automatic cleanup of oldest WAL segments withpg_receivexlog
Следующее
От: Andrew Dunstan
Дата:
Сообщение: user mapping messages