Re: A modest proposal: make parser/rewriter/planner inputs read-only

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrei Lepikhov <lepihov(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: A modest proposal: make parser/rewriter/planner inputs read-only
Date: 2025-04-16 16:22:42
Message-ID: 1915837.1744820562@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrei Lepikhov <lepihov(at)gmail(dot)com> writes:
> I just want to understand how your idea will work. The query_planner
> does the job for subqueries separately. If a query is transformed in
> some way (let's say, an unnecessary join is deleted), we need to change
> references in the parse tree of another subquery, or it will not find
> the reference at the moment of planning, right?

Don't see why. If we're separately planning a subquery, we would
not dare to change anything about its outputs, just as we would
not make a change that affects the topmost level's outputs. I don't
believe there's anything right now that requires a recursive
subquery_planner call to change the outer parsetree, and this idea
wouldn't affect that.

Now, subquery_planner does have side effects on the PlannerGlobal
struct, but that's planner-local data, not an input to the planner.

Maybe we would like to have some enforced contract about what
subquery_planner can and can't touch in the outer planner level's
data, but I'm not feeling a great need for that right now.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-04-16 16:46:42 Re: pipelining in psql, commit 41625ab
Previous Message Michael Paquier 2025-04-16 16:18:01 Re: Add Pipelining support in psql