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

Function ATExecDetachPartitionFinalize

src/backend/commands/tablecmds.c:22560–22586  ·  view source on GitHub ↗

* ALTER TABLE ... DETACH PARTITION ... FINALIZE * * To use when a DETACH PARTITION command previously did not run to * completion; this completes the detaching process. */

Source from the content-addressed store, hash-verified

22558 * completion; this completes the detaching process.
22559 */
22560static ObjectAddress
22561ATExecDetachPartitionFinalize(Relation rel, RangeVar *name)
22562{
22563 Relation partRel;
22564 ObjectAddress address;
22565 Snapshot snap = GetActiveSnapshot();
22566
22567 partRel = table_openrv(name, AccessExclusiveLock);
22568
22569 /*
22570 * Wait until existing snapshots are gone. This is important if the
22571 * second transaction of DETACH PARTITION CONCURRENTLY is canceled: the
22572 * user could immediately run DETACH FINALIZE without actually waiting for
22573 * existing transactions. We must not complete the detach action until
22574 * all such queries are complete (otherwise we would present them with an
22575 * inconsistent view of catalogs).
22576 */
22577 WaitForOlderSnapshots(snap->xmin, false);
22578
22579 DetachPartitionFinalize(rel, partRel, true, InvalidOid);
22580
22581 ObjectAddressSet(address, RelationRelationId, RelationGetRelid(partRel));
22582
22583 table_close(partRel, NoLock);
22584
22585 return address;
22586}
22587
22588/*
22589 * DetachAddConstraintIfNeeded

Callers 1

ATExecCmdFunction · 0.85

Calls 5

GetActiveSnapshotFunction · 0.85
table_openrvFunction · 0.85
WaitForOlderSnapshotsFunction · 0.85
DetachPartitionFinalizeFunction · 0.85
table_closeFunction · 0.85

Tested by

no test coverage detected