From 6bfe64032efd043f80a495a495331dcfc2d9f05c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 14 Jul 2000 22:18:02 +0000 Subject: 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). --- src/backend/storage/large_object/inv_api.c | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/backend/storage/large_object/inv_api.c') diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index cbf1562678..d8abfb4a2b 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.73 2000/07/04 06:11:39 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.74 2000/07/14 22:17:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -87,12 +87,12 @@ static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln); LargeObjectDesc * inv_create(int flags) { - int file_oid; LargeObjectDesc *retval; + Oid file_oid; Relation r; Relation indr; TupleDesc tupdesc; - AttrNumber attNums[1]; + IndexInfo *indexInfo; Oid classObjectId[1]; char objname[NAMEDATALEN]; char indname[NAMEDATALEN]; @@ -109,17 +109,13 @@ inv_create(int flags) sprintf(indname, "xinx%u", file_oid); if (RelnameFindRelid(objname) != InvalidOid) - { elog(ERROR, "internal error: %s already exists -- cannot create large obj", objname); - } if (RelnameFindRelid(indname) != InvalidOid) - { elog(ERROR, "internal error: %s already exists -- cannot create large obj", indname); - } /* this is pretty painful... want a tuple descriptor */ tupdesc = CreateTemplateTupleDesc(2); @@ -155,21 +151,25 @@ inv_create(int flags) /* * Now create a btree index on the relation's olastbyte attribute to - * make seeks go faster. The hardwired constants are embarassing to - * me, and are symptomatic of the pressure under which this code was - * written. - * - * ok, mao, let's put in some symbolic constants - jolly + * make seeks go faster. */ + indexInfo = makeNode(IndexInfo); + indexInfo->ii_NumIndexAttrs = 1; + indexInfo->ii_NumKeyAttrs = 1; + indexInfo->ii_KeyAttrNumbers[0] = 1; + indexInfo->ii_Predicate = NULL; + indexInfo->ii_FuncOid = InvalidOid; + indexInfo->ii_Unique = false; - attNums[0] = 1; classObjectId[0] = INT4_OPS_OID; - index_create(objname, indname, NULL, NULL, BTREE_AM_OID, - 1, &attNums[0], &classObjectId[0], - (Node *) NULL, false, false, false, false); + + index_create(objname, indname, indexInfo, + BTREE_AM_OID, classObjectId, + false, false, false); /* make the index visible in this transaction */ CommandCounterIncrement(); + indr = index_openr(indname); if (!RelationIsValid(indr)) -- cgit v1.2.1