30#include "utils/fmgroids.h"
83 LOCKMODE lockmode,
bool *detached_exist,
141 *detached_exist =
true;
166 elog(
WARNING,
"more than one partition pending detach found for table with OID %u",
264 ctl.keysize =
sizeof(
Oid);
476 Oid inhparent = inh->inhparent;
525 memset(nulls, 0,
sizeof(nulls));
570 true,
NULL, 1, &key);
578 if (!
OidIsValid(inhparent) || parent == inhparent)
592 errmsg(
"cannot detach partition \"%s\"",
594 errdetail(
"The partition is being detached concurrently or has an unfinished detach."),
595 errhint(
"Use ALTER TABLE ... DETACH PARTITION ... FINALIZE to complete the pending detach operation.")));
599 errmsg(
"cannot complete detaching partition \"%s\"",
601 errdetail(
"There's no pending concurrent detach.")));
638 true,
NULL, 1, &key);
654 elog(
ERROR,
"relation %u is not a partition", partoid);
static Datum values[MAXATTR]
#define OidIsValid(objectId)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
void hash_destroy(HTAB *hashp)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static TransactionId HeapTupleHeaderGetXmin(const HeapTupleHeaderData *tup)
static void * GETSTRUCT(const HeapTupleData *tuple)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
List * lappend_int(List *list, int datum)
List * lappend_oid(List *list, Oid datum)
void list_free(List *list)
bool list_member_oid(const List *list, Oid datum)
void UnlockRelationOid(Oid relid, LOCKMODE lockmode)
void LockRelationOid(Oid relid, LOCKMODE lockmode)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
MemoryContext CurrentMemoryContext
int oid_cmp(const void *p1, const void *p2)
Oid typeOrDomainTypeRelid(Oid type_id)
Oid typeidTypeRelid(Oid type_id)
FormData_pg_class * Form_pg_class
List * find_all_inheritors(Oid parentrelId, LOCKMODE lockmode, List **numparents)
bool has_subclass(Oid relationId)
bool DeleteInheritsTuple(Oid inhrelid, Oid inhparent, bool expect_detach_pending, const char *childname)
List * find_inheritance_children(Oid parentrelId, LOCKMODE lockmode)
void StoreSingleInheritance(Oid relationId, Oid parentOid, int32 seqNumber)
List * find_inheritance_children_extended(Oid parentrelId, bool omit_detached, LOCKMODE lockmode, bool *detached_exist, TransactionId *detached_xmin)
bool has_superclass(Oid relationId)
bool typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId)
bool PartitionHasPendingDetach(Oid partoid)
FormData_pg_inherits * Form_pg_inherits
static int list_length(const List *l)
#define list_make1_oid(x1)
static ListCell * list_nth_cell(const List *list, int n)
#define list_make1_int(x1)
#define qsort(a, b, c, d)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Datum Int32GetDatum(int32 X)
#define RelationGetDescr(relation)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
bool XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
bool ActiveSnapshotSet(void)
Snapshot GetActiveSnapshot(void)
#define BTEqualStrategyNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define SearchSysCacheExists1(cacheId, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
static bool TransactionIdFollows(TransactionId id1, TransactionId id2)
#define InvalidTransactionId