MCPcopy Create free account
hub / github.com/apache/cloudberry / AlterTableNamespaceInternal

Function AlterTableNamespaceInternal

src/backend/commands/tablecmds.c:20218–20251  ·  view source on GitHub ↗

* The guts of relocating a table to another namespace: besides moving * the table itself, its dependent objects are relocated to the new schema. */

Source from the content-addressed store, hash-verified

20216 * the table itself, its dependent objects are relocated to the new schema.
20217 */
20218void
20219AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid,
20220 ObjectAddresses *objsMoved)
20221{
20222 Relation classRel;
20223
20224 Assert(objsMoved != NULL);
20225
20226 /* OK, modify the pg_class row and pg_depend entry */
20227 classRel = table_open(RelationRelationId, RowExclusiveLock);
20228
20229 AlterRelationNamespaceInternal(classRel, RelationGetRelid(rel), oldNspOid,
20230 nspOid, true, objsMoved);
20231
20232 /* Fix the table's row type too, if it has one */
20233 if (OidIsValid(rel->rd_rel->reltype))
20234 AlterTypeNamespaceInternal(rel->rd_rel->reltype,
20235 nspOid, false, false, objsMoved);
20236
20237 /* Fix other dependent stuff */
20238 if (rel->rd_rel->relkind == RELKIND_RELATION ||
20239 rel->rd_rel->relkind == RELKIND_DIRECTORY_TABLE ||
20240 rel->rd_rel->relkind == RELKIND_MATVIEW ||
20241 rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
20242 {
20243 AlterIndexNamespaces(classRel, rel, oldNspOid, nspOid, objsMoved);
20244 AlterSeqNamespaces(classRel, rel, oldNspOid, nspOid,
20245 objsMoved, AccessExclusiveLock);
20246 AlterConstraintNamespaces(RelationGetRelid(rel), oldNspOid, nspOid,
20247 false, objsMoved);
20248 }
20249
20250 table_close(classRel, RowExclusiveLock);
20251}
20252
20253/*
20254 * The guts of relocating a relation to another namespace: fix the pg_class

Callers 2

AlterObjectNamespace_oidFunction · 0.85
AlterTableNamespaceFunction · 0.85

Calls 7

table_openFunction · 0.85
AlterIndexNamespacesFunction · 0.85
AlterSeqNamespacesFunction · 0.85
table_closeFunction · 0.85

Tested by

no test coverage detected