Why cann't simplify stable function in planning phase?

From: tender wang <tndrwang(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Why cann't simplify stable function in planning phase?
Date: 2023-02-08 08:59:29
Message-ID: CAHewXNnndduJQpLH1pGh0W9Xoe-k63vOx6sO9HxPeYSkpZT-tg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,
In evaluate_function(), I find codes as shown below:

/*
* Ordinarily we are only allowed to simplify immutable functions. But for
* purposes of estimation, we consider it okay to simplify functions that
* are merely stable; the risk that the result might change from planning
* time to execution time is worth taking in preference to not being able
* to estimate the value at all.
*/
if (funcform->provolatile == PROVOLATILE_IMMUTABLE)
/* okay */ ;
else if (context->estimate && funcform->provolatile == PROVOLATILE_STABLE)
/* okay */ ;
else
return NULL;

The codes say that stable function can not be simplified here(e.g. planning
phase).
I want to know the reason why stable function can not be simplified in
planning phase.
Maybe show me a example that it will be incorrect for a query if simplify
stable function in
planning phases.

With kindest regards, tender wang

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2023-02-08 09:03:03 RE: Time delayed LR (WAS Re: logical replication restrictions)
Previous Message o.tselebrovskiy 2023-02-08 08:21:03 A bug with ExecCheckPermissions