* 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. */
| 16536 | * metadata only operation to update the tablespace. |
| 16537 | */ |
| 16538 | static void |
| 16539 | ATExecSetTableSpaceNoStorage(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 |
no test coverage detected