The const expression evaluation routine should always return a copy

Поиск
Список
Период
Сортировка
От Andrei Lepikhov
Тема The const expression evaluation routine should always return a copy
Дата
Msg-id 2fcdf4d0-5190-42b8-9e7c-ad950354234c@postgrespro.ru
обсуждение исходный текст
Ответы Re: The const expression evaluation routine should always return a copy  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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
Вложения

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: Streaming I/O, vectored I/O (WIP)
Следующее
От: Nathan Bossart
Дата:
Сообщение: Re: cleanup patches for dshash