summaryrefslogtreecommitdiff
path: root/src/backend/access/index/indexam.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-06-01 02:41:36 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-06-01 02:41:36 +0000
commit0b370ea7c81228339da5a447057dbf5f874e0197 (patch)
tree125c8590975f212a7caec6667f95f28d772bb928 /src/backend/access/index/indexam.c
parenta1d9d096f0f36afcdd4ca69afb41cd645b9834d2 (diff)
downloadpostgresql-0b370ea7c81228339da5a447057dbf5f874e0197.tar.gz
Clean up some minor problems exposed by further thought about Panon's bug
report on old-style functions invoked by RI triggers. We had a number of other places that were being sloppy about which memory context FmgrInfo subsidiary data will be allocated in. Turns out none of them actually cause a problem in 7.1, but this is for arcane reasons such as the fact that old-style triggers aren't supported anyway. To avoid getting burnt later, I've restructured the trigger support so that we don't keep trigger FmgrInfo structs in relcache memory. Some other related cleanups too: it's not really necessary to call fmgr_info at all while setting up the index support info in relcache entries, because those ScanKeyEntry structs are never used to invoke the functions. This should speed up relcache initialization a tiny bit.
Diffstat (limited to 'src/backend/access/index/indexam.c')
-rw-r--r--src/backend/access/index/indexam.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index 3cea6895f3..5b12930114 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.49 2001/05/31 18:16:54 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.50 2001/06/01 02:41:35 tgl Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
@@ -232,7 +232,7 @@ index_beginscan(Relation relation,
uint16 numberOfKeys,
ScanKey key)
{
- IndexScanDesc scandesc;
+ IndexScanDesc scan;
RegProcedure procedure;
RELATION_CHECKS;
@@ -249,14 +249,22 @@ index_beginscan(Relation relation,
*/
LockRelation(relation, AccessShareLock);
- scandesc = (IndexScanDesc)
+ scan = (IndexScanDesc)
DatumGetPointer(OidFunctionCall4(procedure,
PointerGetDatum(relation),
BoolGetDatum(scanFromEnd),
UInt16GetDatum(numberOfKeys),
PointerGetDatum(key)));
- return scandesc;
+ /*
+ * We want to look up the amgettuple procedure just once per scan,
+ * not once per index_getnext call. So do it here and save
+ * the fmgr info result in the scan descriptor.
+ */
+ GET_SCAN_PROCEDURE(beginscan, amgettuple);
+ fmgr_info(procedure, &scan->fn_getnext);
+
+ return scan;
}
/* ----------------
@@ -346,18 +354,8 @@ index_getnext(IndexScanDesc scan,
SCAN_CHECKS;
/*
- * Look up the access procedure only once per scan.
- */
- if (scan->fn_getnext.fn_oid == InvalidOid)
- {
- RegProcedure procedure;
-
- GET_SCAN_PROCEDURE(getnext, amgettuple);
- fmgr_info(procedure, &scan->fn_getnext);
- }
-
- /*
* have the am's gettuple proc do all the work.
+ * index_beginscan already set up fn_getnext.
*/
result = (RetrieveIndexResult)
DatumGetPointer(FunctionCall2(&scan->fn_getnext,