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);
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
{
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- simple_heap_delete(*depRel, &tup->t_self);
+ CatalogTupleDelete(*depRel, &tup->t_self);
}
systable_endscan(scan);
NULL, 3, key);
while (HeapTupleIsValid(oldtuple = systable_getnext(scan)))
- simple_heap_delete(relation, &oldtuple->t_self);
+ CatalogTupleDelete(relation, &oldtuple->t_self);
systable_endscan(scan);
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);
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);
/* 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);
/* 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);
{
/* System attribute (probably OID) ... just delete the row */
- simple_heap_delete(attr_rel, &tuple->t_self);
+ CatalogTupleDelete(attr_rel, &tuple->t_self);
}
else
{
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);
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);
/* 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);
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);
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);
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);
+}
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);
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);
/* 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);
CatalogTupleUpdate(rel, &tuple->t_self, newtuple);
}
else
- simple_heap_delete(rel, &tuple->t_self);
+ CatalogTupleDelete(rel, &tuple->t_self);
}
}
else if (HeapTupleIsValid(tuple))
CatalogTupleUpdate(rel, &tuple->t_self, newtuple);
}
else
- simple_heap_delete(rel, &tuple->t_self);
+ CatalogTupleDelete(rel, &tuple->t_self);
}
else if (valuestr)
{
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);
((Form_pg_depend) GETSTRUCT(tup))->deptype == DEPENDENCY_EXTENSION)
continue;
- simple_heap_delete(depRel, &tup->t_self);
+ CatalogTupleDelete(depRel, &tup->t_self);
count++;
}
if (depform->refclassid == refclassId && depform->deptype == deptype)
{
- simple_heap_delete(depRel, &tup->t_self);
+ CatalogTupleDelete(depRel, &tup->t_self);
count++;
}
}
depform->refobjid == oldRefObjectId)
{
if (newIsPinned)
- simple_heap_delete(depRel, &tup->t_self);
+ CatalogTupleDelete(depRel, &tup->t_self);
else
{
/* make a modifiable copy */
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- simple_heap_delete(pg_enum, &tup->t_self);
+ CatalogTupleDelete(pg_enum, &tup->t_self);
}
systable_endscan(scan);
(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);
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);
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- simple_heap_delete(pg_range, &tup->t_self);
+ CatalogTupleDelete(pg_range, &tup->t_self);
}
systable_endscan(scan);
{
/* 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)
{
while (HeapTupleIsValid(tup = systable_getnext(scan)))
{
- simple_heap_delete(sdepRel, &tup->t_self);
+ CatalogTupleDelete(sdepRel, &tup->t_self);
}
systable_endscan(scan);
continue;
/* OK, delete it */
- simple_heap_delete(sdepRel, &tup->t_self);
+ CatalogTupleDelete(sdepRel, &tup->t_self);
}
systable_endscan(scan);
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);
/* 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,
/* 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),
NULL, nkeys, skey);
while ((oldtuple = systable_getnext(sd)) != NULL)
- simple_heap_delete(description, &oldtuple->t_self);
+ CatalogTupleDelete(description, &oldtuple->t_self);
/* Done */
NULL, 2, skey);
while ((oldtuple = systable_getnext(sd)) != NULL)
- simple_heap_delete(shdescription, &oldtuple->t_self);
+ CatalogTupleDelete(shdescription, &oldtuple->t_self);
/* Done */
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);
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);
/* 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);
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);
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);
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);
isagg = ((Form_pg_proc) GETSTRUCT(tup))->proisagg;
- simple_heap_delete(relation, &tup->t_self);
+ CatalogTupleDelete(relation, &tup->t_self);
ReleaseSysCache(tup);
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);
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);
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);
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);
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);
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);
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);
}
}
- simple_heap_delete(relation, &tup->t_self);
+ CatalogTupleDelete(relation, &tup->t_self);
ReleaseSysCache(tup);
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);
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);
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);
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);
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);
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;
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;
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);
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);
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);
EventTriggerSQLDropAddObject(&myself, true, true);
/* Remove the tuple from catalog. */
- simple_heap_delete(rel, &tup->t_self);
+ CatalogTupleDelete(rel, &tup->t_self);
ReleaseSysCache(tup);
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);
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;
}
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);
/*
* 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);
/*
* Delete the pg_trigger tuple.
*/
- simple_heap_delete(tgrel, &tup->t_self);
+ CatalogTupleDelete(tgrel, &tup->t_self);
systable_endscan(tgscan);
heap_close(tgrel, RowExclusiveLock);
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);
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);
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);
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);
while (HeapTupleIsValid((tup = systable_getnext(scan))))
{
- simple_heap_delete(relMap, &tup->t_self);
+ CatalogTupleDelete(relMap, &tup->t_self);
}
systable_endscan(scan);
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- simple_heap_delete(relMap, &maptup->t_self);
+ CatalogTupleDelete(relMap, &maptup->t_self);
}
systable_endscan(scan);
while (HeapTupleIsValid((maptup = systable_getnext(scan))))
{
- simple_heap_delete(relMap, &maptup->t_self);
+ CatalogTupleDelete(relMap, &maptup->t_self);
found = true;
}
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
/*
* 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);
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);
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);
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
{
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();
/*
* Now delete the pg_rewrite tuple for the rule
*/
- simple_heap_delete(RewriteRelation, &tuple->t_self);
+ CatalogTupleDelete(RewriteRelation, &tuple->t_self);
systable_endscan(rcscan);
if (olddata != NULL)
{
Assert(olddata->pageno > pageno);
- simple_heap_delete(lo_heap_r, &oldtuple->t_self);
+ CatalogTupleDelete(lo_heap_r, &oldtuple->t_self);
}
/*
{
while ((oldtuple = systable_getnext_ordered(sd, ForwardScanDirection)) != NULL)
{
- simple_heap_delete(lo_heap_r, &oldtuple->t_self);
+ CatalogTupleDelete(lo_heap_r, &oldtuple->t_self);
}
}
extern Oid CatalogTupleInsert(Relation heapRel, HeapTuple tup);
extern void CatalogTupleUpdate(Relation heapRel, ItemPointer otid,
HeapTuple tup);
+extern void CatalogTupleDelete(Relation heapRel, ItemPointer tid);
/*