]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Expand virtual generated columns before sublink pull-up
authorRichard Guo <rguo@postgresql.org>
Tue, 22 Jul 2025 02:19:17 +0000 (11:19 +0900)
committerRichard Guo <rguo@postgresql.org>
Tue, 22 Jul 2025 02:19:17 +0000 (11:19 +0900)
commite0d05295268e3811e6743403cb779f21d1662426
treedec1e181c8c15a6a97d6a35e4b02e6092b545ca5
parent0810fbb02dbe70b8a7a7bcc51580827b8bbddbdc
Expand virtual generated columns before sublink pull-up

Currently, we expand virtual generated columns after we have pulled up
any SubLinks within the query's quals.  This ensures that the virtual
generated column references within SubLinks that should be transformed
into joins are correctly expanded.  This approach works well and has
posed no issues.

In an upcoming patch, we plan to centralize the collection of catalog
information needed early in the planner.  This will help avoid
repeated table_open/table_close calls for relations in the rangetable.
Since this information is required during sublink pull-up, we are
moving the expansion of virtual generated columns to occur beforehand.

To achieve this, if any EXISTS SubLinks can be pulled up, their
rangetables are processed just before pulling them up.

Author: Richard Guo <guofenglinux@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAMbWs4-bFJ1At4btk5wqbezdu8PLtQ3zv-aiaY3ry9Ymm=jgFQ@mail.gmail.com
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/prep/prepjointree.c
src/include/optimizer/prep.h
src/test/regress/expected/generated_virtual.out
src/test/regress/sql/generated_virtual.sql