summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>1999-03-29 01:30:45 +0000
committerTom Lane <tgl@sss.pgh.pa.us>1999-03-29 01:30:45 +0000
commitc537d4295a1c2fe30ea4782a91da24ec9ce743e0 (patch)
tree041a549410dcfdaa126b3282da8f0adbd74412f7 /src/backend
parentfdf6be80f993d2908f794c0a33aedff479a92813 (diff)
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.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/utils/Gen_fmgrtab.sh.in39
-rw-r--r--src/backend/utils/fmgr/fmgr.c30
2 files changed, 37 insertions, 32 deletions
diff --git a/src/backend/utils/Gen_fmgrtab.sh.in b/src/backend/utils/Gen_fmgrtab.sh.in
index 40f1dccb5dc..24bd9fdde14 100644
--- a/src/backend/utils/Gen_fmgrtab.sh.in
+++ b/src/backend/utils/Gen_fmgrtab.sh.in
@@ -8,7 +8,7 @@
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.13 1999/01/25 00:44:53 tgl Exp $
+# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.14 1999/03/29 01:30:35 tgl Exp $
#
# NOTES
# Passes any -D options on to cpp prior to generating the list
@@ -83,7 +83,7 @@ cat > $HFILE <<FuNkYfMgRsTuFf
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: Gen_fmgrtab.sh.in,v 1.13 1999/01/25 00:44:53 tgl Exp $
+ * $Id: Gen_fmgrtab.sh.in,v 1.14 1999/03/29 01:30:35 tgl Exp $
*
* NOTES
* ******************************
@@ -172,10 +172,19 @@ FmgrInfo *fmgr_pl_finfo;
#define SEL_CONSTANT 1 /* constant does not vary (not a parameter) */
#define SEL_RIGHT 2 /* constant appears to right of operator */
+/*
+ * Constant macros for the OIDs of entries in pg_proc.
+ * NOTE: if the same "proname" is used for more than one
+ * internal-function entry in pg_proc, the equivalent macro
+ * will be defined with the lowest OID among those entries.
+ */
FuNkYfMgRsTuFf
-awk '{ print $2, $1; }' $RAWFILE | \
-@TR@ @TRARGS@ | \
-sed -e 's/^/#define F_/' >> $HFILE
+
+@TR@ @TRARGS@ < $RAWFILE | \
+awk '
+BEGIN { OFS = ""; }
+ { if (seenit[$2]++ == 0) print "#define F_", $2, " ", $1; }' >> $HFILE
+
cat >> $HFILE <<FuNkYfMgRsTuFf
#endif /* FMGR_H */
@@ -197,7 +206,7 @@ cat > $TABCFILE <<FuNkYfMgRtAbStUfF
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.13 1999/01/25 00:44:53 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.14 1999/03/29 01:30:35 tgl Exp $
*
* NOTES
*
@@ -235,12 +244,16 @@ cat > $TABCFILE <<FuNkYfMgRtAbStUfF
#include "utils/fmgrtab.h"
FuNkYfMgRtAbStUfF
-awk '{ print "extern char *" $2 "();"; }' $RAWFILE >> $TABCFILE
+
+awk '{ print "extern char *", $(NF-1), "();"; }' $RAWFILE >> $TABCFILE
+
cat >> $TABCFILE <<FuNkYfMgRtAbStUfF
static FmgrCall fmgr_builtins[] = {
FuNkYfMgRtAbStUfF
-awk '{ printf (" {%d , %d , %s, \"%s\" },\n"), $1, $8, $2, $2 }' $RAWFILE >> $TABCFILE
+
+awk '{ printf (" {%d, %d, %s },\n"), $1, $8, $(NF-1) }' $RAWFILE >> $TABCFILE
+
cat >> $TABCFILE <<FuNkYfMgRtAbStUfF
/* guardian value */
#ifndef WIN32
@@ -276,16 +289,6 @@ FmgrCall *fmgr_isbuiltin(Oid id)
return (FmgrCall *) NULL;
}
-func_ptr fmgr_lookupByName(char *name)
-{
- int i;
- for (i=0; i<FMGR_NBUILTINS; i++) {
- if (strcmp(name,fmgr_builtins[i].funcName) == 0)
- return(fmgr_builtins[i].func);
- }
- return((func_ptr) NULL);
-}
-
FuNkYfMgRtAbStUfF
rm -f $RAWFILE
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index 2e663657b6b..f1cbede894c 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -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;
- }
}
/*