*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.61 1998/09/07 05:35:37 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.62 1998/09/09 03:42:52 vadim Exp $
*
*
* INTERFACE ROUTINES
#define NTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE))
/* non-export function prototypes */
-static Oid RelationNameGetObjectId(char *relationName, Relation pg_class);
+static Oid
+ RelationNameGetObjectId(char *relationName, Relation pg_class);
static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName);
static TupleDesc BuildFuncTupleDesc(FuncIndexInfo *funcInfo);
static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation,
int numatts, AttrNumber *attNums);
static void ConstructIndexReldesc(Relation indexRelation, Oid amoid);
-static Oid UpdateRelationRelation(Relation indexRelation);
+static Oid UpdateRelationRelation(Relation indexRelation);
static void InitializeAttributeOids(Relation indexRelation,
int numatts,
Oid indexoid);
-static void AppendAttributeTuples(Relation indexRelation, int numatts);
+static void
+ AppendAttributeTuples(Relation indexRelation, int numatts);
static void UpdateIndexRelation(Oid indexoid, Oid heapoid,
FuncIndexInfo *funcInfo, int natts,
AttrNumber *attNums, Oid *classOids, Node *predicate,
sizeof(*indexRelation->rd_rel),
(char *) indexRelation->rd_rel);
- /*
- * The new tuple must have the same oid as the heap_create() we just
- * did.
+ /* ----------------
+ * the new tuple must have the same oid as the relcache entry for the
+ * index. sure would be embarassing to do this sort of thing in polite
+ * company.
+ * ----------------
*/
tuple->t_oid = RelationGetRelid(indexRelation);
heap_insert(pg_class, tuple);
/* ----------------
* add index to catalogs
- * (INSERT pg_class tuple)
+ * (append RELATION tuple)
* ----------------
*/
indexoid = UpdateRelationRelation(indexRelation);
char *nullv,
FuncIndexInfoPtr fInfo)
{
- AttrNumber attOff;
+ AttrNumber i;
+ int offset;
bool isNull;
/* ----------------
* ----------------
*/
- for (attOff = 0; attOff < numberOfAttributes; attOff++)
+ for (i = 1; i <= numberOfAttributes; i++)
{
- datum[attOff] = PointerGetDatum(GetIndexValue(heapTuple,
+ offset = AttrNumberGetAttrOffset(i);
+
+ datum[offset] = PointerGetDatum(GetIndexValue(heapTuple,
heapDescriptor,
- attOff,
+ offset,
attributeNumber,
fInfo,
&isNull));
- nullv[attOff] = (isNull) ? 'n' : ' ';
+ nullv[offset] = (isNull) ? 'n' : ' ';
}
}
newtup = heap_modifytuple(tuple, pg_class, values, nulls, replace);
heap_replace(pg_class, &tuple->t_ctid, newtup);
- pfree(newtup);
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
CatalogIndexInsert(idescs, Num_pg_class_indices, pg_class, newtup);
CatalogCloseIndices(Num_pg_class_indices, idescs);
+ pfree(newtup);
}
if (!IsBootstrapProcessingMode())