7
7
*
8
8
*
9
9
* 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 $
11
11
*
12
12
*
13
13
* INTERFACE ROUTINES
64
64
#define NTUPLES_PER_PAGE (natts ) (BLCKSZ/((natts)*AVG_TUPLE_SIZE))
65
65
66
66
/* non-export function prototypes */
67
- static Oid RelationNameGetObjectId (char * relationName , Relation pg_class );
67
+ static Oid
68
+ RelationNameGetObjectId (char * relationName , Relation pg_class );
68
69
static Oid GetHeapRelationOid (char * heapRelationName , char * indexRelationName );
69
70
static TupleDesc BuildFuncTupleDesc (FuncIndexInfo * funcInfo );
70
71
static TupleDesc ConstructTupleDescriptor (Oid heapoid , Relation heapRelation ,
71
72
List * attributeList ,
72
73
int numatts , AttrNumber * attNums );
73
74
74
75
static void ConstructIndexReldesc (Relation indexRelation , Oid amoid );
75
- static Oid UpdateRelationRelation (Relation indexRelation );
76
+ static Oid UpdateRelationRelation (Relation indexRelation );
76
77
static void InitializeAttributeOids (Relation indexRelation ,
77
78
int numatts ,
78
79
Oid indexoid );
79
- static void AppendAttributeTuples (Relation indexRelation , int numatts );
80
+ static void
81
+ AppendAttributeTuples (Relation indexRelation , int numatts );
80
82
static void UpdateIndexRelation (Oid indexoid , Oid heapoid ,
81
83
FuncIndexInfo * funcInfo , int natts ,
82
84
AttrNumber * attNums , Oid * classOids , Node * predicate ,
@@ -550,9 +552,11 @@ UpdateRelationRelation(Relation indexRelation)
550
552
sizeof (* indexRelation -> rd_rel ),
551
553
(char * ) indexRelation -> rd_rel );
552
554
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
+ * ----------------
556
560
*/
557
561
tuple -> t_oid = RelationGetRelid (indexRelation );
558
562
heap_insert (pg_class , tuple );
@@ -1074,7 +1078,7 @@ index_create(char *heapRelationName,
1074
1078
1075
1079
/* ----------------
1076
1080
* add index to catalogs
1077
- * (INSERT pg_class tuple)
1081
+ * (append RELATION tuple)
1078
1082
* ----------------
1079
1083
*/
1080
1084
indexoid = UpdateRelationRelation (indexRelation );
@@ -1260,7 +1264,8 @@ FormIndexDatum(int numberOfAttributes,
1260
1264
char * nullv ,
1261
1265
FuncIndexInfoPtr fInfo )
1262
1266
{
1263
- AttrNumber attOff ;
1267
+ AttrNumber i ;
1268
+ int offset ;
1264
1269
bool isNull ;
1265
1270
1266
1271
/* ----------------
@@ -1270,16 +1275,18 @@ FormIndexDatum(int numberOfAttributes,
1270
1275
* ----------------
1271
1276
*/
1272
1277
1273
- for (attOff = 0 ; attOff < numberOfAttributes ; attOff ++ )
1278
+ for (i = 1 ; i <= numberOfAttributes ; i ++ )
1274
1279
{
1275
- datum [attOff ] = PointerGetDatum (GetIndexValue (heapTuple ,
1280
+ offset = AttrNumberGetAttrOffset (i );
1281
+
1282
+ datum [offset ] = PointerGetDatum (GetIndexValue (heapTuple ,
1276
1283
heapDescriptor ,
1277
- attOff ,
1284
+ offset ,
1278
1285
attributeNumber ,
1279
1286
fInfo ,
1280
1287
& isNull ));
1281
1288
1282
- nullv [attOff ] = (isNull ) ? 'n' : ' ' ;
1289
+ nullv [offset ] = (isNull ) ? 'n' : ' ' ;
1283
1290
}
1284
1291
}
1285
1292
@@ -1417,10 +1424,10 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
1417
1424
1418
1425
newtup = heap_modifytuple (tuple , pg_class , values , nulls , replace );
1419
1426
heap_replace (pg_class , & tuple -> t_ctid , newtup );
1420
- pfree (newtup );
1421
1427
CatalogOpenIndices (Num_pg_class_indices , Name_pg_class_indices , idescs );
1422
1428
CatalogIndexInsert (idescs , Num_pg_class_indices , pg_class , newtup );
1423
1429
CatalogCloseIndices (Num_pg_class_indices , idescs );
1430
+ pfree (newtup );
1424
1431
}
1425
1432
1426
1433
if (!IsBootstrapProcessingMode ())
0 commit comments