From: | Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | The const expression evaluation routine should always return a copy |
Date: | 2024-02-27 04:08:31 |
Message-ID: | 2fcdf4d0-5190-42b8-9e7c-ad950354234c@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
IMO, the routine eval_const_expressions_mutator contains some stale code:
case T_SubPlan:
case T_AlternativeSubPlan:
/*
* Return a SubPlan unchanged --- too late to do anything with it.
*
* XXX should we ereport() here instead? Probably this routine
* should never be invoked after SubPlan creation.
*/
return node;
At least, this code could be achieved with estimate_expression_value().
So, we should fix the comment. But maybe we need to do a bit more.
According to the mutator idea, only the Query node is returned
unchanged. If the Subplan node is on top of the expression, the call
above returns the same node, which may be unconventional.
I'm not totally sure about the impossibility of constantifying SubPlan:
we already have InitPlans for uncorrelated subplans. Maybe something
about parameters that can be estimated as constants at this level and,
as a result, allow to return a Const instead of SubPlan?
But at least we can return a flat copy of the SubPplan node just for the
convention — the same thing for the AlternativeSubPlan. See the patch in
the attachment.
--
regards,
Andrei Lepikhov
Postgres Professional
Attachment | Content-Type | Size |
---|---|---|
0001-Force-eval_const_expressions_mutator-to-return-a-cop.patch | text/plain | 1.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Nathan Bossart | 2024-02-27 04:52:13 | Re: cleanup patches for dshash |
Previous Message | Robert Haas | 2024-02-27 04:02:48 | Re: Streaming I/O, vectored I/O (WIP) |