Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e27f879

Browse files
committed
Turns out it's easy to cache the fmgr function lookup
result, too ... another little bit of speed for SELECT.
1 parent 422221c commit e27f879

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/backend/access/common/printtup.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.40 1999/01/27 00:36:22 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.41 1999/01/27 01:11:43 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -75,7 +75,7 @@ getTypeOutAndElem(Oid type, Oid* typOutput, Oid* typElem)
7575
typedef struct { /* Per-attribute information */
7676
Oid typoutput; /* Oid for the attribute's type output fn */
7777
Oid typelem; /* typelem value to pass to the output fn */
78-
/* more soon... */
78+
FmgrInfo finfo; /* Precomputed call info for typoutput */
7979
} PrinttupAttrInfo;
8080

8181
typedef struct {
@@ -138,8 +138,9 @@ printtup_prepare_info(DR_printtup* myState, TupleDesc typeinfo, int numAttrs)
138138
for (i = 0; i < numAttrs; i++)
139139
{
140140
PrinttupAttrInfo* thisState = myState->myinfo + i;
141-
getTypeOutAndElem((Oid) typeinfo->attrs[i]->atttypid,
142-
&thisState->typoutput, &thisState->typelem);
141+
if (getTypeOutAndElem((Oid) typeinfo->attrs[i]->atttypid,
142+
&thisState->typoutput, &thisState->typelem))
143+
fmgr_info(thisState->typoutput, &thisState->finfo);
143144
}
144145
}
145146

@@ -200,15 +201,14 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver* self)
200201
*/
201202
for (i = 0; i < tuple->t_data->t_natts; ++i)
202203
{
204+
PrinttupAttrInfo* thisState = myState->myinfo + i;
203205
attr = heap_getattr(tuple, i + 1, typeinfo, &isnull);
204206
if (isnull)
205207
continue;
206-
if (OidIsValid(myState->myinfo[i].typoutput))
208+
if (OidIsValid(thisState->typoutput))
207209
{
208-
outputstr = fmgr(myState->myinfo[i].typoutput,
209-
attr,
210-
myState->myinfo[i].typelem,
211-
typeinfo->attrs[i]->atttypmod);
210+
outputstr = (char *) (*fmgr_faddr(&thisState->finfo))
211+
(attr, thisState->typelem, typeinfo->attrs[i]->atttypmod);
212212
#ifdef MULTIBYTE
213213
p = pg_server_to_client(outputstr, strlen(outputstr));
214214
outputlen = strlen(p);

0 commit comments

Comments
 (0)