Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f1e396

Browse files
committed
Third round of fmgr updates: eliminate calls using fmgr() and
fmgr_faddr() in favor of new-style calls. Lots of cleanup ofsloppy casts to use XXXGetDatum and DatumGetXXX ...
1 parenta12a23f commit0f1e396

File tree

35 files changed

+575
-448
lines changed

35 files changed

+575
-448
lines changed

‎src/backend/access/common/indexvalid.c

Lines changed: 7 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/Attic/indexvalid.c,v 1.24 2000/01/26 05:55:53 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.25 2000/05/30 04:24:27 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -40,7 +40,7 @@ index_keytest(IndexTuple tuple,
4040
{
4141
boolisNull;
4242
Datumdatum;
43-
inttest;
43+
Datumtest;
4444

4545
IncrIndexProcessed();
4646

@@ -62,18 +62,16 @@ index_keytest(IndexTuple tuple,
6262

6363
if (key[0].sk_flags&SK_COMMUTE)
6464
{
65-
test= (*(fmgr_faddr(&key[0].sk_func)))
66-
(DatumGetPointer(key[0].sk_argument),
67-
datum) ?1 :0;
65+
test=FunctionCall2(&key[0].sk_func,
66+
key[0].sk_argument,datum);
6867
}
6968
else
7069
{
71-
test= (*(fmgr_faddr(&key[0].sk_func)))
72-
(datum,
73-
DatumGetPointer(key[0].sk_argument)) ?1 :0;
70+
test=FunctionCall2(&key[0].sk_func,
71+
datum,key[0].sk_argument);
7472
}
7573

76-
if (!test== !(key[0].sk_flags&SK_NEGATE))
74+
if (DatumGetBool(test)==!!(key[0].sk_flags&SK_NEGATE))
7775
return false;
7876

7977
scanKeySize-=1;

‎src/backend/access/common/printtup.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.52 2000/01/26 05:55:53 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.53 2000/05/30 04:24:27 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -206,8 +206,10 @@ printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
206206
continue;
207207
if (OidIsValid(thisState->typoutput))
208208
{
209-
outputstr= (char*) (*fmgr_faddr(&thisState->finfo))
210-
(attr,thisState->typelem,typeinfo->attrs[i]->atttypmod);
209+
outputstr=DatumGetCString(FunctionCall3(&thisState->finfo,
210+
attr,
211+
ObjectIdGetDatum(thisState->typelem),
212+
Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
211213
pq_sendcountedtext(&buf,outputstr,strlen(outputstr));
212214
pfree(outputstr);
213215
}
@@ -295,8 +297,10 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self)
295297
if (getTypeOutAndElem((Oid)typeinfo->attrs[i]->atttypid,
296298
&typoutput,&typelem))
297299
{
298-
value=fmgr(typoutput,attr,typelem,
299-
typeinfo->attrs[i]->atttypmod);
300+
value=DatumGetCString(OidFunctionCall3(typoutput,
301+
attr,
302+
ObjectIdGetDatum(typelem),
303+
Int32GetDatum(typeinfo->attrs[i]->atttypmod)));
300304
printatt((unsigned)i+1,typeinfo->attrs[i],value);
301305
pfree(value);
302306
}

‎src/backend/access/gist/gist.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.54 2000/05/3000:49:39 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.55 2000/05/3004:24:28 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -551,10 +551,16 @@ gistAdjustKeys(Relation r,
551551
ev1p=&((GISTENTRY*)VARDATA(evec))[1];
552552

553553
/* form union of decompressed entries */
554-
datum= (*fmgr_faddr(&giststate->unionFn)) (evec,&datumsize);
554+
datum= (char*)
555+
DatumGetPointer(FunctionCall2(&giststate->unionFn,
556+
PointerGetDatum(evec),
557+
PointerGetDatum(&datumsize)));
555558

556559
/* did union leave decompressed version of oldud unchanged? */
557-
(*fmgr_faddr(&giststate->equalFn)) (ev0p->pred,datum,&result);
560+
FunctionCall3(&giststate->equalFn,
561+
PointerGetDatum(ev0p->pred),
562+
PointerGetDatum(datum),
563+
PointerGetDatum(&result));
558564
if (!result)
559565
{
560566
TupleDesctd=RelationGetDescr(r);
@@ -727,7 +733,9 @@ gistSplit(Relation r,
727733
VARSIZE(entryvec)= (maxoff+2)*sizeof(GISTENTRY)+VARHDRSZ;
728734

729735
/* now let the user-defined picksplit function set up the split vector */
730-
(*fmgr_faddr(&giststate->picksplitFn)) (entryvec,&v);
736+
FunctionCall2(&giststate->picksplitFn,
737+
PointerGetDatum(entryvec),
738+
PointerGetDatum(&v));
731739

732740
/* compress ldatum and rdatum */
733741
gistcentryinit(giststate,&tmpentry,v.spl_ldatum, (Relation)NULL,
@@ -1054,7 +1062,10 @@ gistchoose(Relation r, Page p, IndexTuple it,/* it has compressed entry */
10541062
size=IndexTupleSize(datum)-sizeof(IndexTupleData);
10551063
datum+=sizeof(IndexTupleData);
10561064
gistdentryinit(giststate,&entry,datum,r,p,i,size, FALSE);
1057-
(*fmgr_faddr(&giststate->penaltyFn)) (&entry,&identry,&usize);
1065+
FunctionCall3(&giststate->penaltyFn,
1066+
PointerGetDatum(&entry),
1067+
PointerGetDatum(&identry),
1068+
PointerGetDatum(&usize));
10581069
if (which_grow<0||usize<which_grow)
10591070
{
10601071
which=i;
@@ -1237,7 +1248,9 @@ gistdentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, Relation r,
12371248
gistentryinit(*e,pr,r,pg,o,b,l);
12381249
if (giststate->haskeytype)
12391250
{
1240-
dep= (GISTENTRY*) ((*fmgr_faddr(&giststate->decompressFn)) (e));
1251+
dep= (GISTENTRY*)
1252+
DatumGetPointer(FunctionCall1(&giststate->decompressFn,
1253+
PointerGetDatum(e)));
12411254
gistentryinit(*e,dep->pred,dep->rel,dep->page,dep->offset,dep->bytes,
12421255
dep->leafkey);
12431256
if (dep!=e)
@@ -1258,7 +1271,9 @@ gistcentryinit(GISTSTATE *giststate, GISTENTRY *e, char *pr, Relation r,
12581271
gistentryinit(*e,pr,r,pg,o,b,l);
12591272
if (giststate->haskeytype)
12601273
{
1261-
cep= (GISTENTRY*) ((*fmgr_faddr(&giststate->compressFn)) (e));
1274+
cep= (GISTENTRY*)
1275+
DatumGetPointer(FunctionCall1(&giststate->compressFn,
1276+
PointerGetDatum(e)));
12621277
gistentryinit(*e,cep->pred,cep->rel,cep->page,cep->offset,cep->bytes,
12631278
cep->leafkey);
12641279
if (cep!=e)

‎src/backend/access/gist/gistget.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ gistindex_keytest(IndexTuple tuple,
227227
{
228228
boolisNull;
229229
Datumdatum;
230-
inttest;
230+
Datumtest;
231231
GISTENTRYde;
232232

233233
IncrIndexProcessed();
@@ -251,19 +251,20 @@ gistindex_keytest(IndexTuple tuple,
251251

252252
if (key[0].sk_flags&SK_COMMUTE)
253253
{
254-
test= (*fmgr_faddr(&key[0].sk_func))
255-
(DatumGetPointer(key[0].sk_argument),
256-
&de,key[0].sk_procedure) ?1 :0;
254+
test=FunctionCall3(&key[0].sk_func,
255+
key[0].sk_argument,
256+
PointerGetDatum(&de),
257+
ObjectIdGetDatum(key[0].sk_procedure));
257258
}
258259
else
259260
{
260-
test=(*fmgr_faddr(&key[0].sk_func))
261-
(&de,
262-
DatumGetPointer(key[0].sk_argument),
263-
key[0].sk_procedure) ?1 :0;
261+
test=FunctionCall3(&key[0].sk_func,
262+
PointerGetDatum(&de),
263+
key[0].sk_argument,
264+
ObjectIdGetDatum(key[0].sk_procedure));
264265
}
265266

266-
if (!test== !(key[0].sk_flags&SK_NEGATE))
267+
if (DatumGetBool(test)==!!(key[0].sk_flags&SK_NEGATE))
267268
return false;
268269

269270
scanKeySize-=1;

‎src/backend/access/hash/hashutil.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.23 2000/01/26 05:55:55 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.24 2000/05/30 04:24:31 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -91,10 +91,8 @@ _hash_call(Relation rel, HashMetaPage metap, Datum key)
9191
{
9292
uint32n;
9393
Bucketbucket;
94-
RegProcedureproc;
9594

96-
proc=metap->hashm_procid;
97-
n= (uint32)fmgr(proc,key);
95+
n=DatumGetUInt32(OidFunctionCall1(metap->hashm_procid,key));
9896
bucket=n&metap->hashm_highmask;
9997
if (bucket>metap->hashm_maxbucket)
10098
bucket=bucket&metap->hashm_lowmask;

‎src/backend/access/index/indexam.c

Lines changed: 26 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/index/indexam.c,v 1.43 2000/05/28 17:55:52 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.44 2000/05/30 04:24:32 tgl Exp $
1212
*
1313
* INTERFACE ROUTINES
1414
*index_open- open an index relation by relationId
@@ -195,7 +195,13 @@ index_insert(Relation relation,
195195
* ----------------
196196
*/
197197
specificResult= (InsertIndexResult)
198-
fmgr(procedure,relation,datum,nulls,heap_t_ctid,heapRel,NULL);
198+
DatumGetPointer(OidFunctionCall6(procedure,
199+
PointerGetDatum(relation),
200+
PointerGetDatum(datum),
201+
PointerGetDatum(nulls),
202+
PointerGetDatum(heap_t_ctid),
203+
PointerGetDatum(heapRel),
204+
PointerGetDatum(NULL)));
199205

200206
/* must be pfree'ed */
201207
returnspecificResult;
@@ -213,7 +219,9 @@ index_delete(Relation relation, ItemPointer indexItem)
213219
RELATION_CHECKS;
214220
GET_REL_PROCEDURE(delete,amdelete);
215221

216-
fmgr(procedure,relation,indexItem);
222+
OidFunctionCall2(procedure,
223+
PointerGetDatum(relation),
224+
PointerGetDatum(indexItem));
217225
}
218226

219227
/* ----------------
@@ -245,7 +253,11 @@ index_beginscan(Relation relation,
245253
LockRelation(relation,AccessShareLock);
246254

247255
scandesc= (IndexScanDesc)
248-
fmgr(procedure,relation,scanFromEnd,numberOfKeys,key);
256+
DatumGetPointer(OidFunctionCall4(procedure,
257+
PointerGetDatum(relation),
258+
BoolGetDatum(scanFromEnd),
259+
UInt16GetDatum(numberOfKeys),
260+
PointerGetDatum(key)));
249261

250262
returnscandesc;
251263
}
@@ -262,7 +274,10 @@ index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key)
262274
SCAN_CHECKS;
263275
GET_SCAN_PROCEDURE(rescan,amrescan);
264276

265-
fmgr(procedure,scan,scanFromEnd,key);
277+
OidFunctionCall3(procedure,
278+
PointerGetDatum(scan),
279+
BoolGetDatum(scanFromEnd),
280+
PointerGetDatum(key));
266281
}
267282

268283
/* ----------------
@@ -277,7 +292,7 @@ index_endscan(IndexScanDesc scan)
277292
SCAN_CHECKS;
278293
GET_SCAN_PROCEDURE(endscan,amendscan);
279294

280-
fmgr(procedure,scan);
295+
OidFunctionCall1(procedure,PointerGetDatum(scan));
281296

282297
/* Release lock and refcount acquired by index_beginscan */
283298

@@ -301,7 +316,7 @@ index_markpos(IndexScanDesc scan)
301316
SCAN_CHECKS;
302317
GET_SCAN_PROCEDURE(markpos,ammarkpos);
303318

304-
fmgr(procedure,scan);
319+
OidFunctionCall1(procedure,PointerGetDatum(scan));
305320
}
306321

307322
/* ----------------
@@ -316,7 +331,7 @@ index_restrpos(IndexScanDesc scan)
316331
SCAN_CHECKS;
317332
GET_SCAN_PROCEDURE(restrpos,amrestrpos);
318333

319-
fmgr(procedure,scan);
334+
OidFunctionCall1(procedure,PointerGetDatum(scan));
320335
}
321336

322337
/* ----------------
@@ -350,7 +365,9 @@ index_getnext(IndexScanDesc scan,
350365
* ----------------
351366
*/
352367
result= (RetrieveIndexResult)
353-
(*fmgr_faddr(&scan->fn_getnext)) (scan,direction);
368+
DatumGetPointer(FunctionCall2(&scan->fn_getnext,
369+
PointerGetDatum(scan),
370+
Int32GetDatum(direction)));
354371

355372
returnresult;
356373
}

‎src/backend/access/index/istrat.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.43 2000/05/28 17:55:52 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.44 2000/05/30 04:24:32 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -217,15 +217,14 @@ StrategyTermEvaluate(StrategyTerm term,
217217
Datumleft,
218218
Datumright)
219219
{
220+
boolresult= false;
220221
Indexindex;
221-
longtmpres=0;
222-
boolresult=0;
223222
StrategyOperatoroperator;
224-
ScanKeyentry;
225223

226224
for (index=0,operator=&term->operatorData[0];
227225
index<term->degree;index+=1,operator+=1)
228226
{
227+
ScanKeyentry;
229228

230229
entry=&map->entry[operator->strategy-1];
231230

@@ -234,31 +233,29 @@ StrategyTermEvaluate(StrategyTerm term,
234233
switch (operator->flags ^entry->sk_flags)
235234
{
236235
case0x0:
237-
tmpres=(long)FMGR_PTR2(&entry->sk_func,
238-
left,right);
236+
result=DatumGetBool(FunctionCall2(&entry->sk_func,
237+
left,right));
239238
break;
240239

241240
caseSK_NEGATE:
242-
tmpres=(long) !FMGR_PTR2(&entry->sk_func,
243-
left,right);
241+
result=!DatumGetBool(FunctionCall2(&entry->sk_func,
242+
left,right));
244243
break;
245244

246245
caseSK_COMMUTE:
247-
tmpres=(long)FMGR_PTR2(&entry->sk_func,
248-
right,left);
246+
result=DatumGetBool(FunctionCall2(&entry->sk_func,
247+
right,left));
249248
break;
250249

251250
caseSK_NEGATE |SK_COMMUTE:
252-
tmpres=(long) !FMGR_PTR2(&entry->sk_func,
253-
right,left);
251+
result=!DatumGetBool(FunctionCall2(&entry->sk_func,
252+
right,left));
254253
break;
255254

256255
default:
257-
elog(FATAL,"StrategyTermEvaluate: impossible case %d",
256+
elog(ERROR,"StrategyTermEvaluate: impossible case %d",
258257
operator->flags ^entry->sk_flags);
259258
}
260-
261-
result= (bool)tmpres;
262259
if (!result)
263260
returnresult;
264261
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp