Fix for indexing problem (?): heap tuple was pfree-d before CatalogIndexInsert()...

This commit is contained in:
Vadim B. Mikheev 1998-09-09 03:42:52 +00:00
parent b5ed4be218
commit 04abb54197
1 changed files with 21 additions and 14 deletions

View File

@ -7,7 +7,7 @@
*
*
* 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
@ -64,7 +64,8 @@
#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,
@ -72,11 +73,12 @@ 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,
@ -550,9 +552,11 @@ UpdateRelationRelation(Relation indexRelation)
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);
@ -1074,7 +1078,7 @@ index_create(char *heapRelationName,
/* ----------------
* add index to catalogs
* (INSERT pg_class tuple)
* (append RELATION tuple)
* ----------------
*/
indexoid = UpdateRelationRelation(indexRelation);
@ -1260,7 +1264,8 @@ FormIndexDatum(int numberOfAttributes,
char *nullv,
FuncIndexInfoPtr fInfo)
{
AttrNumber attOff;
AttrNumber i;
int offset;
bool isNull;
/* ----------------
@ -1270,16 +1275,18 @@ FormIndexDatum(int numberOfAttributes,
* ----------------
*/
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' : ' ';
}
}
@ -1417,10 +1424,10 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
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())