mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Initial MVCC code.
New code for locking buffer' context.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.17 1998/11/27 19:51:46 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.18 1998/12/15 12:45:39 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* See acl.h.
|
||||
@@ -162,7 +162,7 @@ ChangeAcl(char *relname,
|
||||
tuple = heap_modifytuple(tuple, relation, values, nulls, replaces);
|
||||
/* XXX handle index on pg_class? */
|
||||
setheapoverride(true);
|
||||
heap_replace(relation, &tuple->t_self, tuple);
|
||||
heap_replace(relation, &tuple->t_self, tuple, NULL);
|
||||
setheapoverride(false);
|
||||
|
||||
/* keep the catalog indices up to date */
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.69 1998/12/14 05:18:37 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.70 1998/12/15 12:45:40 vadim Exp $
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
* heap_create() - Create an uncataloged heap relation
|
||||
@@ -929,7 +929,7 @@ RelationRemoveInheritance(Relation relation)
|
||||
|
||||
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
|
||||
{
|
||||
heap_delete(catalogRelation, &tuple->t_self);
|
||||
heap_delete(catalogRelation, &tuple->t_self, NULL);
|
||||
found = true;
|
||||
}
|
||||
|
||||
@@ -951,7 +951,7 @@ RelationRemoveInheritance(Relation relation)
|
||||
&entry);
|
||||
|
||||
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
|
||||
heap_delete(catalogRelation, &tuple->t_self);
|
||||
heap_delete(catalogRelation, &tuple->t_self, NULL);
|
||||
|
||||
heap_endscan(scan);
|
||||
heap_close(catalogRelation);
|
||||
@@ -1020,7 +1020,7 @@ DeletePgRelationTuple(Relation rel)
|
||||
* delete the relation tuple from pg_class, and finish up.
|
||||
* ----------------
|
||||
*/
|
||||
heap_delete(pg_class_desc, &tup->t_self);
|
||||
heap_delete(pg_class_desc, &tup->t_self, NULL);
|
||||
pfree(tup);
|
||||
|
||||
heap_close(pg_class_desc);
|
||||
@@ -1048,7 +1048,7 @@ DeletePgAttributeTuples(Relation rel)
|
||||
* Get a write lock _before_ getting the read lock in the scan
|
||||
* ----------------
|
||||
*/
|
||||
RelationSetLockForWrite(pg_attribute_desc);
|
||||
LockRelation(pg_attribute_desc, AccessExclusiveLock);
|
||||
|
||||
for (attnum = FirstLowInvalidHeapAttributeNumber + 1;
|
||||
attnum <= rel->rd_att->natts;
|
||||
@@ -1059,7 +1059,7 @@ DeletePgAttributeTuples(Relation rel)
|
||||
Int16GetDatum(attnum),
|
||||
0, 0)))
|
||||
{
|
||||
heap_delete(pg_attribute_desc, &tup->t_self);
|
||||
heap_delete(pg_attribute_desc, &tup->t_self, NULL);
|
||||
pfree(tup);
|
||||
}
|
||||
}
|
||||
@@ -1068,7 +1068,7 @@ DeletePgAttributeTuples(Relation rel)
|
||||
* Release the write lock
|
||||
* ----------------
|
||||
*/
|
||||
RelationUnsetLockForWrite(pg_attribute_desc);
|
||||
UnlockRelation(pg_attribute_desc, AccessExclusiveLock);
|
||||
heap_close(pg_attribute_desc);
|
||||
}
|
||||
|
||||
@@ -1183,7 +1183,7 @@ DeletePgTypeTuple(Relation rel)
|
||||
* we release the read lock on pg_type. -mer 13 Aug 1991
|
||||
* ----------------
|
||||
*/
|
||||
heap_delete(pg_type_desc, &tup->t_self);
|
||||
heap_delete(pg_type_desc, &tup->t_self, NULL);
|
||||
|
||||
heap_endscan(pg_type_scan);
|
||||
heap_close(pg_type_desc);
|
||||
@@ -1209,7 +1209,7 @@ heap_destroy_with_catalog(char *relname)
|
||||
if (rel == NULL)
|
||||
elog(ERROR, "Relation %s Does Not Exist!", relname);
|
||||
|
||||
RelationSetLockForWrite(rel);
|
||||
LockRelation(rel, AccessExclusiveLock);
|
||||
rid = rel->rd_id;
|
||||
|
||||
/* ----------------
|
||||
@@ -1288,7 +1288,7 @@ heap_destroy_with_catalog(char *relname)
|
||||
|
||||
rel->rd_tmpunlinked = TRUE;
|
||||
|
||||
RelationUnsetLockForWrite(rel);
|
||||
UnlockRelation(rel, AccessExclusiveLock);
|
||||
|
||||
heap_close(rel);
|
||||
|
||||
@@ -1608,16 +1608,16 @@ RemoveAttrDefault(Relation rel)
|
||||
ScanKeyEntryInitialize(&key, 0, Anum_pg_attrdef_adrelid,
|
||||
F_OIDEQ, rel->rd_id);
|
||||
|
||||
RelationSetLockForWrite(adrel);
|
||||
LockRelation(adrel, AccessExclusiveLock);
|
||||
|
||||
adscan = heap_beginscan(adrel, 0, SnapshotNow, 1, &key);
|
||||
|
||||
while (HeapTupleIsValid(tup = heap_getnext(adscan, 0)))
|
||||
heap_delete(adrel, &tup->t_self);
|
||||
heap_delete(adrel, &tup->t_self, NULL);
|
||||
|
||||
heap_endscan(adscan);
|
||||
|
||||
RelationUnsetLockForWrite(adrel);
|
||||
UnlockRelation(adrel, AccessExclusiveLock);
|
||||
heap_close(adrel);
|
||||
|
||||
}
|
||||
@@ -1635,16 +1635,16 @@ RemoveRelCheck(Relation rel)
|
||||
ScanKeyEntryInitialize(&key, 0, Anum_pg_relcheck_rcrelid,
|
||||
F_OIDEQ, rel->rd_id);
|
||||
|
||||
RelationSetLockForWrite(rcrel);
|
||||
LockRelation(rcrel, AccessExclusiveLock);
|
||||
|
||||
rcscan = heap_beginscan(rcrel, 0, SnapshotNow, 1, &key);
|
||||
|
||||
while (HeapTupleIsValid(tup = heap_getnext(rcscan, 0)))
|
||||
heap_delete(rcrel, &tup->t_self);
|
||||
heap_delete(rcrel, &tup->t_self, NULL);
|
||||
|
||||
heap_endscan(rcscan);
|
||||
|
||||
RelationUnsetLockForWrite(rcrel);
|
||||
UnlockRelation(rcrel, AccessExclusiveLock);
|
||||
heap_close(rcrel);
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.65 1998/12/13 04:37:50 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.66 1998/12/15 12:45:43 vadim Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -913,7 +913,7 @@ UpdateIndexPredicate(Oid indexoid, Node *oldPred, Node *predicate)
|
||||
|
||||
newtup = heap_modifytuple(tuple, pg_index, values, nulls, replace);
|
||||
|
||||
heap_replace(pg_index, &newtup->t_self, newtup);
|
||||
heap_replace(pg_index, &newtup->t_self, newtup, NULL);
|
||||
|
||||
pfree(newtup);
|
||||
heap_close(pg_index);
|
||||
@@ -1039,15 +1039,11 @@ index_create(char *heapRelationName,
|
||||
|
||||
heapRelation = heap_open(heapoid);
|
||||
|
||||
/* ----------------
|
||||
* write lock heap to guarantee exclusive access
|
||||
* ----------------
|
||||
RelationSetLockForWrite(heapRelation);
|
||||
* ^^^^^
|
||||
* Does it have any sense ? - vadim 10/27/97
|
||||
/*
|
||||
* Only SELECT ... FOR UPDATE are allowed
|
||||
*/
|
||||
|
||||
RelationSetLockForRead(heapRelation);
|
||||
LockRelation(heapRelation, ShareLock);
|
||||
|
||||
/* ----------------
|
||||
* construct new tuple descriptor
|
||||
@@ -1195,7 +1191,7 @@ index_destroy(Oid indexId)
|
||||
|
||||
AssertState(HeapTupleIsValid(tuple));
|
||||
|
||||
heap_delete(relationRelation, &tuple->t_self);
|
||||
heap_delete(relationRelation, &tuple->t_self, NULL);
|
||||
pfree(tuple);
|
||||
heap_close(relationRelation);
|
||||
|
||||
@@ -1212,7 +1208,7 @@ index_destroy(Oid indexId)
|
||||
Int16GetDatum(attnum),
|
||||
0, 0)))
|
||||
{
|
||||
heap_delete(attributeRelation, &tuple->t_self);
|
||||
heap_delete(attributeRelation, &tuple->t_self, NULL);
|
||||
pfree(tuple);
|
||||
attnum++;
|
||||
}
|
||||
@@ -1232,7 +1228,7 @@ index_destroy(Oid indexId)
|
||||
|
||||
indexRelation = heap_openr(IndexRelationName);
|
||||
|
||||
heap_delete(indexRelation, &tuple->t_self);
|
||||
heap_delete(indexRelation, &tuple->t_self, NULL);
|
||||
pfree(tuple);
|
||||
heap_close(indexRelation);
|
||||
|
||||
@@ -1424,7 +1420,7 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
|
||||
values[Anum_pg_class_relhasindex - 1] = CharGetDatum(hasindex);
|
||||
|
||||
newtup = heap_modifytuple(tuple, pg_class, values, nulls, replace);
|
||||
heap_replace(pg_class, &tuple->t_self, newtup);
|
||||
heap_replace(pg_class, &tuple->t_self, newtup, NULL);
|
||||
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);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.30 1998/11/27 19:51:50 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.31 1998/12/15 12:45:45 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* these routines moved here from commands/define.c and somewhat cleaned up.
|
||||
@@ -711,7 +711,7 @@ OperatorDef(char *operatorName,
|
||||
replaces);
|
||||
|
||||
setheapoverride(true);
|
||||
heap_replace(pg_operator_desc, &tup->t_self, tup);
|
||||
heap_replace(pg_operator_desc, &tup->t_self, tup, NULL);
|
||||
setheapoverride(false);
|
||||
}
|
||||
else
|
||||
@@ -830,7 +830,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
|
||||
replaces);
|
||||
|
||||
setheapoverride(true);
|
||||
heap_replace(pg_operator_desc, &tup->t_self, tup);
|
||||
heap_replace(pg_operator_desc, &tup->t_self, tup, NULL);
|
||||
setheapoverride(false);
|
||||
|
||||
}
|
||||
@@ -855,7 +855,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
|
||||
replaces);
|
||||
|
||||
setheapoverride(true);
|
||||
heap_replace(pg_operator_desc, &tup->t_self, tup);
|
||||
heap_replace(pg_operator_desc, &tup->t_self, tup, NULL);
|
||||
setheapoverride(false);
|
||||
|
||||
values[Anum_pg_operator_oprcom - 1] = (Datum) NULL;
|
||||
@@ -884,7 +884,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
|
||||
replaces);
|
||||
|
||||
setheapoverride(true);
|
||||
heap_replace(pg_operator_desc, &tup->t_self, tup);
|
||||
heap_replace(pg_operator_desc, &tup->t_self, tup, NULL);
|
||||
setheapoverride(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.31 1998/11/27 19:51:51 vadim Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.32 1998/12/15 12:45:47 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -459,7 +459,7 @@ TypeCreate(char *typeName,
|
||||
* when the heap_insert() or heap_replace() is called.
|
||||
* -----------------
|
||||
*/
|
||||
RelationSetLockForWrite(pg_type_desc);
|
||||
LockRelation(pg_type_desc, AccessExclusiveLock);
|
||||
|
||||
typeKey[0].sk_argument = PointerGetDatum(typeName);
|
||||
pg_type_scan = heap_beginscan(pg_type_desc,
|
||||
@@ -484,7 +484,7 @@ TypeCreate(char *typeName,
|
||||
replaces);
|
||||
|
||||
setheapoverride(true);
|
||||
heap_replace(pg_type_desc, &tup->t_self, tup);
|
||||
heap_replace(pg_type_desc, &tup->t_self, tup, NULL);
|
||||
setheapoverride(false);
|
||||
|
||||
typeObjectId = tup->t_data->t_oid;
|
||||
@@ -516,7 +516,7 @@ TypeCreate(char *typeName,
|
||||
CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup);
|
||||
CatalogCloseIndices(Num_pg_type_indices, idescs);
|
||||
}
|
||||
RelationUnsetLockForWrite(pg_type_desc);
|
||||
UnlockRelation(pg_type_desc, AccessExclusiveLock);
|
||||
heap_close(pg_type_desc);
|
||||
|
||||
return typeObjectId;
|
||||
@@ -561,7 +561,7 @@ TypeRename(char *oldTypeName, char *newTypeName)
|
||||
namestrcpy(&(((Form_pg_type) GETSTRUCT(oldtup))->typname), newTypeName);
|
||||
|
||||
setheapoverride(true);
|
||||
heap_replace(pg_type_desc, &oldtup->t_self, oldtup);
|
||||
heap_replace(pg_type_desc, &oldtup->t_self, oldtup, NULL);
|
||||
setheapoverride(false);
|
||||
|
||||
/* update the system catalog indices */
|
||||
|
||||
Reference in New Issue
Block a user