1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-13 16:22:44 +03:00

fix for index problem.

This commit is contained in:
Bruce Momjian
1998-08-20 22:07:46 +00:00
parent 31309423c9
commit 4a70002149
9 changed files with 69 additions and 61 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.58 1998/08/19 02:01:30 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.59 1998/08/20 22:07:32 momjian Exp $
*
* INTERFACE ROUTINES
* heap_create() - Create an uncataloged heap relation
@@ -1051,18 +1051,20 @@ DeletePgAttributeTuples(Relation rel)
*/
RelationSetLockForWrite(pg_attribute_desc);
attnum = FirstLowInvalidHeapAttributeNumber + 1; /* cmax */
while (HeapTupleIsValid(tup = SearchSysCacheTupleCopy(ATTNUM,
ObjectIdGetDatum(rel->rd_att->attrs[0]->attrelid),
Int16GetDatum(attnum),
0, 0)))
for (attnum = FirstLowInvalidHeapAttributeNumber + 1;
attnum <= rel->rd_att->natts;
attnum++)
{
heap_delete(pg_attribute_desc, &tup->t_ctid);
pfree(tup);
attnum++;
if (HeapTupleIsValid(tup = SearchSysCacheTupleCopy(ATTNUM,
ObjectIdGetDatum(RelationGetRelid(rel)),
Int16GetDatum(attnum),
0, 0)))
{
heap_delete(pg_attribute_desc, &tup->t_ctid);
pfree(tup);
}
}
/* ----------------
* Release the write lock
* ----------------
@@ -1104,8 +1106,10 @@ DeletePgTypeTuple(Relation rel)
* to this relation.
* ----------------
*/
ScanKeyEntryInitialize(&key, 0, Anum_pg_type_typrelid, F_INT4EQ,
rel->rd_att->attrs[0]->attrelid);
ScanKeyEntryInitialize(&key, 0,
Anum_pg_type_typrelid,
F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)));
pg_type_scan = heap_beginscan(pg_type_desc,
0,
@@ -1140,7 +1144,9 @@ DeletePgTypeTuple(Relation rel)
pg_attribute_desc = heap_openr(AttributeRelationName);
ScanKeyEntryInitialize(&attkey,
0, Anum_pg_attribute_atttypid, F_INT4EQ,
0,
Anum_pg_attribute_atttypid,
F_OIDEQ,
typoid);
pg_attribute_scan = heap_beginscan(pg_attribute_desc,
@@ -1151,13 +1157,13 @@ DeletePgTypeTuple(Relation rel)
/* ----------------
* try and get a pg_attribute tuple. if we succeed it means
* we cant delete the relation because something depends on
* we can't delete the relation because something depends on
* the schema.
* ----------------
*/
atttup = heap_getnext(pg_attribute_scan, 0);
if (PointerIsValid(atttup))
if (HeapTupleIsValid(atttup))
{
Oid relid = ((AttributeTupleForm) GETSTRUCT(atttup))->attrelid;

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.49 1998/08/20 15:16:54 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.50 1998/08/20 22:07:34 momjian Exp $
*
*
* INTERFACE ROUTINES
@@ -1173,6 +1173,7 @@ index_destroy(Oid indexId)
{
Relation indexRelation;
Relation catalogRelation;
Relation attributeRelation;
HeapTuple tuple;
int16 attnum;
@@ -1200,7 +1201,7 @@ index_destroy(Oid indexId)
* fix ATTRIBUTE relation
* ----------------
*/
catalogRelation = heap_openr(AttributeRelationName);
attributeRelation = heap_openr(AttributeRelationName);
attnum = 1; /* indexes start at 1 */
@@ -1209,29 +1210,28 @@ index_destroy(Oid indexId)
Int16GetDatum(attnum),
0, 0)))
{
heap_delete(catalogRelation, &tuple->t_ctid);
heap_delete(attributeRelation, &tuple->t_ctid);
pfree(tuple);
attnum++;
}
heap_close(catalogRelation);
heap_close(attributeRelation);
/* ----------------
* fix INDEX relation
* ----------------
*/
tuple = SearchSysCacheTupleCopy(INDEXRELID,
ObjectIdGetDatum(indexId),
0, 0, 0);
ObjectIdGetDatum(indexId),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
{
elog(NOTICE, "IndexRelationDestroy: %s's INDEX tuple missing",
RelationGetRelationName(indexRelation));
}
heap_delete(catalogRelation, &tuple->t_ctid);
Assert(ItemPointerIsValid(&tuple->t_ctid));
heap_delete(indexRelation, &tuple->t_ctid);
pfree(tuple);
heap_close(catalogRelation);
/*
* flush cache and physically remove the file

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.21 1998/08/20 15:16:55 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.22 1998/08/20 22:07:36 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -125,7 +125,7 @@ CatalogIndexInsert(Relation *idescs,
InsertIndexResult indexRes;
indexDescriptor = RelationGetTupleDescriptor(idescs[i]);
pgIndexTup = SearchSysCacheTuple(INDEXRELID,
pgIndexTup = SearchSysCacheTupleCopy(INDEXRELID,
ObjectIdGetDatum(idescs[i]->rd_id),
0, 0, 0);
Assert(pgIndexTup);
@@ -163,6 +163,7 @@ CatalogIndexInsert(Relation *idescs,
&heapTuple->t_ctid, heapRelation);
if (indexRes)
pfree(indexRes);
pfree(pgIndexTup);
}
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.27 1998/08/19 02:01:38 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.28 1998/08/20 22:07:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -384,12 +384,12 @@ TypeCreate(char *typeName,
values[i++] = (Datum) GetUserId(); /* 2 */
values[i++] = (Datum) internalSize; /* 3 */
values[i++] = (Datum) externalSize; /* 4 */
values[i++] = (Datum) passedByValue; /* 5 */
values[i++] = (Datum) passedByValue;/* 5 */
values[i++] = (Datum) typeType; /* 6 */
values[i++] = (Datum) (bool) 1; /* 7 */
values[i++] = (Datum) typDelim; /* 8 */
values[i++] = (Datum) (typeType == 'c' ? relationOid : InvalidOid); /* 9 */
values[i++] = (Datum) elementObjectId; /* 10 */
values[i++] = (Datum) elementObjectId;/* 10 */
/*
* arguments to type input and output functions must be 0
@@ -431,7 +431,7 @@ TypeCreate(char *typeName,
func_error("TypeCreate", procname, 1, argList, NULL);
}
values[i++] = (Datum) tup->t_oid; /* 11 - 14 */
values[i++] = (Datum) tup->t_oid; /* 11 - 14 */
}
/* ----------------