]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Turns out it's easy to cache the fmgr function lookup
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 27 Jan 1999 01:11:43 +0000 (01:11 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 27 Jan 1999 01:11:43 +0000 (01:11 +0000)
result, too ... another little bit of speed for SELECT.

src/backend/access/common/printtup.c

index 91273e4933f3c3364621a3fcd36e617f6ec6f78b..94c4d013857f672ab34b7aaed123873261179c15 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.40 1999/01/27 00:36:22 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.41 1999/01/27 01:11:43 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -75,7 +75,7 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem)
 typedef struct {                               /* Per-attribute information */
        Oid                     typoutput;              /* Oid for the attribute's type output fn */
        Oid                     typelem;                /* typelem value to pass to the output fn */
-       /* more soon... */
+       FmgrInfo        finfo;                  /* Precomputed call info for typoutput */
 } PrinttupAttrInfo;
 
 typedef struct {
@@ -138,8 +138,9 @@ printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs)
        for (i = 0; i < numAttrs; i++)
        {
                PrinttupAttrInfo* thisState = myState->myinfo + i;
-               getTypeOutAndElem((Oid) typeinfo->attrs[i]->atttypid,
-                                                 &thisState->typoutput, &thisState->typelem);
+               if (getTypeOutAndElem((Oid) typeinfo->attrs[i]->atttypid,
+                                                         &thisState->typoutput, &thisState->typelem))
+                       fmgr_info(thisState->typoutput, &thisState->finfo);
        }
 }
 
@@ -200,15 +201,14 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
         */
        for (i = 0; i < tuple->t_data->t_natts; ++i)
        {
+               PrinttupAttrInfo* thisState = myState->myinfo + i;
                attr = heap_getattr(tuple, i + 1, typeinfo, &isnull);
                if (isnull)
                        continue;
-               if (OidIsValid(myState->myinfo[i].typoutput))
+               if (OidIsValid(thisState->typoutput))
                {
-                       outputstr = fmgr(myState->myinfo[i].typoutput,
-                                                        attr,
-                                                        myState->myinfo[i].typelem,
-                                                        typeinfo->attrs[i]->atttypmod);
+                       outputstr = (char *) (*fmgr_faddr(&thisState->finfo))
+                               (attr, thisState->typelem, typeinfo->attrs[i]->atttypmod);
 #ifdef MULTIBYTE
                        p = pg_server_to_client(outputstr, strlen(outputstr));
                        outputlen = strlen(p);