1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Implement constant-expression simplification per Bernard

Frankpitt, plus some improvements from yours truly.  The simplifier depends
on the proiscachable field of pg_proc to tell it whether a function is
safe to pre-evaluate --- things like nextval() are not, for example.
Update pg_proc.h to contain reasonable cacheability information; as of
6.5.* hardly any functions were marked cacheable.  I may have erred too
far in the other direction; see recent mail to pghackers for more info.
This update does not force an initdb, exactly, but you won't see much
benefit from the simplifier until you do one.
This commit is contained in:
Tom Lane
1999-09-26 02:28:44 +00:00
parent 95d3d468ce
commit 40f6524161
7 changed files with 1359 additions and 938 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.48 1999/08/21 03:48:57 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.49 1999/09/26 02:28:21 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -223,6 +223,22 @@ _equalAggref(Aggref *a, Aggref *b)
return true;
}
static bool
_equalSubLink(SubLink *a, SubLink *b)
{
if (a->subLinkType != b->subLinkType)
return false;
if (a->useor != b->useor)
return false;
if (!equal(a->lefthand, b->lefthand))
return false;
if (!equal(a->oper, b->oper))
return false;
if (!equal(a->subselect, b->subselect))
return false;
return true;
}
static bool
_equalArray(Array *a, Array *b)
{
@ -393,7 +409,7 @@ _equalSubPlan(SubPlan *a, SubPlan *b)
if (a->plan_id != b->plan_id)
return false;
if (!equal(a->sublink->oper, b->sublink->oper))
if (!equal(a->sublink, b->sublink))
return false;
return true;
@ -713,6 +729,9 @@ equal(void *a, void *b)
case T_Aggref:
retval = _equalAggref(a, b);
break;
case T_SubLink:
retval = _equalSubLink(a, b);
break;
case T_Func:
retval = _equalFunc(a, b);
break;