Access root->simple_rte_array instead of Query->rtable for 2 more cases.

Started by Andy Fanover 5 years ago2 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t44284
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 04:58 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t44284_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t44284_1 && git checkout t44284_1

Patchset v1 (message #1) is on t44284_1

Jump to latest
#1Andy Fan
zhihui.fan1213@gmail.com

When I am understanding the relationship between Query->rtable and
root->simple_rte_array, I'd like to assume that Query->rtable should be
never used
when root->simple_rte_array is ready. I mainly checked two places,
make_one_rel and
create_plan with the below hacks.

{
List *l = root->parse->rtable;
root->parse->rtable = NIL;
make_one_rel.. or create_plan_recurse..
root->parse->rtable = l;
}

Then I found adjust_appendrel_attrs_mutator and infer_arbiter_indexes still
use it. The attached patch fixed it by replacing the rt_fetch with
planner_rt_fetch,
all the tests passed.

--
Best Regards
Andy Fan (https://www.aliyun.com/)

Attachments:

t44284_1
v1-0001-Use-planner_rt_fetch-instead-of-rt_fetch-when-roo.patchapplication/octet-stream; name=v1-0001-Use-planner_rt_fetch-instead-of-rt_fetch-when-roo.patchDownload+3-4
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andy Fan (#1)
Re: Access root->simple_rte_array instead of Query->rtable for 2 more cases.

Andy Fan <zhihui.fan1213@gmail.com> writes:

When I am understanding the relationship between Query->rtable and
root->simple_rte_array, I'd like to assume that Query->rtable should be
never used
when root->simple_rte_array is ready.

TBH, now that Lists are really arrays, there's basically no performance
advantage to be gained by fooling with this. I've considered ripping
out simple_rte_array, but haven't felt that the code churn would be
worth it.

regards, tom lane