1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-16 15:02:33 +03:00

Modify fmgr so that internal name (compiler name) of a built-in

function is found in prosrc field of pg_proc, not proname.  This allows
multiple aliases of a built-in to all be implemented as direct builtins,
without needing a level of indirection through an SQL function.  Replace
existing SQL alias functions with builtin entries accordingly.
Save a few K by not storing string names of builtin functions in fmgr's
internal table (if you really want 'em, get 'em from pg_proc...).
Update opr_sanity with a few more cross-checks.
This commit is contained in:
Tom Lane
1999-03-29 01:30:45 +00:00
parent fdf6be80f9
commit c537d4295a
6 changed files with 1223 additions and 1026 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.22 1999/02/13 23:19:52 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.23 1999/03/29 01:30:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -169,14 +169,20 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo)
finfo->fn_plhandler = NULL;
finfo->fn_oid = procedureId;
if (!(fcp = fmgr_isbuiltin(procedureId)))
if ((fcp = fmgr_isbuiltin(procedureId)) != NULL)
{
/* Fast path for builtin functions: don't bother consulting pg_proc */
finfo->fn_addr = fcp->func;
finfo->fn_nargs = fcp->nargs;
}
else
{
procedureTuple = SearchSysCacheTuple(PROOID,
ObjectIdGetDatum(procedureId),
ObjectIdGetDatum(procedureId),
0, 0, 0);
if (!HeapTupleIsValid(procedureTuple))
{
elog(ERROR, "fmgr_info: function %d: cache lookup failed\n",
elog(ERROR, "fmgr_info: function %d: cache lookup failed",
procedureId);
}
procedureStruct = (FormData_pg_proc *) GETSTRUCT(procedureTuple);
@@ -190,11 +196,12 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo)
switch (language)
{
case INTERNALlanguageId:
finfo->fn_addr = fmgr_lookupByName(procedureStruct->proname.data);
if (!finfo->fn_addr)
elog(ERROR, "fmgr_info: function %s: not in internal table",
procedureStruct->proname.data);
finfo->fn_nargs = procedureStruct->pronargs;
/*
* Since we already tried to look up the OID as a builtin
* function, we should never get here...
*/
elog(ERROR, "fmgr_info: function %d: not in internal table",
procedureId);
break;
case ClanguageId:
finfo->fn_addr = fmgr_dynamic(procedureId, &(finfo->fn_nargs));
@@ -239,11 +246,6 @@ fmgr_info(Oid procedureId, FmgrInfo *finfo)
break;
}
}
else
{
finfo->fn_addr = fcp->func;
finfo->fn_nargs = fcp->nargs;
}
}
/*