diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-05-28 17:56:29 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-05-28 17:56:29 +0000 |
commit | 0a7fb4e9184539afcb6fed0f1d2bc0abddc2b0a6 (patch) | |
tree | affcce1c5b6367468fb6dcfd2790585f2e967629 /src/backend/access/index/indexam.c | |
parent | 5005bb060b3f3a82cd1bd662c7f8946c9be59db5 (diff) | |
download | postgresql-0a7fb4e9184539afcb6fed0f1d2bc0abddc2b0a6.tar.gz postgresql-0a7fb4e9184539afcb6fed0f1d2bc0abddc2b0a6.zip |
First round of changes for new fmgr interface. fmgr itself and the
key call sites are changed, but most called functions are still oldstyle.
An exception is that the PL managers are updated (so, for example, NULL
handling now behaves as expected in plperl and plpgsql functions).
NOTE initdb is forced due to added column in pg_proc.
Diffstat (limited to 'src/backend/access/index/indexam.c')
-rw-r--r-- | src/backend/access/index/indexam.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index e0672667c7f..43d8a3850f5 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.42 2000/04/12 17:14:47 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.43 2000/05/28 17:55:52 tgl Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relationId @@ -418,28 +418,43 @@ GetIndexValue(HeapTuple tuple, bool *attNull) { Datum returnVal; - bool isNull = FALSE; if (PointerIsValid(fInfo) && FIgetProcOid(fInfo) != InvalidOid) { - int i; - Datum *attData = (Datum *) palloc(FIgetnArgs(fInfo) * sizeof(Datum)); + FmgrInfo flinfo; + FunctionCallInfoData fcinfo; + int i; + bool anynull = false; + + /* + * XXX ought to store lookup info in FuncIndexInfo so it need not + * be repeated on each call? + */ + fmgr_info(FIgetProcOid(fInfo), &flinfo); + + MemSet(&fcinfo, 0, sizeof(fcinfo)); + fcinfo.flinfo = &flinfo; + fcinfo.nargs = FIgetnArgs(fInfo); for (i = 0; i < FIgetnArgs(fInfo); i++) { - attData[i] = heap_getattr(tuple, - attrNums[i], - hTupDesc, - attNull); - if (*attNull) - isNull = TRUE; + fcinfo.arg[i] = heap_getattr(tuple, + attrNums[i], + hTupDesc, + &fcinfo.argnull[i]); + anynull |= fcinfo.argnull[i]; + } + if (flinfo.fn_strict && anynull) + { + /* force a null result for strict function */ + returnVal = (Datum) 0; + *attNull = true; + } + else + { + returnVal = FunctionCallInvoke(&fcinfo); + *attNull = fcinfo.isnull; } - returnVal = (Datum) fmgr_array_args(FIgetProcOid(fInfo), - FIgetnArgs(fInfo), - (char **) attData, - &isNull); - pfree(attData); - *attNull = isNull; } else returnVal = heap_getattr(tuple, attrNums[attOff], hTupDesc, attNull); |