]> granicus.if.org Git - postgresql/commitdiff
Provide CatalogTupleDelete() as a wrapper around simple_heap_delete().
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 1 Feb 2017 21:13:30 +0000 (16:13 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 1 Feb 2017 21:13:30 +0000 (16:13 -0500)
This extends the work done in commit 2f5c9d9c9 to provide a more nearly
complete abstraction layer hiding the details of index updating for catalog
changes.  That commit only invented abstractions for catalog inserts and
updates, leaving nearby code for catalog deletes still calling the
heap-level routines directly.  That seems rather ugly from here, and it
does little to help if we ever want to shift to a storage system in which
indexing work is needed at delete time.

Hence, create a wrapper function CatalogTupleDelete(), and replace calls
of simple_heap_delete() on catalog tuples with it.  There are now very
few direct calls of [simple_]heap_delete remaining in the tree.

Discussion: https://postgr.es/m/462.1485902736@sss.pgh.pa.us

40 files changed:
src/backend/catalog/aclchk.c
src/backend/catalog/dependency.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/indexing.c
src/backend/catalog/pg_collation.c
src/backend/catalog/pg_constraint.c
src/backend/catalog/pg_conversion.c
src/backend/catalog/pg_db_role_setting.c
src/backend/catalog/pg_depend.c
src/backend/catalog/pg_enum.c
src/backend/catalog/pg_largeobject.c
src/backend/catalog/pg_range.c
src/backend/catalog/pg_shdepend.c
src/backend/commands/amcmds.c
src/backend/commands/comment.c
src/backend/commands/dbcommands.c
src/backend/commands/event_trigger.c
src/backend/commands/extension.c
src/backend/commands/foreigncmds.c
src/backend/commands/functioncmds.c
src/backend/commands/opclasscmds.c
src/backend/commands/operatorcmds.c
src/backend/commands/policy.c
src/backend/commands/proclang.c
src/backend/commands/publicationcmds.c
src/backend/commands/schemacmds.c
src/backend/commands/seclabel.c
src/backend/commands/sequence.c
src/backend/commands/subscriptioncmds.c
src/backend/commands/tablecmds.c
src/backend/commands/tablespace.c
src/backend/commands/trigger.c
src/backend/commands/tsearchcmds.c
src/backend/commands/typecmds.c
src/backend/commands/user.c
src/backend/replication/logical/origin.c
src/backend/rewrite/rewriteRemove.c
src/backend/storage/large_object/inv_api.c
src/include/catalog/indexing.h

index e73226dc8135afe921763e6065a7042ea7ac6626..79b7fd5370b187460bec02ef5e4cca0562f33639 100644 (file)
@@ -1470,7 +1470,7 @@ RemoveDefaultACLById(Oid defaclOid)
        if (!HeapTupleIsValid(tuple))
                elog(ERROR, "could not find tuple for default ACL %u", defaclOid);
 
-       simple_heap_delete(rel, &tuple->t_self);
+       CatalogTupleDelete(rel, &tuple->t_self);
 
        systable_endscan(scan);
        heap_close(rel, RowExclusiveLock);
@@ -5718,8 +5718,10 @@ recordExtensionInitPrivWorker(Oid objoid, Oid classoid, int objsubid, Acl *new_a
                        CatalogTupleUpdate(relation, &oldtuple->t_self, oldtuple);
                }
                else
+               {
                        /* new_acl is NULL, so delete the entry we found. */
-                       simple_heap_delete(relation, &oldtuple->t_self);
+                       CatalogTupleDelete(relation, &oldtuple->t_self);
+               }
        }
        else
        {
index 1c43af6effb91aba6a64e3c5ad2f8af91b3bdf82..fc088b216589ccbb70f3201a128d59e8345b913c 100644 (file)
@@ -1062,7 +1062,7 @@ deleteOneObject(const ObjectAddress *object, Relation *depRel, int flags)
 
        while (HeapTupleIsValid(tup = systable_getnext(scan)))
        {
-               simple_heap_delete(*depRel, &tup->t_self);
+               CatalogTupleDelete(*depRel, &tup->t_self);
        }
 
        systable_endscan(scan);
@@ -2467,7 +2467,7 @@ DeleteInitPrivs(const ObjectAddress *object)
                                                          NULL, 3, key);
 
        while (HeapTupleIsValid(oldtuple = systable_getnext(scan)))
-               simple_heap_delete(relation, &oldtuple->t_self);
+               CatalogTupleDelete(relation, &oldtuple->t_self);
 
        systable_endscan(scan);
 
index cb6b6eb46cddc1b1cc06c91f97aeaab8b8afdbec..a674401e464b3e66733815709f1ae2d823815646 100644 (file)
@@ -1417,7 +1417,7 @@ RelationRemoveInheritance(Oid relid)
                                                          NULL, 1, &key);
 
        while (HeapTupleIsValid(tuple = systable_getnext(scan)))
-               simple_heap_delete(catalogRelation, &tuple->t_self);
+               CatalogTupleDelete(catalogRelation, &tuple->t_self);
 
        systable_endscan(scan);
        heap_close(catalogRelation, RowExclusiveLock);
@@ -1445,7 +1445,7 @@ DeleteRelationTuple(Oid relid)
                elog(ERROR, "cache lookup failed for relation %u", relid);
 
        /* delete the relation tuple from pg_class, and finish up */
-       simple_heap_delete(pg_class_desc, &tup->t_self);
+       CatalogTupleDelete(pg_class_desc, &tup->t_self);
 
        ReleaseSysCache(tup);
 
@@ -1482,7 +1482,7 @@ DeleteAttributeTuples(Oid relid)
 
        /* Delete all the matching tuples */
        while ((atttup = systable_getnext(scan)) != NULL)
-               simple_heap_delete(attrel, &atttup->t_self);
+               CatalogTupleDelete(attrel, &atttup->t_self);
 
        /* Clean up after the scan */
        systable_endscan(scan);
@@ -1523,7 +1523,7 @@ DeleteSystemAttributeTuples(Oid relid)
 
        /* Delete all the matching tuples */
        while ((atttup = systable_getnext(scan)) != NULL)
-               simple_heap_delete(attrel, &atttup->t_self);
+               CatalogTupleDelete(attrel, &atttup->t_self);
 
        /* Clean up after the scan */
        systable_endscan(scan);
@@ -1570,7 +1570,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum)
        {
                /* System attribute (probably OID) ... just delete the row */
 
-               simple_heap_delete(attr_rel, &tuple->t_self);
+               CatalogTupleDelete(attr_rel, &tuple->t_self);
        }
        else
        {
@@ -1715,7 +1715,7 @@ RemoveAttrDefaultById(Oid attrdefId)
        myrel = relation_open(myrelid, AccessExclusiveLock);
 
        /* Now we can delete the pg_attrdef row */
-       simple_heap_delete(attrdef_rel, &tuple->t_self);
+       CatalogTupleDelete(attrdef_rel, &tuple->t_self);
 
        systable_endscan(scan);
        heap_close(attrdef_rel, RowExclusiveLock);
@@ -1809,7 +1809,7 @@ heap_drop_with_catalog(Oid relid)
                if (!HeapTupleIsValid(tuple))
                        elog(ERROR, "cache lookup failed for foreign table %u", relid);
 
-               simple_heap_delete(rel, &tuple->t_self);
+               CatalogTupleDelete(rel, &tuple->t_self);
 
                ReleaseSysCache(tuple);
                heap_close(rel, RowExclusiveLock);
@@ -2764,7 +2764,7 @@ RemoveStatistics(Oid relid, AttrNumber attnum)
 
        /* we must loop even when attnum != 0, in case of inherited stats */
        while (HeapTupleIsValid(tuple = systable_getnext(scan)))
-               simple_heap_delete(pgstatistic, &tuple->t_self);
+               CatalogTupleDelete(pgstatistic, &tuple->t_self);
 
        systable_endscan(scan);
 
@@ -3196,7 +3196,7 @@ RemovePartitionKeyByRelId(Oid relid)
                elog(ERROR, "cache lookup failed for partition key of relation %u",
                         relid);
 
-       simple_heap_delete(rel, &tuple->t_self);
+       CatalogTupleDelete(rel, &tuple->t_self);
 
        ReleaseSysCache(tuple);
        heap_close(rel, RowExclusiveLock);
index 618e170b6bf7d09389156b7abf1d8d0f03070b07..815a694cfcd9b22a8ce154a46ce23ad59fffb418 100644 (file)
@@ -1573,7 +1573,7 @@ index_drop(Oid indexId, bool concurrent)
 
        hasexprs = !heap_attisnull(tuple, Anum_pg_index_indexprs);
 
-       simple_heap_delete(indexRelation, &tuple->t_self);
+       CatalogTupleDelete(indexRelation, &tuple->t_self);
 
        ReleaseSysCache(tuple);
        heap_close(indexRelation, RowExclusiveLock);
index c26765ab00ee1a89bcef0768da0cd611700fc416..02f64813ec54cb2fd3460c8ee8e6d8faaf2c3ed0 100644 (file)
@@ -192,3 +192,19 @@ CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
        CatalogIndexInsert(indstate, tup);
        CatalogCloseIndexes(indstate);
 }
+
+/*
+ * CatalogTupleDelete - do heap and indexing work for deleting a catalog tuple
+ *
+ * Delete the tuple identified by tid in the specified catalog.
+ *
+ * With Postgres heaps, there is no index work to do at deletion time;
+ * cleanup will be done later by VACUUM.  However, callers of this function
+ * shouldn't have to know that; we'd like a uniform abstraction for all
+ * catalog tuple changes.  Hence, provide this currently-trivial wrapper.
+ */
+void
+CatalogTupleDelete(Relation heapRel, ItemPointer tid)
+{
+       simple_heap_delete(heapRel, tid);
+}
index 686d392123a4dd5a34cebc6d921a60d6212a22b5..65b6051c0d197cdca5323fa5017a7439c99322d9 100644 (file)
@@ -191,7 +191,7 @@ RemoveCollationById(Oid collationOid)
        tuple = systable_getnext(scandesc);
 
        if (HeapTupleIsValid(tuple))
-               simple_heap_delete(rel, &tuple->t_self);
+               CatalogTupleDelete(rel, &tuple->t_self);
        else
                elog(ERROR, "could not find tuple for collation %u", collationOid);
 
index cf43f7e29b0006f972f02cdcc727fca6f88b846d..62be80d800e6264526f64ab08c828c760abce074 100644 (file)
@@ -604,7 +604,7 @@ RemoveConstraintById(Oid conId)
                elog(ERROR, "constraint %u is not of a known type", conId);
 
        /* Fry the constraint itself */
-       simple_heap_delete(conDesc, &tup->t_self);
+       CatalogTupleDelete(conDesc, &tup->t_self);
 
        /* Clean up */
        ReleaseSysCache(tup);
index d1e2b93086c216db54942406d1da8cff27c6554d..5746dc349af4c4848a4faff39d3c86e9991b5a72 100644 (file)
@@ -165,7 +165,7 @@ RemoveConversionById(Oid conversionOid)
 
        /* search for the target tuple */
        if (HeapTupleIsValid(tuple = heap_getnext(scan, ForwardScanDirection)))
-               simple_heap_delete(rel, &tuple->t_self);
+               CatalogTupleDelete(rel, &tuple->t_self);
        else
                elog(ERROR, "could not find tuple for conversion %u", conversionOid);
        heap_endscan(scan);
index 3dfe9ac5a7dd695222f0049c47834351c9986f8e..323471bc83a47e71b4c2c246dd4ab26a886d71ca 100644 (file)
@@ -91,7 +91,7 @@ AlterSetting(Oid databaseid, Oid roleid, VariableSetStmt *setstmt)
                                CatalogTupleUpdate(rel, &tuple->t_self, newtuple);
                        }
                        else
-                               simple_heap_delete(rel, &tuple->t_self);
+                               CatalogTupleDelete(rel, &tuple->t_self);
                }
        }
        else if (HeapTupleIsValid(tuple))
@@ -129,7 +129,7 @@ AlterSetting(Oid databaseid, Oid roleid, VariableSetStmt *setstmt)
                        CatalogTupleUpdate(rel, &tuple->t_self, newtuple);
                }
                else
-                       simple_heap_delete(rel, &tuple->t_self);
+                       CatalogTupleDelete(rel, &tuple->t_self);
        }
        else if (valuestr)
        {
@@ -199,7 +199,7 @@ DropSetting(Oid databaseid, Oid roleid)
        scan = heap_beginscan_catalog(relsetting, numkeys, keys);
        while (HeapTupleIsValid(tup = heap_getnext(scan, ForwardScanDirection)))
        {
-               simple_heap_delete(relsetting, &tup->t_self);
+               CatalogTupleDelete(relsetting, &tup->t_self);
        }
        heap_endscan(scan);
 
index e114a9cdfefc2f867113f4320d4cdec77cb75706..722df67bda038f64d68ecbb7299c2eccefe7e557 100644 (file)
@@ -219,7 +219,7 @@ deleteDependencyRecordsFor(Oid classId, Oid objectId,
                  ((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION)
                        continue;
 
-               simple_heap_delete(depRel, &tup->t_self);
+               CatalogTupleDelete(depRel, &tup->t_self);
                count++;
        }
 
@@ -269,7 +269,7 @@ deleteDependencyRecordsForClass(Oid classId, Oid objectId,
 
                if (depform->refclassid == refclassId && depform->deptype == deptype)
                {
-                       simple_heap_delete(depRel, &tup->t_self);
+                       CatalogTupleDelete(depRel, &tup->t_self);
                        count++;
                }
        }
@@ -353,7 +353,7 @@ changeDependencyFor(Oid classId, Oid objectId,
                        depform->refobjid == oldRefObjectId)
                {
                        if (newIsPinned)
-                               simple_heap_delete(depRel, &tup->t_self);
+                               CatalogTupleDelete(depRel, &tup->t_self);
                        else
                        {
                                /* make a modifiable copy */
index 1fc6f7c6b4e302e1d3dbabb68ef006faa50c9c9e..a7d933663ee47b5d5cfbb8c9db9c3d1d844e5cbc 100644 (file)
@@ -161,7 +161,7 @@ EnumValuesDelete(Oid enumTypeOid)
 
        while (HeapTupleIsValid(tup = systable_getnext(scan)))
        {
-               simple_heap_delete(pg_enum, &tup->t_self);
+               CatalogTupleDelete(pg_enum, &tup->t_self);
        }
 
        systable_endscan(scan);
index 754ad9f79c293b7f3bbd19d1f2e19dc149e10cdc..fc4f4f8c9baf500e6352774c8fb10eb5f81d8f10 100644 (file)
@@ -110,7 +110,7 @@ LargeObjectDrop(Oid loid)
                                (errcode(ERRCODE_UNDEFINED_OBJECT),
                                 errmsg("large object %u does not exist", loid)));
 
-       simple_heap_delete(pg_lo_meta, &tuple->t_self);
+       CatalogTupleDelete(pg_lo_meta, &tuple->t_self);
 
        systable_endscan(scan);
 
@@ -127,7 +127,7 @@ LargeObjectDrop(Oid loid)
                                                          NULL, 1, skey);
        while (HeapTupleIsValid(tuple = systable_getnext(scan)))
        {
-               simple_heap_delete(pg_largeobject, &tuple->t_self);
+               CatalogTupleDelete(pg_largeobject, &tuple->t_self);
        }
 
        systable_endscan(scan);
index fcbf374bd67e6ea7eb30896747b41f3b9c8991a4..a3b0fb88384de1e8f830b89ebf61aa2c1aaa1e49 100644 (file)
@@ -129,7 +129,7 @@ RangeDelete(Oid rangeTypeOid)
 
        while (HeapTupleIsValid(tup = systable_getnext(scan)))
        {
-               simple_heap_delete(pg_range, &tup->t_self);
+               CatalogTupleDelete(pg_range, &tup->t_self);
        }
 
        systable_endscan(scan);
index 4b68e05e519107b8a4b22335c021212466fa63d8..ef50b854d4d9d00081abfef2d7e2cb1e6d9f7d03 100644 (file)
@@ -249,7 +249,7 @@ shdepChangeDep(Relation sdepRel,
        {
                /* No new entry needed, so just delete existing entry if any */
                if (oldtup)
-                       simple_heap_delete(sdepRel, &oldtup->t_self);
+                       CatalogTupleDelete(sdepRel, &oldtup->t_self);
        }
        else if (oldtup)
        {
@@ -795,7 +795,7 @@ dropDatabaseDependencies(Oid databaseId)
 
        while (HeapTupleIsValid(tup = systable_getnext(scan)))
        {
-               simple_heap_delete(sdepRel, &tup->t_self);
+               CatalogTupleDelete(sdepRel, &tup->t_self);
        }
 
        systable_endscan(scan);
@@ -948,7 +948,7 @@ shdepDropDependency(Relation sdepRel,
                        continue;
 
                /* OK, delete it */
-               simple_heap_delete(sdepRel, &tup->t_self);
+               CatalogTupleDelete(sdepRel, &tup->t_self);
        }
 
        systable_endscan(scan);
index b6e60469f397714ab595bc5ff357470c3bffd163..225e6f636cadf6f1f5f030059e948a2ae125904d 100644 (file)
@@ -128,7 +128,7 @@ RemoveAccessMethodById(Oid amOid)
        if (!HeapTupleIsValid(tup))
                elog(ERROR, "cache lookup failed for access method %u", amOid);
 
-       simple_heap_delete(relation, &tup->t_self);
+       CatalogTupleDelete(relation, &tup->t_self);
 
        ReleaseSysCache(tup);
 
index 8a437de81549659b09ef95eafbd2a591f432c8c5..87ca62f24032bc8b4b9a7c425b4028f52b941830 100644 (file)
@@ -194,7 +194,7 @@ CreateComments(Oid oid, Oid classoid, int32 subid, char *comment)
                /* Found the old tuple, so delete or update it */
 
                if (comment == NULL)
-                       simple_heap_delete(description, &oldtuple->t_self);
+                       CatalogTupleDelete(description, &oldtuple->t_self);
                else
                {
                        newtuple = heap_modify_tuple(oldtuple, RelationGetDescr(description), values,
@@ -284,7 +284,7 @@ CreateSharedComments(Oid oid, Oid classoid, char *comment)
                /* Found the old tuple, so delete or update it */
 
                if (comment == NULL)
-                       simple_heap_delete(shdescription, &oldtuple->t_self);
+                       CatalogTupleDelete(shdescription, &oldtuple->t_self);
                else
                {
                        newtuple = heap_modify_tuple(oldtuple, RelationGetDescr(shdescription),
@@ -358,7 +358,7 @@ DeleteComments(Oid oid, Oid classoid, int32 subid)
                                                        NULL, nkeys, skey);
 
        while ((oldtuple = systable_getnext(sd)) != NULL)
-               simple_heap_delete(description, &oldtuple->t_self);
+               CatalogTupleDelete(description, &oldtuple->t_self);
 
        /* Done */
 
@@ -394,7 +394,7 @@ DeleteSharedComments(Oid oid, Oid classoid)
                                                        NULL, 2, skey);
 
        while ((oldtuple = systable_getnext(sd)) != NULL)
-               simple_heap_delete(shdescription, &oldtuple->t_self);
+               CatalogTupleDelete(shdescription, &oldtuple->t_self);
 
        /* Done */
 
index c3eb3c79df49cd43b616c461e570960672615eef..30000a1eeb8fe130b6a0b965fbea00567bb248a5 100644 (file)
@@ -895,7 +895,7 @@ dropdb(const char *dbname, bool missing_ok)
        if (!HeapTupleIsValid(tup))
                elog(ERROR, "cache lookup failed for database %u", db_id);
 
-       simple_heap_delete(pgdbrel, &tup->t_self);
+       CatalogTupleDelete(pgdbrel, &tup->t_self);
 
        ReleaseSysCache(tup);
 
index 94c4ea5dd21312d07e34d438ed2e85a28fa935ec..346b347ae17654e9c4e5155f5d1a2e6a294d9a7e 100644 (file)
@@ -484,7 +484,7 @@ RemoveEventTriggerById(Oid trigOid)
        if (!HeapTupleIsValid(tup))
                elog(ERROR, "cache lookup failed for event trigger %u", trigOid);
 
-       simple_heap_delete(tgrel, &tup->t_self);
+       CatalogTupleDelete(tgrel, &tup->t_self);
 
        ReleaseSysCache(tup);
 
index 14738ea584c92e6a005e63c6a657dd1fbb076f34..325f5b74b81a65c5b6f8cb06dbb28b5102c53350 100644 (file)
@@ -1854,7 +1854,7 @@ RemoveExtensionById(Oid extId)
 
        /* We assume that there can be at most one matching tuple */
        if (HeapTupleIsValid(tuple))
-               simple_heap_delete(rel, &tuple->t_self);
+               CatalogTupleDelete(rel, &tuple->t_self);
 
        systable_endscan(scandesc);
 
index ad8ca2d8eba402509bf30a0c0a2987038d6cb05a..d5d40e623922f6413ce09d5c23ed3ac655b73545 100644 (file)
@@ -846,7 +846,7 @@ RemoveForeignDataWrapperById(Oid fdwId)
        if (!HeapTupleIsValid(tp))
                elog(ERROR, "cache lookup failed for foreign-data wrapper %u", fdwId);
 
-       simple_heap_delete(rel, &tp->t_self);
+       CatalogTupleDelete(rel, &tp->t_self);
 
        ReleaseSysCache(tp);
 
@@ -1080,7 +1080,7 @@ RemoveForeignServerById(Oid srvId)
        if (!HeapTupleIsValid(tp))
                elog(ERROR, "cache lookup failed for foreign server %u", srvId);
 
-       simple_heap_delete(rel, &tp->t_self);
+       CatalogTupleDelete(rel, &tp->t_self);
 
        ReleaseSysCache(tp);
 
@@ -1403,7 +1403,7 @@ RemoveUserMappingById(Oid umId)
        if (!HeapTupleIsValid(tp))
                elog(ERROR, "cache lookup failed for user mapping %u", umId);
 
-       simple_heap_delete(rel, &tp->t_self);
+       CatalogTupleDelete(rel, &tp->t_self);
 
        ReleaseSysCache(tp);
 
index f4fa8d35a4e808aeab2e0d2ae06760db1e15bf64..dd83858b3ddb82d84c699546706f4778bc57a751 100644 (file)
@@ -1131,7 +1131,7 @@ RemoveFunctionById(Oid funcOid)
 
        isagg = ((Form_pg_proc) GETSTRUCT(tup))->proisagg;
 
-       simple_heap_delete(relation, &tup->t_self);
+       CatalogTupleDelete(relation, &tup->t_self);
 
        ReleaseSysCache(tup);
 
@@ -1148,7 +1148,7 @@ RemoveFunctionById(Oid funcOid)
                if (!HeapTupleIsValid(tup))             /* should not happen */
                        elog(ERROR, "cache lookup failed for pg_aggregate tuple for function %u", funcOid);
 
-               simple_heap_delete(relation, &tup->t_self);
+               CatalogTupleDelete(relation, &tup->t_self);
 
                ReleaseSysCache(tup);
 
@@ -1735,7 +1735,7 @@ DropCastById(Oid castOid)
        tuple = systable_getnext(scan);
        if (!HeapTupleIsValid(tuple))
                elog(ERROR, "could not find tuple for cast %u", castOid);
-       simple_heap_delete(relation, &tuple->t_self);
+       CatalogTupleDelete(relation, &tuple->t_self);
 
        systable_endscan(scan);
        heap_close(relation, RowExclusiveLock);
@@ -2021,7 +2021,7 @@ DropTransformById(Oid transformOid)
        tuple = systable_getnext(scan);
        if (!HeapTupleIsValid(tuple))
                elog(ERROR, "could not find tuple for transform %u", transformOid);
-       simple_heap_delete(relation, &tuple->t_self);
+       CatalogTupleDelete(relation, &tuple->t_self);
 
        systable_endscan(scan);
        heap_close(relation, RowExclusiveLock);
index 99a39bdd74248b57022a8bcb22ec5e23e8050cf7..5f2364bccf61077457c71cbf36d4f1f02b441164 100644 (file)
@@ -1571,7 +1571,7 @@ RemoveOpFamilyById(Oid opfamilyOid)
        if (!HeapTupleIsValid(tup)) /* should not happen */
                elog(ERROR, "cache lookup failed for opfamily %u", opfamilyOid);
 
-       simple_heap_delete(rel, &tup->t_self);
+       CatalogTupleDelete(rel, &tup->t_self);
 
        ReleaseSysCache(tup);
 
@@ -1590,7 +1590,7 @@ RemoveOpClassById(Oid opclassOid)
        if (!HeapTupleIsValid(tup)) /* should not happen */
                elog(ERROR, "cache lookup failed for opclass %u", opclassOid);
 
-       simple_heap_delete(rel, &tup->t_self);
+       CatalogTupleDelete(rel, &tup->t_self);
 
        ReleaseSysCache(tup);
 
@@ -1620,7 +1620,7 @@ RemoveAmOpEntryById(Oid entryOid)
        if (!HeapTupleIsValid(tup))
                elog(ERROR, "could not find tuple for amop entry %u", entryOid);
 
-       simple_heap_delete(rel, &tup->t_self);
+       CatalogTupleDelete(rel, &tup->t_self);
 
        systable_endscan(scan);
        heap_close(rel, RowExclusiveLock);
@@ -1649,7 +1649,7 @@ RemoveAmProcEntryById(Oid entryOid)
        if (!HeapTupleIsValid(tup))
                elog(ERROR, "could not find tuple for amproc entry %u", entryOid);
 
-       simple_heap_delete(rel, &tup->t_self);
+       CatalogTupleDelete(rel, &tup->t_self);
 
        systable_endscan(scan);
        heap_close(rel, RowExclusiveLock);
index 66d2452dbe28e7db086842910b291cb09557b80c..b063467bbde6c2e544ad286ec9a320a93b91359d 100644 (file)
@@ -368,7 +368,7 @@ RemoveOperatorById(Oid operOid)
                }
        }
 
-       simple_heap_delete(relation, &tup->t_self);
+       CatalogTupleDelete(relation, &tup->t_self);
 
        ReleaseSysCache(tup);
 
index da2b1ae0e7e08fe5bd736406b88459b3b9cca003..4a758426c39ebe20ca40f9adec9996e119d15626 100644 (file)
@@ -397,7 +397,7 @@ RemovePolicyById(Oid policy_id)
                                 errmsg("permission denied: \"%s\" is a system catalog",
                                                RelationGetRelationName(rel))));
 
-       simple_heap_delete(pg_policy_rel, &tuple->t_self);
+       CatalogTupleDelete(pg_policy_rel, &tuple->t_self);
 
        systable_endscan(sscan);
 
index 4c8daa5928926f0ef0e3700aa0eead1d2dc61233..a4fbc05a12278cd443f92d74b3132cdaa31a70be 100644 (file)
@@ -536,7 +536,7 @@ DropProceduralLanguageById(Oid langOid)
        if (!HeapTupleIsValid(langTup))         /* should not happen */
                elog(ERROR, "cache lookup failed for language %u", langOid);
 
-       simple_heap_delete(rel, &langTup->t_self);
+       CatalogTupleDelete(rel, &langTup->t_self);
 
        ReleaseSysCache(langTup);
 
index bc0f65399144ef50e74133a82b2b1e22bd9a6a3f..3fe1d15052d8ae2ddcc1f402127d5feb59f99f18 100644 (file)
@@ -461,7 +461,7 @@ RemovePublicationById(Oid pubid)
        if (!HeapTupleIsValid(tup))
                elog(ERROR, "cache lookup failed for publication %u", pubid);
 
-       simple_heap_delete(rel, &tup->t_self);
+       CatalogTupleDelete(rel, &tup->t_self);
 
        ReleaseSysCache(tup);
 
@@ -486,13 +486,12 @@ RemovePublicationRelById(Oid proid)
                elog(ERROR, "cache lookup failed for publication table %u",
                         proid);
 
-
        pubrel = (Form_pg_publication_rel) GETSTRUCT(tup);
 
        /* Invalidate relcache so that publication info is rebuilt. */
        CacheInvalidateRelcacheByRelid(pubrel->prrelid);
 
-       simple_heap_delete(rel, &tup->t_self);
+       CatalogTupleDelete(rel, &tup->t_self);
 
        ReleaseSysCache(tup);
 
index d14c2698036682c8ef775d2b2e1f7eb50a6b1e4c..722b965d65db6a739fe8aafa3d630230ff6a3524 100644 (file)
@@ -226,7 +226,7 @@ RemoveSchemaById(Oid schemaOid)
        if (!HeapTupleIsValid(tup)) /* should not happen */
                elog(ERROR, "cache lookup failed for namespace %u", schemaOid);
 
-       simple_heap_delete(relation, &tup->t_self);
+       CatalogTupleDelete(relation, &tup->t_self);
 
        ReleaseSysCache(tup);
 
index 506c90f6e25df0de9928140b15ebad24689b6ea9..422da8b6b06d3f716b3a90a8a42039099c67e3f4 100644 (file)
@@ -293,7 +293,7 @@ SetSharedSecurityLabel(const ObjectAddress *object,
        if (HeapTupleIsValid(oldtup))
        {
                if (label == NULL)
-                       simple_heap_delete(pg_shseclabel, &oldtup->t_self);
+                       CatalogTupleDelete(pg_shseclabel, &oldtup->t_self);
                else
                {
                        replaces[Anum_pg_shseclabel_label - 1] = true;
@@ -380,7 +380,7 @@ SetSecurityLabel(const ObjectAddress *object,
        if (HeapTupleIsValid(oldtup))
        {
                if (label == NULL)
-                       simple_heap_delete(pg_seclabel, &oldtup->t_self);
+                       CatalogTupleDelete(pg_seclabel, &oldtup->t_self);
                else
                {
                        replaces[Anum_pg_seclabel_label - 1] = true;
@@ -432,7 +432,7 @@ DeleteSharedSecurityLabel(Oid objectId, Oid classId)
        scan = systable_beginscan(pg_shseclabel, SharedSecLabelObjectIndexId, true,
                                                          NULL, 2, skey);
        while (HeapTupleIsValid(oldtup = systable_getnext(scan)))
-               simple_heap_delete(pg_shseclabel, &oldtup->t_self);
+               CatalogTupleDelete(pg_shseclabel, &oldtup->t_self);
        systable_endscan(scan);
 
        heap_close(pg_shseclabel, RowExclusiveLock);
@@ -483,7 +483,7 @@ DeleteSecurityLabel(const ObjectAddress *object)
        scan = systable_beginscan(pg_seclabel, SecLabelObjectIndexId, true,
                                                          NULL, nkeys, skey);
        while (HeapTupleIsValid(oldtup = systable_getnext(scan)))
-               simple_heap_delete(pg_seclabel, &oldtup->t_self);
+               CatalogTupleDelete(pg_seclabel, &oldtup->t_self);
        systable_endscan(scan);
 
        heap_close(pg_seclabel, RowExclusiveLock);
index 6ac76b1e565618d9fbad2d8c19021a388723e9ae..c148b09cd725ba56987e767663a7e6575b164ba0 100644 (file)
@@ -521,7 +521,7 @@ DeleteSequenceTuple(Oid relid)
        if (!HeapTupleIsValid(tuple))
                elog(ERROR, "cache lookup failed for sequence %u", relid);
 
-       simple_heap_delete(rel, &tuple->t_self);
+       CatalogTupleDelete(rel, &tuple->t_self);
 
        ReleaseSysCache(tuple);
        heap_close(rel, RowExclusiveLock);
index 5de999928f338516db97fc0dd87a4ec299699b5f..3b7080756537687a26e6677f51fb9d0e23e4ab11 100644 (file)
@@ -501,7 +501,7 @@ DropSubscription(DropSubscriptionStmt *stmt)
        EventTriggerSQLDropAddObject(&myself, true, true);
 
        /* Remove the tuple from catalog. */
-       simple_heap_delete(rel, &tup->t_self);
+       CatalogTupleDelete(rel, &tup->t_self);
 
        ReleaseSysCache(tup);
 
index 764071bd11b45f969b490aa52deddd19e335479e..878b48d39ef0b6fa0b91840dbe5e53ef1aa6b367 100644 (file)
@@ -8939,7 +8939,7 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel,
                          foundDep->refobjid == attTup->attcollation))
                        elog(ERROR, "found unexpected dependency for column");
 
-               simple_heap_delete(depRel, &depTup->t_self);
+               CatalogTupleDelete(depRel, &depTup->t_self);
        }
 
        systable_endscan(scan);
@@ -11177,7 +11177,7 @@ RemoveInheritance(Relation child_rel, Relation parent_rel)
                inhparent = ((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhparent;
                if (inhparent == RelationGetRelid(parent_rel))
                {
-                       simple_heap_delete(catalogRelation, &inheritsTuple->t_self);
+                       CatalogTupleDelete(catalogRelation, &inheritsTuple->t_self);
                        found = true;
                        break;
                }
@@ -11370,7 +11370,7 @@ drop_parent_dependency(Oid relid, Oid refclassid, Oid refobjid)
                        dep->refobjid == refobjid &&
                        dep->refobjsubid == 0 &&
                        dep->deptype == DEPENDENCY_NORMAL)
-                       simple_heap_delete(catalogRelation, &depTuple->t_self);
+                       CatalogTupleDelete(catalogRelation, &depTuple->t_self);
        }
 
        systable_endscan(scan);
index 6e652aa66bdc4890ac4dcfe0ffd4ab3e67ef6376..80515bae19c35b7436fe9c5608d205a174c5da88 100644 (file)
@@ -460,7 +460,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
        /*
         * Remove the pg_tablespace tuple (this will roll back if we fail below)
         */
-       simple_heap_delete(rel, &tuple->t_self);
+       CatalogTupleDelete(rel, &tuple->t_self);
 
        heap_endscan(scandesc);
 
index b3e89a44f72f6fffcf46b52a7d149503ee6451f3..d80bff671c0996f9e07d38f888530104fa3ea21f 100644 (file)
@@ -1238,7 +1238,7 @@ RemoveTriggerById(Oid trigOid)
        /*
         * Delete the pg_trigger tuple.
         */
-       simple_heap_delete(tgrel, &tup->t_self);
+       CatalogTupleDelete(tgrel, &tup->t_self);
 
        systable_endscan(tgscan);
        heap_close(tgrel, RowExclusiveLock);
index 988930b1c553e92bcddcfb992dfb1d45000b7fc1..49668be0d70aa6b8410354d1d1a1e5535bfbc72e 100644 (file)
@@ -301,7 +301,7 @@ RemoveTSParserById(Oid prsId)
        if (!HeapTupleIsValid(tup))
                elog(ERROR, "cache lookup failed for text search parser %u", prsId);
 
-       simple_heap_delete(relation, &tup->t_self);
+       CatalogTupleDelete(relation, &tup->t_self);
 
        ReleaseSysCache(tup);
 
@@ -511,7 +511,7 @@ RemoveTSDictionaryById(Oid dictId)
                elog(ERROR, "cache lookup failed for text search dictionary %u",
                         dictId);
 
-       simple_heap_delete(relation, &tup->t_self);
+       CatalogTupleDelete(relation, &tup->t_self);
 
        ReleaseSysCache(tup);
 
@@ -831,7 +831,7 @@ RemoveTSTemplateById(Oid tmplId)
                elog(ERROR, "cache lookup failed for text search template %u",
                         tmplId);
 
-       simple_heap_delete(relation, &tup->t_self);
+       CatalogTupleDelete(relation, &tup->t_self);
 
        ReleaseSysCache(tup);
 
@@ -1139,7 +1139,7 @@ RemoveTSConfigurationById(Oid cfgId)
                elog(ERROR, "cache lookup failed for text search dictionary %u",
                         cfgId);
 
-       simple_heap_delete(relCfg, &tup->t_self);
+       CatalogTupleDelete(relCfg, &tup->t_self);
 
        ReleaseSysCache(tup);
 
@@ -1158,7 +1158,7 @@ RemoveTSConfigurationById(Oid cfgId)
 
        while (HeapTupleIsValid((tup = systable_getnext(scan))))
        {
-               simple_heap_delete(relMap, &tup->t_self);
+               CatalogTupleDelete(relMap, &tup->t_self);
        }
 
        systable_endscan(scan);
@@ -1317,7 +1317,7 @@ MakeConfigurationMapping(AlterTSConfigurationStmt *stmt,
 
                        while (HeapTupleIsValid((maptup = systable_getnext(scan))))
                        {
-                               simple_heap_delete(relMap, &maptup->t_self);
+                               CatalogTupleDelete(relMap, &maptup->t_self);
                        }
 
                        systable_endscan(scan);
@@ -1472,7 +1472,7 @@ DropConfigurationMapping(AlterTSConfigurationStmt *stmt,
 
                while (HeapTupleIsValid((maptup = systable_getnext(scan))))
                {
-                       simple_heap_delete(relMap, &maptup->t_self);
+                       CatalogTupleDelete(relMap, &maptup->t_self);
                        found = true;
                }
 
index b848389ab856826534964ef246646734a179d845..d8bd8a50dd87bf5d655cfe42daacc45f7de988c9 100644 (file)
@@ -697,7 +697,7 @@ RemoveTypeById(Oid typeOid)
        if (!HeapTupleIsValid(tup))
                elog(ERROR, "cache lookup failed for type %u", typeOid);
 
-       simple_heap_delete(relation, &tup->t_self);
+       CatalogTupleDelete(relation, &tup->t_self);
 
        /*
         * If it is an enum, delete the pg_enum entries too; we don't bother with
index f2ec3b2d0d842101d053aa87bdd00569587f4939..994c093250be8b119563be33771acf3d463113fe 100644 (file)
@@ -1044,7 +1044,7 @@ DropRole(DropRoleStmt *stmt)
                /*
                 * Remove the role from the pg_authid table
                 */
-               simple_heap_delete(pg_authid_rel, &tuple->t_self);
+               CatalogTupleDelete(pg_authid_rel, &tuple->t_self);
 
                ReleaseSysCache(tuple);
 
@@ -1064,7 +1064,7 @@ DropRole(DropRoleStmt *stmt)
 
                while (HeapTupleIsValid(tmp_tuple = systable_getnext(sscan)))
                {
-                       simple_heap_delete(pg_auth_members_rel, &tmp_tuple->t_self);
+                       CatalogTupleDelete(pg_auth_members_rel, &tmp_tuple->t_self);
                }
 
                systable_endscan(sscan);
@@ -1079,7 +1079,7 @@ DropRole(DropRoleStmt *stmt)
 
                while (HeapTupleIsValid(tmp_tuple = systable_getnext(sscan)))
                {
-                       simple_heap_delete(pg_auth_members_rel, &tmp_tuple->t_self);
+                       CatalogTupleDelete(pg_auth_members_rel, &tmp_tuple->t_self);
                }
 
                systable_endscan(sscan);
@@ -1606,7 +1606,7 @@ DelRoleMems(const char *rolename, Oid roleid,
                if (!admin_opt)
                {
                        /* Remove the entry altogether */
-                       simple_heap_delete(pg_authmem_rel, &authmem_tuple->t_self);
+                       CatalogTupleDelete(pg_authmem_rel, &authmem_tuple->t_self);
                }
                else
                {
index 7e88f97f086e4f0adbd0fa417637786b9950cc16..ade80d407fea9074d693de85d8f1ad26e281eb60 100644 (file)
@@ -377,7 +377,7 @@ replorigin_drop(RepOriginId roident)
                elog(ERROR, "cache lookup failed for replication origin with oid %u",
                         roident);
 
-       simple_heap_delete(rel, &tuple->t_self);
+       CatalogTupleDelete(rel, &tuple->t_self);
        ReleaseSysCache(tuple);
 
        CommandCounterIncrement();
index 659a311017792878270e0fe9e29f9ab831a43062..e6f5ed575f907f0186458338a781d693f8c2c66f 100644 (file)
@@ -76,7 +76,7 @@ RemoveRewriteRuleById(Oid ruleOid)
        /*
         * Now delete the pg_rewrite tuple for the rule
         */
-       simple_heap_delete(RewriteRelation, &tuple->t_self);
+       CatalogTupleDelete(RewriteRelation, &tuple->t_self);
 
        systable_endscan(rcscan);
 
index 15e1b15483e6591c0e654d33847fd9d7d119b077..8eb5b3b08e36830ac48cfeaedc8c167756b3ba56 100644 (file)
@@ -861,7 +861,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len)
                if (olddata != NULL)
                {
                        Assert(olddata->pageno > pageno);
-                       simple_heap_delete(lo_heap_r, &oldtuple->t_self);
+                       CatalogTupleDelete(lo_heap_r, &oldtuple->t_self);
                }
 
                /*
@@ -897,7 +897,7 @@ inv_truncate(LargeObjectDesc *obj_desc, int64 len)
        {
                while ((oldtuple = systable_getnext_ordered(sd, ForwardScanDirection)) != NULL)
                {
-                       simple_heap_delete(lo_heap_r, &oldtuple->t_self);
+                       CatalogTupleDelete(lo_heap_r, &oldtuple->t_self);
                }
        }
 
index 977dc9c7ca26b9d32ec3bc9b944b07a9e6d67ffc..9d02666ed1bf4c9a624375799ef3105145532ac6 100644 (file)
@@ -35,6 +35,7 @@ extern void CatalogIndexInsert(CatalogIndexState indstate,
 extern Oid CatalogTupleInsert(Relation heapRel, HeapTuple tup);
 extern void CatalogTupleUpdate(Relation heapRel, ItemPointer otid,
                                   HeapTuple tup);
+extern void CatalogTupleDelete(Relation heapRel, ItemPointer tid);
 
 
 /*