77 *
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.61 1998/09/07 05:35:37 momjian Exp $
10+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.62 1998/09/09 03:42:52 vadim Exp $
1111 *
1212 *
1313 * INTERFACE ROUTINES
6464#define NTUPLES_PER_PAGE (natts ) (BLCKSZ/((natts)*AVG_TUPLE_SIZE))
6565
6666/* non-export function prototypes */
67- static Oid RelationNameGetObjectId (char * relationName ,Relation pg_class );
67+ static Oid
68+ RelationNameGetObjectId (char * relationName ,Relation pg_class );
6869static Oid GetHeapRelationOid (char * heapRelationName ,char * indexRelationName );
6970static TupleDesc BuildFuncTupleDesc (FuncIndexInfo * funcInfo );
7071static TupleDesc ConstructTupleDescriptor (Oid heapoid ,Relation heapRelation ,
7172List * attributeList ,
7273int numatts ,AttrNumber * attNums );
7374
7475static void ConstructIndexReldesc (Relation indexRelation ,Oid amoid );
75- static Oid UpdateRelationRelation (Relation indexRelation );
76+ static Oid UpdateRelationRelation (Relation indexRelation );
7677static void InitializeAttributeOids (Relation indexRelation ,
7778int numatts ,
7879Oid indexoid );
79- static void AppendAttributeTuples (Relation indexRelation ,int numatts );
80+ static void
81+ AppendAttributeTuples (Relation indexRelation ,int numatts );
8082static void UpdateIndexRelation (Oid indexoid ,Oid heapoid ,
8183FuncIndexInfo * funcInfo ,int natts ,
8284AttrNumber * attNums ,Oid * classOids ,Node * predicate ,
@@ -550,9 +552,11 @@ UpdateRelationRelation(Relation indexRelation)
550552sizeof (* indexRelation -> rd_rel ),
551553 (char * )indexRelation -> rd_rel );
552554
553- /*
554- *The new tuple must have the same oid as the heap_create() we just
555- *did.
555+ /* ----------------
556+ *the new tuple must have the same oid as the relcache entry for the
557+ *index.sure would be embarassing to do this sort of thing in polite
558+ *company.
559+ * ----------------
556560 */
557561tuple -> t_oid = RelationGetRelid (indexRelation );
558562heap_insert (pg_class ,tuple );
@@ -1074,7 +1078,7 @@ index_create(char *heapRelationName,
10741078
10751079/* ----------------
10761080 * add index to catalogs
1077- * (INSERT pg_class tuple)
1081+ * (append RELATION tuple)
10781082 * ----------------
10791083 */
10801084indexoid = UpdateRelationRelation (indexRelation );
@@ -1260,7 +1264,8 @@ FormIndexDatum(int numberOfAttributes,
12601264char * nullv ,
12611265FuncIndexInfoPtr fInfo )
12621266{
1263- AttrNumber attOff ;
1267+ AttrNumber i ;
1268+ int offset ;
12641269bool isNull ;
12651270
12661271/* ----------------
@@ -1270,16 +1275,18 @@ FormIndexDatum(int numberOfAttributes,
12701275 * ----------------
12711276 */
12721277
1273- for (attOff = 0 ; attOff < numberOfAttributes ;attOff ++ )
1278+ for (i = 1 ; i <= numberOfAttributes ;i ++ )
12741279{
1275- datum [attOff ]= PointerGetDatum (GetIndexValue (heapTuple ,
1280+ offset = AttrNumberGetAttrOffset (i );
1281+
1282+ datum [offset ]= PointerGetDatum (GetIndexValue (heapTuple ,
12761283heapDescriptor ,
1277- attOff ,
1284+ offset ,
12781285attributeNumber ,
12791286fInfo ,
12801287& isNull ));
12811288
1282- nullv [attOff ]= (isNull ) ?'n' :' ' ;
1289+ nullv [offset ]= (isNull ) ?'n' :' ' ;
12831290}
12841291}
12851292
@@ -1417,10 +1424,10 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
14171424
14181425newtup = heap_modifytuple (tuple ,pg_class ,values ,nulls ,replace );
14191426heap_replace (pg_class ,& tuple -> t_ctid ,newtup );
1420- pfree (newtup );
14211427CatalogOpenIndices (Num_pg_class_indices ,Name_pg_class_indices ,idescs );
14221428CatalogIndexInsert (idescs ,Num_pg_class_indices ,pg_class ,newtup );
14231429CatalogCloseIndices (Num_pg_class_indices ,idescs );
1430+ pfree (newtup );
14241431}
14251432
14261433if (!IsBootstrapProcessingMode ())