OSDN Git Service

Cleanup of code for creating index entries. Functional indexes with
[pg-rex/syncrep.git] / src / backend / access / index / indexam.c
index 43d8a38..dc18b0d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.43 2000/05/28 17:55:52 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.46 2000/07/14 22:17:30 tgl Exp $
  *
  * INTERFACE ROUTINES
  *             index_open              - open an index relation by relationId
@@ -195,7 +195,12 @@ index_insert(Relation relation,
         * ----------------
         */
        specificResult = (InsertIndexResult)
-               fmgr(procedure, relation, datum, nulls, heap_t_ctid, heapRel, NULL);
+               DatumGetPointer(OidFunctionCall5(procedure,
+                                                                                PointerGetDatum(relation),
+                                                                                PointerGetDatum(datum),
+                                                                                PointerGetDatum(nulls),
+                                                                                PointerGetDatum(heap_t_ctid),
+                                                                                PointerGetDatum(heapRel)));
 
        /* must be pfree'ed */
        return specificResult;
@@ -213,7 +218,9 @@ index_delete(Relation relation, ItemPointer indexItem)
        RELATION_CHECKS;
        GET_REL_PROCEDURE(delete, amdelete);
 
-       fmgr(procedure, relation, indexItem);
+       OidFunctionCall2(procedure,
+                                        PointerGetDatum(relation),
+                                        PointerGetDatum(indexItem));
 }
 
 /* ----------------
@@ -245,7 +252,11 @@ index_beginscan(Relation relation,
        LockRelation(relation, AccessShareLock);
 
        scandesc = (IndexScanDesc)
-               fmgr(procedure, relation, scanFromEnd, numberOfKeys, key);
+               DatumGetPointer(OidFunctionCall4(procedure,
+                                                                                PointerGetDatum(relation),
+                                                                                BoolGetDatum(scanFromEnd),
+                                                                                UInt16GetDatum(numberOfKeys),
+                                                                                PointerGetDatum(key)));
 
        return scandesc;
 }
@@ -262,7 +273,10 @@ index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key)
        SCAN_CHECKS;
        GET_SCAN_PROCEDURE(rescan, amrescan);
 
-       fmgr(procedure, scan, scanFromEnd, key);
+       OidFunctionCall3(procedure,
+                                        PointerGetDatum(scan),
+                                        BoolGetDatum(scanFromEnd),
+                                        PointerGetDatum(key));
 }
 
 /* ----------------
@@ -277,7 +291,7 @@ index_endscan(IndexScanDesc scan)
        SCAN_CHECKS;
        GET_SCAN_PROCEDURE(endscan, amendscan);
 
-       fmgr(procedure, scan);
+       OidFunctionCall1(procedure, PointerGetDatum(scan));
 
        /* Release lock and refcount acquired by index_beginscan */
 
@@ -301,7 +315,7 @@ index_markpos(IndexScanDesc scan)
        SCAN_CHECKS;
        GET_SCAN_PROCEDURE(markpos, ammarkpos);
 
-       fmgr(procedure, scan);
+       OidFunctionCall1(procedure, PointerGetDatum(scan));
 }
 
 /* ----------------
@@ -316,7 +330,7 @@ index_restrpos(IndexScanDesc scan)
        SCAN_CHECKS;
        GET_SCAN_PROCEDURE(restrpos, amrestrpos);
 
-       fmgr(procedure, scan);
+       OidFunctionCall1(procedure, PointerGetDatum(scan));
 }
 
 /* ----------------
@@ -350,7 +364,9 @@ index_getnext(IndexScanDesc scan,
         * ----------------
         */
        result = (RetrieveIndexResult)
-               (*fmgr_faddr(&scan->fn_getnext)) (scan, direction);
+               DatumGetPointer(FunctionCall2(&scan->fn_getnext,
+                                                                         PointerGetDatum(scan),
+                                                                         Int32GetDatum(direction)));
 
        return result;
 }
@@ -408,56 +424,3 @@ index_getprocid(Relation irel,
 
        return loc[(natts * (procnum - 1)) + (attnum - 1)];
 }
-
-Datum
-GetIndexValue(HeapTuple tuple,
-                         TupleDesc hTupDesc,
-                         int attOff,
-                         AttrNumber *attrNums,
-                         FuncIndexInfo *fInfo,
-                         bool *attNull)
-{
-       Datum           returnVal;
-
-       if (PointerIsValid(fInfo) && FIgetProcOid(fInfo) != InvalidOid)
-       {
-               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++)
-               {
-                       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;
-               }
-       }
-       else
-               returnVal = heap_getattr(tuple, attrNums[attOff], hTupDesc, attNull);
-
-       return returnVal;
-}