aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/index
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-07-14 22:18:02 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-07-14 22:18:02 +0000
commit6bfe64032efd043f80a495a495331dcfc2d9f05c (patch)
treed0cc092d38bdea690a79e4aebfa4629e1db54e96 /src/backend/access/index
parenta30bc7c75a54910a78d1939bd32f5d91164ba8a4 (diff)
downloadpostgresql-6bfe64032efd043f80a495a495331dcfc2d9f05c.tar.gz
postgresql-6bfe64032efd043f80a495a495331dcfc2d9f05c.zip
Cleanup of code for creating index entries. Functional indexes with
pass-by-ref data types --- eg, an index on lower(textfield) --- no longer leak memory during index creation or update. Clean up a lot of redundant code ... did you know that copy, vacuum, truncate, reindex, extend index, and bootstrap each basically duplicated the main executor's logic for extracting information about an index and preparing index entries? Functional indexes should be a little faster now too, due to removal of repeated function lookups. CREATE INDEX 'opt_type' clause is deimplemented by these changes, but I haven't removed it from the parser yet (need to merge with Thomas' latest change set first).
Diffstat (limited to 'src/backend/access/index')
-rw-r--r--src/backend/access/index/indexam.c55
-rw-r--r--src/backend/access/index/istrat.c15
2 files changed, 10 insertions, 60 deletions
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index 2d1504238de..dc18b0d3b77 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.45 2000/06/13 07:34:35 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
@@ -424,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;
-}
diff --git a/src/backend/access/index/istrat.c b/src/backend/access/index/istrat.c
index fc7ac6dcb14..d6a966bcd44 100644
--- a/src/backend/access/index/istrat.c
+++ b/src/backend/access/index/istrat.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.45 2000/06/08 22:36:51 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.46 2000/07/14 22:17:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -533,6 +533,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
void
IndexSupportInitialize(IndexStrategy indexStrategy,
RegProcedure *indexSupport,
+ bool *isUnique,
Oid indexObjectId,
Oid accessMethodObjectId,
StrategyNumber maxStrategyNumber,
@@ -544,6 +545,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
ScanKeyData entry[2];
Relation operatorRelation;
HeapTuple tuple;
+ Form_pg_index iform;
StrategyMap map;
AttrNumber attributeNumber;
int attributeIndex;
@@ -568,7 +570,12 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
}
if (!HeapTupleIsValid(tuple))
- elog(ERROR, "IndexSupportInitialize: corrupted catalogs");
+ elog(ERROR, "IndexSupportInitialize: no pg_index entry for index %u",
+ indexObjectId);
+
+ iform = (Form_pg_index) GETSTRUCT(tuple);
+
+ *isUnique = iform->indisunique;
maxStrategyNumber = AMStrategies(maxStrategyNumber);
@@ -578,10 +585,6 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
*/
for (attributeIndex = 0; attributeIndex < maxAttributeNumber; attributeIndex++)
{
- Form_pg_index iform;
-
- iform = (Form_pg_index) GETSTRUCT(tuple);
-
if (!OidIsValid(iform->indkey[attributeIndex]))
{
if (attributeIndex == InvalidAttrNumber)