aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 27abf6ace50..95e217b9a4f 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.89 2001/11/26 21:15:14 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.90 2002/02/19 20:11:16 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -341,6 +341,7 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
HeapTuple ht_idx;
HeapTuple ht_idxrel;
HeapTuple ht_indrel;
+ HeapTuple ht_am;
Form_pg_index idxrec;
Form_pg_class idxrelrec;
Form_pg_class indrelrec;
@@ -383,13 +384,13 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
/*
* Fetch the pg_am tuple of the index' access method
- *
- * There is no syscache for this, so use index.c subroutine.
*/
- amrec = AccessMethodObjectIdGetForm(idxrelrec->relam,
- CurrentMemoryContext);
- if (!amrec)
- elog(ERROR, "lookup for AM %u failed", idxrelrec->relam);
+ ht_am = SearchSysCache(AMOID,
+ ObjectIdGetDatum(idxrelrec->relam),
+ 0, 0, 0);
+ if (!HeapTupleIsValid(ht_am))
+ elog(ERROR, "syscache lookup for AM %u failed", idxrelrec->relam);
+ amrec = (Form_pg_am) GETSTRUCT(ht_am);
/*
* Start the index definition
@@ -504,10 +505,11 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
pfree(buf.data);
pfree(keybuf.data);
- pfree(amrec);
+
ReleaseSysCache(ht_idx);
ReleaseSysCache(ht_idxrel);
ReleaseSysCache(ht_indrel);
+ ReleaseSysCache(ht_am);
PG_RETURN_TEXT_P(indexdef);
}