diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index c8436b709d1da6099e17bab7a0c05b4a495a4abf..9f81057d615f21754ea7ddeb431b1f6ce3e51951 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.108 2001/01/15 05:29:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.109 2001/01/23 04:32:20 tgl Exp $ * * * INTERFACE ROUTINES @@ -1423,6 +1423,9 @@ heap_insert(Relation relation, HeapTuple tup) /* * heap_delete - delete a tuple + * + * NB: do not call this directly unless you are prepared to deal with + * concurrent-update conditions. Use simple_heap_delete instead. */ int heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid) @@ -1496,8 +1499,7 @@ l1: if (result != HeapTupleMayBeUpdated) { Assert(result == HeapTupleSelfUpdated || result == HeapTupleUpdated); - if (ctid != NULL) - *ctid = tp.t_data->t_ctid; + *ctid = tp.t_data->t_ctid; LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); return result; @@ -1560,8 +1562,48 @@ l1: return HeapTupleMayBeUpdated; } +/* + * simple_heap_delete - delete a tuple + * + * This routine may be used to delete a tuple when concurrent updates of + * the target tuple are not expected (for example, because we have a lock + * on the relation associated with the tuple). Any failure is reported + * via elog(). + */ +void +simple_heap_delete(Relation relation, ItemPointer tid) +{ + ItemPointerData ctid; + int result; + + result = heap_delete(relation, tid, &ctid); + switch (result) + { + case HeapTupleSelfUpdated: + /* Tuple was already updated in current command? */ + elog(ERROR, "simple_heap_delete: tuple already updated by self"); + break; + + case HeapTupleMayBeUpdated: + /* done successfully */ + break; + + case HeapTupleUpdated: + elog(ERROR, "simple_heap_delete: tuple concurrently updated"); + break; + + default: + elog(ERROR, "Unknown status %u from heap_delete", result); + break; + } + +} + /* * heap_update - replace a tuple + * + * NB: do not call this directly unless you are prepared to deal with + * concurrent-update conditions. Use simple_heap_update instead. */ int heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, @@ -1643,8 +1685,7 @@ l2: if (result != HeapTupleMayBeUpdated) { Assert(result == HeapTupleSelfUpdated || result == HeapTupleUpdated); - if (ctid != NULL) - *ctid = oldtup.t_data->t_ctid; + *ctid = oldtup.t_data->t_ctid; LockBuffer(buffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(buffer); return result; @@ -1783,6 +1824,42 @@ l2: return HeapTupleMayBeUpdated; } +/* + * simple_heap_update - replace a tuple + * + * This routine may be used to update a tuple when concurrent updates of + * the target tuple are not expected (for example, because we have a lock + * on the relation associated with the tuple). Any failure is reported + * via elog(). + */ +void +simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup) +{ + ItemPointerData ctid; + int result; + + result = heap_update(relation, otid, tup, &ctid); + switch (result) + { + case HeapTupleSelfUpdated: + /* Tuple was already updated in current command? */ + elog(ERROR, "simple_heap_update: tuple already updated by self"); + break; + + case HeapTupleMayBeUpdated: + /* done successfully */ + break; + + case HeapTupleUpdated: + elog(ERROR, "simple_heap_update: tuple concurrently updated"); + break; + + default: + elog(ERROR, "Unknown status %u from heap_update", result); + break; + } +} + /* * heap_mark4update - mark a tuple for update */ diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c index 46495404b8148f2155cdcd619179e540ea37f99a..da2f9612a41b98e4559458c1f4e507ab2ec419d0 100644 --- a/src/backend/access/heap/tuptoaster.c +++ b/src/backend/access/heap/tuptoaster.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.14 2001/01/15 05:29:19 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.15 2001/01/23 04:32:20 tgl Exp $ * * * INTERFACE ROUTINES @@ -937,7 +937,7 @@ toast_delete_datum(Relation rel, Datum value) * Have a chunk, delete it * ---------- */ - heap_delete(toastrel, &toasttup.t_self, NULL); + simple_heap_delete(toastrel, &toasttup.t_self); ReleaseBuffer(buffer); } diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 67f675f0d3b8dfb9fe67a3785f4f0e0a2f5c79ff..080eb82ef0cba9f46a6c774a3ea11bf3035d271d 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.44 2000/11/28 23:42:31 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.45 2001/01/23 04:32:21 tgl Exp $ * * NOTES * See acl.h. @@ -139,7 +139,7 @@ ChangeAcl(char *relname, ReleaseSysCache(tuple); - heap_update(relation, &newtuple->t_self, newtuple, NULL); + simple_heap_update(relation, &newtuple->t_self, newtuple); /* keep the catalog indices up to date */ CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index b869480fe309586f234b586cc5bff99b4d874844..75307f20f20523081832c6c5a8cc358c00ff9f93 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.156 2001/01/01 21:33:31 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.157 2001/01/23 04:32:21 tgl Exp $ * * * INTERFACE ROUTINES @@ -1000,7 +1000,7 @@ RelationRemoveInheritance(Relation relation) while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) { - heap_delete(catalogRelation, &tuple->t_self, NULL); + simple_heap_delete(catalogRelation, &tuple->t_self); found = true; } @@ -1023,7 +1023,9 @@ RelationRemoveInheritance(Relation relation) &entry); while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) - heap_delete(catalogRelation, &tuple->t_self, NULL); + { + simple_heap_delete(catalogRelation, &tuple->t_self); + } heap_endscan(scan); heap_close(catalogRelation, RowExclusiveLock); @@ -1093,7 +1095,7 @@ DeleteRelationTuple(Relation rel) * delete the relation tuple from pg_class, and finish up. * ---------------- */ - heap_delete(pg_class_desc, &tup->t_self, NULL); + simple_heap_delete(pg_class_desc, &tup->t_self); heap_freetuple(tup); heap_close(pg_class_desc, RowExclusiveLock); @@ -1267,7 +1269,7 @@ DeleteAttributeTuples(Relation rel) /*** Delete any comments associated with this attribute ***/ DeleteComments(tup->t_data->t_oid); - heap_delete(pg_attribute_desc, &tup->t_self, NULL); + simple_heap_delete(pg_attribute_desc, &tup->t_self); heap_freetuple(tup); } } @@ -1382,12 +1384,10 @@ DeleteTypeTuple(Relation rel) /* ---------------- * Ok, it's safe so we delete the relation tuple - * from pg_type and finish up. But first end the scan so that - * we release the read lock on pg_type. -mer 13 Aug 1991 + * from pg_type and finish up. * ---------------- */ - - heap_delete(pg_type_desc, &tup->t_self, NULL); + simple_heap_delete(pg_type_desc, &tup->t_self); heap_endscan(pg_type_scan); heap_close(pg_type_desc, RowExclusiveLock); @@ -1595,7 +1595,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin, if (!attStruct->atthasdef) { attStruct->atthasdef = true; - heap_update(attrrel, &atttup->t_self, atttup, NULL); + simple_heap_update(attrrel, &atttup->t_self, atttup); /* keep catalog indices current */ CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, attridescs); @@ -1962,7 +1962,7 @@ AddRelationRawConstraints(Relation rel, relStruct->relchecks = numchecks; - heap_update(relrel, &reltup->t_self, reltup, NULL); + simple_heap_update(relrel, &reltup->t_self, reltup); /* keep catalog indices current */ CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, @@ -1990,7 +1990,9 @@ RemoveAttrDefault(Relation rel) adscan = heap_beginscan(adrel, 0, SnapshotNow, 1, &key); while (HeapTupleIsValid(tup = heap_getnext(adscan, 0))) - heap_delete(adrel, &tup->t_self, NULL); + { + simple_heap_delete(adrel, &tup->t_self); + } heap_endscan(adscan); heap_close(adrel, RowExclusiveLock); @@ -2012,7 +2014,9 @@ RemoveRelCheck(Relation rel) rcscan = heap_beginscan(rcrel, 0, SnapshotNow, 1, &key); while (HeapTupleIsValid(tup = heap_getnext(rcscan, 0))) - heap_delete(rcrel, &tup->t_self, NULL); + { + simple_heap_delete(rcrel, &tup->t_self); + } heap_endscan(rcscan); heap_close(rcrel, RowExclusiveLock); @@ -2049,7 +2053,9 @@ RemoveStatistics(Relation rel) scan = heap_beginscan(pgstatistic, false, SnapshotNow, 1, &key); while (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) - heap_delete(pgstatistic, &tuple->t_self, NULL); + { + simple_heap_delete(pgstatistic, &tuple->t_self); + } heap_endscan(scan); heap_close(pgstatistic, RowExclusiveLock); diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 3ad84b506b4a67479dabc6e7ff0c3ed7dfbe9d62..590e2a59f33037584e64cff70fce3d55a8b8c494 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.135 2001/01/18 07:29:04 inoue Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.136 2001/01/23 04:32:21 tgl Exp $ * * * INTERFACE ROUTINES @@ -783,7 +783,7 @@ UpdateIndexPredicate(Oid indexoid, Node *oldPred, Node *predicate) newtup = heap_modifytuple(tuple, pg_index, values, nulls, replace); - heap_update(pg_index, &newtup->t_self, newtup, NULL); + simple_heap_update(pg_index, &newtup->t_self, newtup); heap_freetuple(newtup); ReleaseSysCache(tuple); @@ -1085,7 +1085,7 @@ index_drop(Oid indexId) elog(ERROR, "index_drop: cache lookup failed for index %u", indexId); - heap_delete(relationRelation, &tuple->t_self, NULL); + simple_heap_delete(relationRelation, &tuple->t_self); heap_freetuple(tuple); /* @@ -1113,7 +1113,7 @@ index_drop(Oid indexId) Int16GetDatum(attnum), 0, 0))) { - heap_delete(attributeRelation, &tuple->t_self, NULL); + simple_heap_delete(attributeRelation, &tuple->t_self); heap_freetuple(tuple); attnum++; } @@ -1132,7 +1132,7 @@ index_drop(Oid indexId) elog(ERROR, "index_drop: cache lookup failed for index %u", indexId); - heap_delete(indexRelation, &tuple->t_self, NULL); + simple_heap_delete(indexRelation, &tuple->t_self); heap_freetuple(tuple); heap_close(indexRelation, RowExclusiveLock); @@ -1495,7 +1495,7 @@ setRelhasindex(Oid relid, bool hasindex) } else { - heap_update(pg_class, &tuple->t_self, tuple, NULL); + simple_heap_update(pg_class, &tuple->t_self, tuple); /* Keep the catalog indices up to date */ if (!IsIgnoringSystemIndexes()) @@ -1545,7 +1545,7 @@ setNewRelfilenode(Relation relation) classTuple = heap_copytuple(&lockTupleData); ReleaseBuffer(buffer); ((Form_pg_class) GETSTRUCT(classTuple))->relfilenode = newrelfilenode; - heap_update(pg_class, &classTuple->t_self, classTuple, NULL); + simple_heap_update(pg_class, &classTuple->t_self, classTuple); } /* unlink old relfilenode */ DropRelationBuffers(relation); @@ -1751,7 +1751,7 @@ UpdateStats(Oid relid, long reltuples) replace[Anum_pg_class_reltuples - 1] = 'r'; values[Anum_pg_class_reltuples - 1] = (Datum) reltuples; newtup = heap_modifytuple(tuple, pg_class, values, nulls, replace); - heap_update(pg_class, &tuple->t_self, newtup, NULL); + simple_heap_update(pg_class, &tuple->t_self, newtup); if (!IsIgnoringSystemIndexes()) { CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs); diff --git a/src/backend/catalog/pg_largeobject.c b/src/backend/catalog/pg_largeobject.c index c471a9ae139fc838e951267dfc1db2760b31eb2d..45d205bb32ed8d275b0a9e51b687133ed970743c 100644 --- a/src/backend/catalog/pg_largeobject.c +++ b/src/backend/catalog/pg_largeobject.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.5 2000/10/24 01:38:23 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.6 2001/01/23 04:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -118,7 +118,7 @@ LargeObjectDrop(Oid loid) pfree(indexRes); if (tuple.t_data != NULL) { - heap_delete(pg_largeobject, &tuple.t_self, NULL); + simple_heap_delete(pg_largeobject, &tuple.t_self); ReleaseBuffer(buffer); found = true; } diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index 29f404063ff87e87cf7de163b725f32a9e7a40fe..76eaaad01c6ff8a5d96bd0d634acff3ec434039f 100644 --- a/src/backend/catalog/pg_operator.c +++ b/src/backend/catalog/pg_operator.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.53 2000/11/16 22:30:17 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.54 2001/01/23 04:32:21 tgl Exp $ * * NOTES * these routines moved here from commands/define.c and somewhat cleaned up. @@ -801,7 +801,7 @@ OperatorDef(char *operatorName, nulls, replaces); - heap_update(pg_operator_desc, &tup->t_self, tup, NULL); + simple_heap_update(pg_operator_desc, &tup->t_self, tup); } else elog(ERROR, "OperatorDef: no operator %u", operatorObjectId); @@ -935,7 +935,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) nulls, replaces); - heap_update(pg_operator_desc, &tup->t_self, tup, NULL); + simple_heap_update(pg_operator_desc, &tup->t_self, tup); if (RelationGetForm(pg_operator_desc)->relhasindex) { @@ -967,7 +967,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) nulls, replaces); - heap_update(pg_operator_desc, &tup->t_self, tup, NULL); + simple_heap_update(pg_operator_desc, &tup->t_self, tup); if (RelationGetForm(pg_operator_desc)->relhasindex) { @@ -1005,7 +1005,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) nulls, replaces); - heap_update(pg_operator_desc, &tup->t_self, tup, NULL); + simple_heap_update(pg_operator_desc, &tup->t_self, tup); if (RelationGetForm(pg_operator_desc)->relhasindex) { diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index f1f306424f070b6bd136baa6fec4f794926ab27d..07b2987fd9161367fcf08aab1ae06f57202fcad3 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.56 2000/11/16 22:30:17 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.57 2001/01/23 04:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -490,7 +490,7 @@ TypeCreate(char *typeName, nulls, replaces); - heap_update(pg_type_desc, &tup->t_self, tup, NULL); + simple_heap_update(pg_type_desc, &tup->t_self, tup); typeObjectId = tup->t_data->t_oid; } @@ -555,7 +555,7 @@ TypeRename(const char *oldTypeName, const char *newTypeName) namestrcpy(&(((Form_pg_type) GETSTRUCT(tuple))->typname), newTypeName); - heap_update(pg_type_desc, &tuple->t_self, tuple, NULL); + simple_heap_update(pg_type_desc, &tuple->t_self, tuple); /* update the system catalog indices */ CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs); diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 889cd5316e81156142cc1ff99c34219aec6f26ca..98df8370b9c88eb4581ce2b2ba763bf25202e081 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.11 2001/01/14 05:08:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.12 2001/01/23 04:32:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -664,7 +664,7 @@ del_stats(Oid relid, int attcnt, int *attnums) if (i >= attcnt) continue; /* don't delete it */ } - heap_delete(pgstatistic, &tuple->t_self, NULL); + simple_heap_delete(pgstatistic, &tuple->t_self); } heap_endscan(scan); diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index b86f2421eb8403fd9b0cb73d6c8f25f8536f6811..a2bcbb5b663b5cac083f29b247d2ce7ba82f5916 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.74 2000/12/18 17:33:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.75 2001/01/23 04:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -299,7 +299,7 @@ Async_Unlisten(char *relname, int pid) 0, 0); if (HeapTupleIsValid(lTuple)) { - heap_delete(lRel, &lTuple->t_self, NULL); + simple_heap_delete(lRel, &lTuple->t_self); ReleaseSysCache(lTuple); } heap_close(lRel, AccessExclusiveLock); @@ -349,7 +349,9 @@ Async_UnlistenAll() sRel = heap_beginscan(lRel, 0, SnapshotNow, 1, key); while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0))) - heap_delete(lRel, &lTuple->t_self, NULL); + { + simple_heap_delete(lRel, &lTuple->t_self); + } heap_endscan(sRel); heap_close(lRel, AccessExclusiveLock); @@ -506,7 +508,7 @@ AtCommit_Notify() * just do it for any failure (certainly at least for * EPERM too...) */ - heap_delete(lRel, &lTuple->t_self, NULL); + simple_heap_delete(lRel, &lTuple->t_self); } else { @@ -516,7 +518,7 @@ AtCommit_Notify() { rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl); - heap_update(lRel, &lTuple->t_self, rTuple, NULL); + simple_heap_update(lRel, &lTuple->t_self, rTuple); if (RelationGetForm(lRel)->relhasindex) { Relation idescs[Num_pg_listener_indices]; @@ -797,7 +799,7 @@ ProcessIncomingNotify(void) NotifyMyFrontEnd(relname, sourcePID); /* Rewrite the tuple with 0 in notification column */ rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl); - heap_update(lRel, &lTuple->t_self, rTuple, NULL); + simple_heap_update(lRel, &lTuple->t_self, rTuple); if (RelationGetForm(lRel)->relhasindex) { Relation idescs[Num_pg_listener_indices]; diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 2808127d71e08a519fc5fb8557ee906a155015c1..a7901d0884ca0a3666312be1d3bd51e736244920 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.117 2001/01/23 01:48:16 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.118 2001/01/23 04:32:22 tgl Exp $ * * NOTES * The PerformAddAttribute() code, like most of the relation @@ -467,7 +467,7 @@ AlterTableAddColumn(const char *relationName, newreltup = heap_copytuple(reltup); ((Form_pg_class) GETSTRUCT(newreltup))->relnatts = maxatts; - heap_update(rel, &newreltup->t_self, newreltup, NULL); + simple_heap_update(rel, &newreltup->t_self, newreltup); /* keep catalog indices current */ CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs); @@ -620,7 +620,7 @@ AlterTableAlterColumn(const char *relationName, /* update to false */ newtuple = heap_copytuple(tuple); ((Form_pg_attribute) GETSTRUCT(newtuple))->atthasdef = FALSE; - heap_update(attr_rel, &tuple->t_self, newtuple, NULL); + simple_heap_update(attr_rel, &tuple->t_self, newtuple); /* keep the system catalog indices current */ CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations); @@ -657,10 +657,9 @@ drop_default(Oid relid, int16 attnum) Int16GetDatum(attnum)); scan = heap_beginscan(attrdef_rel, false, SnapshotNow, 2, scankeys); - AssertState(scan != NULL); if (HeapTupleIsValid(tuple = heap_getnext(scan, 0))) - heap_delete(attrdef_rel, &tuple->t_self, NULL); + simple_heap_delete(attrdef_rel, &tuple->t_self); heap_endscan(scan); @@ -833,7 +832,7 @@ RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup) } else { - heap_delete(rcrel, &htup->t_self, NULL); + simple_heap_delete(rcrel, &htup->t_self); pgcform->relchecks--; } } @@ -1008,7 +1007,7 @@ AlterTableDropColumn(const char *relationName, namestrcpy(&(attribute->attname), dropColname); ATTRIBUTE_DROP_COLUMN(attribute); - heap_update(attrdesc, &tup->t_self, tup, NULL); + simple_heap_update(attrdesc, &tup->t_self, tup); hasindex = (!IsIgnoringSystemIndexes() && RelationGetForm(attrdesc)->relhasindex); if (hasindex) { @@ -1038,7 +1037,7 @@ AlterTableDropColumn(const char *relationName, { if (((Form_pg_attrdef) GETSTRUCT(tup))->adnum == attnum) { - heap_delete(adrel, &tup->t_self, NULL); + simple_heap_delete(adrel, &tup->t_self); break; } } @@ -1054,7 +1053,7 @@ AlterTableDropColumn(const char *relationName, RemoveColumnReferences(myrelid, attnum, false, reltup); /* update pg_class tuple */ - heap_update(rel, &reltup->t_self, reltup, NULL); + simple_heap_update(rel, &reltup->t_self, reltup); CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs); CatalogIndexInsert(ridescs, Num_pg_class_indices, rel, reltup); CatalogCloseIndices(Num_pg_class_indices, ridescs); @@ -1496,7 +1495,7 @@ AlterTableOwner(const char *relationName, const char *newOwnerName) */ ((Form_pg_class) GETSTRUCT(tuple))->relowner = newOwnerSysid; - heap_update(class_rel, &tuple->t_self, tuple, NULL); + simple_heap_update(class_rel, &tuple->t_self, tuple); /* Keep the catalog indices up to date */ CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs); @@ -1692,7 +1691,7 @@ AlterTableCreateToastTable(const char *relationName, bool silent) */ ((Form_pg_class) GETSTRUCT(reltup))->reltoastrelid = toast_relid; ((Form_pg_class) GETSTRUCT(reltup))->reltoastidxid = toast_idxid; - heap_update(class_rel, &reltup->t_self, reltup, NULL); + simple_heap_update(class_rel, &reltup->t_self, reltup); /* * Keep catalog indices current diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c index 1af4ba102f7e39de2aadf1a0f9767529c1679584..46e8b8057ec7bf0dd6f3af198276c29e338c1cea 100644 --- a/src/backend/commands/comment.c +++ b/src/backend/commands/comment.c @@ -6,6 +6,9 @@ * * Copyright (c) 1999, PostgreSQL Global Development Group * + * IDENTIFICATION + * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.26 2001/01/23 04:32:21 tgl Exp $ + * *------------------------------------------------------------------------- */ @@ -169,15 +172,15 @@ CreateComments(Oid oid, char *comment) if (HeapTupleIsValid(searchtuple)) { - /*** If the comment is blank, call heap_delete, else heap_update ***/ + /*** If the comment is blank, delete old entry, else update it ***/ if ((comment == NULL) || (strlen(comment) == 0)) - heap_delete(description, &searchtuple->t_self, NULL); + simple_heap_delete(description, &searchtuple->t_self); else { desctuple = heap_modifytuple(searchtuple, description, values, nulls, replaces); - heap_update(description, &searchtuple->t_self, desctuple, NULL); + simple_heap_update(description, &searchtuple->t_self, desctuple); modified = TRUE; } @@ -253,7 +256,7 @@ DeleteComments(Oid oid) /*** If a previous tuple exists, delete it ***/ if (HeapTupleIsValid(searchtuple)) - heap_delete(description, &searchtuple->t_self, NULL); + simple_heap_delete(description, &searchtuple->t_self); /*** Complete the scan, update indices, if necessary ***/ @@ -395,7 +398,7 @@ CommentDatabase(char *database, char *comment) Oid oid; bool superuser; int32 dba; - Oid userid; + Oid userid; /*** First find the tuple in pg_database for the database ***/ diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index 22a34d2e5a39c88213da737747213311285e212c..b9284604e72a19c3a1b61f30dce89fbb8409a5e5 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.70 2001/01/05 02:58:16 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.71 2001/01/23 04:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -771,7 +771,7 @@ setRelhassubclassInRelation(Oid relationId, bool relhassubclass) elog(ERROR, "setRelhassubclassInRelation: cache lookup failed for relation %u", relationId); ((Form_pg_class) GETSTRUCT(tuple))->relhassubclass = relhassubclass; - heap_update(relationRelation, &tuple->t_self, tuple, NULL); + simple_heap_update(relationRelation, &tuple->t_self, tuple); /* keep the catalog indices up to date */ CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs); diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index 6f2923e6a8d58b28143203a2166930912ebad717..bdbc21619d1239803cafee13e97c8bc82a7cb19d 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.71 2001/01/14 22:14:10 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.72 2001/01/23 04:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -347,7 +347,7 @@ dropdb(const char *dbname) } /* Remove the database's tuple from pg_database */ - heap_delete(pgdbrel, &tup->t_self, NULL); + simple_heap_delete(pgdbrel, &tup->t_self); heap_endscan(pgdbscan); diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index aead01b9736f31386d9b065d0e1b93a26f99a394..bbf008c918eb88972c9c16d930c226831872bf89 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -179,7 +179,7 @@ DropProceduralLanguage(DropPLangStmt *stmt) elog(ERROR, "Language %s isn't a created procedural language", languageName); - heap_delete(rel, &langTup->t_self, NULL); + simple_heap_delete(rel, &langTup->t_self); heap_freetuple(langTup); heap_close(rel, RowExclusiveLock); diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c index 7353ae2ca82815f11a7a271e57c7d30570e6f9fd..bfb2cd8dc915b8c64a09410a9c4763570d253099 100644 --- a/src/backend/commands/remove.c +++ b/src/backend/commands/remove.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.57 2000/12/15 04:08:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.58 2001/01/23 04:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -91,7 +91,7 @@ RemoveOperator(char *operatorName, /* operator name */ DeleteComments(tup->t_data->t_oid); - heap_delete(relation, &tup->t_self, NULL); + simple_heap_delete(relation, &tup->t_self); } else @@ -154,8 +154,7 @@ SingleOpOperatorRemove(Oid typeOid) DeleteComments(tup->t_data->t_oid); - heap_delete(rel, &tup->t_self, NULL); - + simple_heap_delete(rel, &tup->t_self); } heap_endscan(scan); @@ -266,7 +265,7 @@ RemoveType(char *typeName) /* type name to be removed */ DeleteComments(typeOid); - heap_delete(relation, &tup->t_self, NULL); + simple_heap_delete(relation, &tup->t_self); ReleaseSysCache(tup); @@ -278,7 +277,7 @@ RemoveType(char *typeName) /* type name to be removed */ if (!HeapTupleIsValid(tup)) elog(ERROR, "RemoveType: type '%s' does not exist", shadow_type); - heap_delete(relation, &tup->t_self, NULL); + simple_heap_delete(relation, &tup->t_self); ReleaseSysCache(tup); @@ -354,7 +353,7 @@ RemoveFunction(char *functionName, /* function name to be removed */ DeleteComments(tup->t_data->t_oid); - heap_delete(relation, &tup->t_self, NULL); + simple_heap_delete(relation, &tup->t_self); ReleaseSysCache(tup); @@ -428,7 +427,7 @@ RemoveAggregate(char *aggName, char *aggType) DeleteComments(tup->t_data->t_oid); - heap_delete(relation, &tup->t_self, NULL); + simple_heap_delete(relation, &tup->t_self); ReleaseSysCache(tup); diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c index 3722948047b16ea1e8f49f2fb8fecf74869dfea0..8bf47473caac08e1e1708073d7d6051da4ddae7e 100644 --- a/src/backend/commands/rename.c +++ b/src/backend/commands/rename.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.53 2000/11/16 22:30:18 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.54 2001/01/23 04:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -152,7 +152,7 @@ renameatt(char *relname, StrNCpy(NameStr(((Form_pg_attribute) GETSTRUCT(atttup))->attname), newattname, NAMEDATALEN); - heap_update(attrelation, &atttup->t_self, atttup, NULL); + simple_heap_update(attrelation, &atttup->t_self, atttup); /* keep system catalog indices current */ { @@ -250,7 +250,7 @@ renamerel(const char *oldrelname, const char *newrelname) StrNCpy(NameStr(((Form_pg_class) GETSTRUCT(reltup))->relname), newrelname, NAMEDATALEN); - heap_update(relrelation, &reltup->t_self, reltup, NULL); + simple_heap_update(relrelation, &reltup->t_self, reltup); /* keep the system catalog indices current */ CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, irelations); diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index ccb2aa5fce3806c0a75ded1d9889d9158c6d1c2e..2775de5e70ec4137425ab086781c7deead2d91ad 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.83 2001/01/22 00:50:07 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.84 2001/01/23 04:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -277,7 +277,7 @@ CreateTrigger(CreateTrigStmt *stmt) stmt->relname); ((Form_pg_class) GETSTRUCT(tuple))->reltriggers = found + 1; - heap_update(pgrel, &tuple->t_self, tuple, NULL); + simple_heap_update(pgrel, &tuple->t_self, tuple); CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs); CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple); CatalogCloseIndices(Num_pg_class_indices, ridescs); @@ -333,7 +333,7 @@ DropTrigger(DropTrigStmt *stmt) DeleteComments(tuple->t_data->t_oid); - heap_delete(tgrel, &tuple->t_self, NULL); + simple_heap_delete(tgrel, &tuple->t_self); tgfound++; } else @@ -362,7 +362,7 @@ DropTrigger(DropTrigStmt *stmt) stmt->relname); ((Form_pg_class) GETSTRUCT(tuple))->reltriggers = found; - heap_update(pgrel, &tuple->t_self, tuple, NULL); + simple_heap_update(pgrel, &tuple->t_self, tuple); CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs); CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple); CatalogCloseIndices(Num_pg_class_indices, ridescs); @@ -404,7 +404,7 @@ RelationRemoveTriggers(Relation rel) DeleteComments(tup->t_data->t_oid); - heap_delete(tgrel, &tup->t_self, NULL); + simple_heap_delete(tgrel, &tup->t_self); found = true; } @@ -435,7 +435,7 @@ RelationRemoveTriggers(Relation rel) RelationGetRelid(rel)); ((Form_pg_class) GETSTRUCT(tup))->reltriggers = 0; - heap_update(pgrel, &tup->t_self, tup, NULL); + simple_heap_update(pgrel, &tup->t_self, tup); CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs); CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tup); CatalogCloseIndices(Num_pg_class_indices, ridescs); diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 27f1d3c2e16114ab84cc6ffdf5dd2d5304137af3..e0cadbde95a390fbd9aca611a60da2b401658906 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.71 2001/01/17 17:26:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.72 2001/01/23 04:32:21 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -458,10 +458,7 @@ AlterUser(AlterUserStmt *stmt) } new_tuple = heap_formtuple(pg_shadow_dsc, new_record, new_record_nulls); - Assert(new_tuple); - /* XXX check return value of this? */ - heap_update(pg_shadow_rel, &tuple->t_self, new_tuple, NULL); - + simple_heap_update(pg_shadow_rel, &tuple->t_self, new_tuple); /* Update indexes */ if (RelationGetForm(pg_shadow_rel)->relhasindex) @@ -581,7 +578,7 @@ DropUser(DropUserStmt *stmt) /* * Remove the user from the pg_shadow table */ - heap_delete(pg_shadow_rel, &tuple->t_self, NULL); + simple_heap_delete(pg_shadow_rel, &tuple->t_self); ReleaseSysCache(tuple); @@ -929,7 +926,7 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag) new_record[Anum_pg_group_grolist - 1] = PointerGetDatum(newarray); tuple = heap_formtuple(pg_group_dsc, new_record, new_record_nulls); - heap_update(pg_group_rel, &group_tuple->t_self, tuple, NULL); + simple_heap_update(pg_group_rel, &group_tuple->t_self, tuple); /* Update indexes */ if (RelationGetForm(pg_group_rel)->relhasindex) @@ -1035,7 +1032,7 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag) new_record[Anum_pg_group_grolist - 1] = PointerGetDatum(newarray); tuple = heap_formtuple(pg_group_dsc, new_record, new_record_nulls); - heap_update(pg_group_rel, &group_tuple->t_self, tuple, NULL); + simple_heap_update(pg_group_rel, &group_tuple->t_self, tuple); /* Update indexes */ if (RelationGetForm(pg_group_rel)->relhasindex) @@ -1093,7 +1090,7 @@ DropGroup(DropGroupStmt *stmt) if (datum && !null && strcmp((char *) datum, stmt->name) == 0) { gro_exists = true; - heap_delete(pg_group_rel, &tuple->t_self, NULL); + simple_heap_delete(pg_group_rel, &tuple->t_self); } } diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c index 760614461cda72c482beb864dc8ff0b8be536911..19334d7975e605a3a2aa085264878fe58fc1578e 100644 --- a/src/backend/rewrite/rewriteRemove.c +++ b/src/backend/rewrite/rewriteRemove.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.41 2000/11/16 22:30:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.42 2001/01/23 04:32:22 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -124,7 +124,7 @@ RemoveRewriteRule(char *ruleName) /* * Now delete the pg_rewrite tuple for the rule */ - heap_delete(RewriteRelation, &tuple->t_self, NULL); + simple_heap_delete(RewriteRelation, &tuple->t_self); heap_freetuple(tuple); @@ -181,8 +181,7 @@ RelationRemoveRules(Oid relid) DeleteComments(tuple->t_data->t_oid); - heap_delete(RewriteRelation, &tuple->t_self, NULL); - + simple_heap_delete(RewriteRelation, &tuple->t_self); } heap_endscan(scanDesc); diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c index 30e4ba6e603cc3cbd3d17b20bb9860051ca83e25..b4d94023cb383ae10f0ec3457e4d3c211fcb9859 100644 --- a/src/backend/rewrite/rewriteSupport.c +++ b/src/backend/rewrite/rewriteSupport.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.45 2000/11/16 22:30:29 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.46 2001/01/23 04:32:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,7 @@ SetRelationRuleStatus(Oid relationId, bool relHasRules, if (relIsBecomingView) ((Form_pg_class) GETSTRUCT(tuple))->relkind = RELKIND_VIEW; - heap_update(relationRelation, &tuple->t_self, tuple, NULL); + simple_heap_update(relationRelation, &tuple->t_self, tuple); /* Keep the catalog indices up to date */ CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs); diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index a4be699f420b971f50389c5731c33bc4cd6d339d..1c8ef0dd40d3198bea0a93eb676d39dfedd9644b 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.82 2001/01/21 03:50:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.83 2001/01/23 04:32:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -522,7 +522,7 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes) replace[Anum_pg_largeobject_data - 1] = 'r'; newtup = heap_modifytuple(&oldtuple, obj_desc->heap_r, values, nulls, replace); - heap_update(obj_desc->heap_r, &newtup->t_self, newtup, NULL); + simple_heap_update(obj_desc->heap_r, &newtup->t_self, newtup); if (write_indices) CatalogIndexInsert(idescs, Num_pg_largeobject_indices, obj_desc->heap_r, newtup); diff --git a/src/backend/utils/adt/sets.c b/src/backend/utils/adt/sets.c index 6f64847dcab97d148fa4d5faa03c25ef7387284d..5c107eaf68711dd4f4c5ccae4626eb1b1c4fa35b 100644 --- a/src/backend/utils/adt/sets.c +++ b/src/backend/utils/adt/sets.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.34 2000/11/16 22:30:31 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.35 2001/01/23 04:32:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -113,7 +113,7 @@ SetDefine(char *querystr, char *typename) replNull, repl); - heap_update(procrel, &newtup->t_self, newtup, NULL); + simple_heap_update(procrel, &newtup->t_self, newtup); setoid = newtup->t_data->t_oid; diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 7618cc55ae5e661ebdbe1347b55511926deccca0..461599cee126494a0af3dfcffb82f404ee6227f7 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: heapam.h,v 1.60 2000/12/27 23:59:13 tgl Exp $ + * $Id: heapam.h,v 1.61 2001/01/23 04:32:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -209,6 +209,9 @@ extern int heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid); extern int heap_update(Relation relation, ItemPointer otid, HeapTuple tup, ItemPointer ctid); extern int heap_mark4update(Relation relation, HeapTuple tup, Buffer *userbuf); +extern void simple_heap_delete(Relation relation, ItemPointer tid); +extern void simple_heap_update(Relation relation, ItemPointer otid, + HeapTuple tup); extern void heap_markpos(HeapScanDesc scan); extern void heap_restrpos(HeapScanDesc scan);