pgsql: Avoid passing query tlist around separately fromroot->processed

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Avoid passing query tlist around separately fromroot->processed
Дата
Msg-id E1h9Bsh-0001k6-KZ@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Avoid passing query tlist around separately from root->processed_tlist.

In the dim past, the planner kept the fully-processed version of the query
targetlist (the result of preprocess_targetlist) in grouping_planner's
local variable "tlist", and only grudgingly passed it to individual other
routines as needed.  Later we discovered a need to still have it available
after grouping_planner finishes, and invented the root->processed_tlist
field for that purpose, but it wasn't used internally to grouping_planner;
the tlist was still being passed around separately in the same places as
before.

Now comes a proposed patch to allow appendrel expansion to add entries
to the processed tlist, well after preprocess_targetlist has finished
its work.  To avoid having to pass around the tlist explicitly, it's
proposed to allow appendrel expansion to modify root->processed_tlist.
That makes aliasing the tlist with assorted parameters and local
variables really scary.  It would accidentally work as long as the
tlist is initially nonempty, because then the List header won't move
around, but it's not exactly hard to think of ways for that to break.
Aliased values are poor programming practice anyway.

Hence, get rid of local variables and parameters that can be identified
with root->processed_tlist, in favor of just using that field directly.
And adjust comments to match.  (Some of the new comments speak as though
it's already possible for appendrel expansion to modify the tlist; that's
not true yet, but will happen in a later patch.)

Discussion: https://postgr.es/m/9d7c5112-cb99-6a47-d3be-cf1ee6862a1d@lab.ntt.co.jp

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/333ed246c6f351c4e8fe22c764b97793c4101b00

Modified Files
--------------
src/backend/optimizer/plan/planagg.c  | 19 +++++-----
src/backend/optimizer/plan/planmain.c |  6 ++--
src/backend/optimizer/plan/planner.c  | 65 +++++++++++++----------------------
src/include/nodes/pathnodes.h         |  9 +++--
src/include/optimizer/planmain.h      |  4 +--
5 files changed, 45 insertions(+), 58 deletions(-)


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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: pgsql: pgbench: doExecuteCommand -> executeMetaCommand
Следующее
От: Tomas Vondra
Дата:
Сообщение: pgsql: Add support for multivariate MCV lists