aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-01-23 04:32:23 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-01-23 04:32:23 +0000
commit786f1a59cd44f890b2423e15ba3ab172dab968bf (patch)
tree30a730a13a351ac02264f7f48ab6145eb7c51e17 /src/backend/commands
parent7a2a1acd520761b479c9dfc4a8e573aeec626094 (diff)
downloadpostgresql-786f1a59cd44f890b2423e15ba3ab172dab968bf.tar.gz
postgresql-786f1a59cd44f890b2423e15ba3ab172dab968bf.zip
Fix all the places that called heap_update() and heap_delete() without
bothering to check the return value --- which meant that in case the update or delete failed because of a concurrent update, you'd not find out about it, except by observing later that the transaction produced the wrong outcome. There are now subroutines simple_heap_update and simple_heap_delete that should be used anyplace that you're not prepared to do the full nine yards of coping with concurrent updates. In practice, that seems to mean absolutely everywhere but the executor, because *noplace* else was checking.
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/analyze.c4
-rw-r--r--src/backend/commands/async.c14
-rw-r--r--src/backend/commands/command.c21
-rw-r--r--src/backend/commands/comment.c13
-rw-r--r--src/backend/commands/creatinh.c4
-rw-r--r--src/backend/commands/dbcommands.c4
-rw-r--r--src/backend/commands/proclang.c2
-rw-r--r--src/backend/commands/remove.c15
-rw-r--r--src/backend/commands/rename.c6
-rw-r--r--src/backend/commands/trigger.c12
-rw-r--r--src/backend/commands/user.c15
11 files changed, 55 insertions, 55 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 889cd5316e8..98df8370b9c 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 b86f2421eb8..a2bcbb5b663 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 2808127d71e..a7901d0884c 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 1af4ba102f7..46e8b8057ec 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 22a34d2e5a3..b9284604e72 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 6f2923e6a8d..bdbc21619d1 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 aead01b9736..bbf008c918e 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 7353ae2ca82..bfb2cd8dc91 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 3722948047b..8bf47473caa 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 ccb2aa5fce3..2775de5e70e 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 27f1d3c2e16..e0cadbde95a 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);
}
}