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

Function ATExecSetTableSpaceNoStorage

src/backend/commands/tablecmds.c:16538–16563  ·  view source on GitHub ↗

* Special handling of ALTER TABLE SET TABLESPACE for relations with no * storage that have an interest in preserving tablespace. * * Since these have no storage the tablespace can be updated with a simple * metadata only operation to update the tablespace. */

Source from the content-addressed store, hash-verified

16536 * metadata only operation to update the tablespace.
16537 */
16538static void
16539ATExecSetTableSpaceNoStorage(Relation rel, Oid newTableSpace)
16540{
16541 /*
16542 * Shouldn't be called on relations having storage; these are processed in
16543 * phase 3.
16544 */
16545 Assert(!RELKIND_HAS_STORAGE(rel->rd_rel->relkind));
16546
16547 /* check if relation can be moved to its new tablespace */
16548 if (!CheckRelationTableSpaceMove(rel, newTableSpace))
16549 {
16550 InvokeObjectPostAlterHook(RelationRelationId,
16551 RelationGetRelid(rel),
16552 0);
16553 return;
16554 }
16555
16556 /* Update can be done, so change reltablespace */
16557 SetRelationTableSpace(rel, newTableSpace, InvalidOid);
16558
16559 InvokeObjectPostAlterHook(RelationRelationId, RelationGetRelid(rel), 0);
16560
16561 /* Make sure the reltablespace change is visible */
16562 CommandCounterIncrement();
16563}
16564
16565/*
16566 * Alter Table ALL ... SET TABLESPACE

Callers 1

ATExecCmdFunction · 0.85

Calls 3

SetRelationTableSpaceFunction · 0.85
CommandCounterIncrementFunction · 0.85

Tested by

no test coverage detected