29 #include "utils/fmgroids.h"
90 max_slots =
Min(nreferenced,
98 slot_stored_count = 0;
101 for (
i = 0;
i < nreferenced;
i++, referenced++)
111 if (slot_init_count < max_slots)
132 memset(slot[slot_stored_count]->tts_isnull,
false,
133 slot[slot_stored_count]->tts_tupleDescriptor->natts *
sizeof(
bool));
139 if (slot_stored_count == max_slots)
142 if (indstate == NULL)
147 slot_stored_count = 0;
152 if (slot_stored_count > 0)
155 if (indstate == NULL)
162 if (indstate != NULL)
168 for (
i = 0;
i < slot_init_count;
i++)
223 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
224 errmsg(
"%s is already a member of extension \"%s\"",
230 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
231 errmsg(
"%s is not a member of extension \"%s\"",
234 errdetail(
"An extension is not allowed to replace an object that it does not own.")));
238 extension.
classId = ExtensionRelationId;
281 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
282 errmsg(
"%s is not a member of extension \"%s\"",
285 errdetail(
"An extension may only use CREATE ... IF NOT EXISTS to skip object creation if the conflicting object is one that it already owns.")));
303 bool skipExtensionDeps)
314 Anum_pg_depend_classid,
318 Anum_pg_depend_objid,
327 if (skipExtensionDeps &&
353 Oid refclassId,
char deptype)
364 Anum_pg_depend_classid,
368 Anum_pg_depend_objid,
379 if (depform->refclassid == refclassId && depform->deptype == deptype)
400 Oid refclassId,
Oid refobjectId)
411 Anum_pg_depend_classid,
415 Anum_pg_depend_objid,
426 if (depform->refclassid == refclassId &&
427 depform->refobjid == refobjectId &&
428 depform->deptype == deptype)
459 Oid refClassId,
Oid oldRefObjectId,
513 Anum_pg_depend_classid,
517 Anum_pg_depend_objid,
528 if (depform->refclassid == refClassId &&
529 depform->refobjid == oldRefObjectId)
539 depform->refobjid = newRefObjectId;
578 Anum_pg_depend_classid,
582 Anum_pg_depend_objid,
597 depform->objid = newObjectId;
647 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
648 errmsg(
"cannot remove dependency on %s because it is a system object",
661 Anum_pg_depend_refclassid,
665 Anum_pg_depend_refobjid,
684 depform->refobjid = newRefObjectId;
744 Anum_pg_depend_classid,
748 Anum_pg_depend_objid,
759 if (depform->refclassid == ExtensionRelationId &&
762 result = depform->refobjid;
790 Anum_pg_depend_classid,
794 Anum_pg_depend_objid,
805 if (depform->refclassid == ExtensionRelationId &&
840 Anum_pg_depend_classid,
844 Anum_pg_depend_objid,
855 if (depform->refclassid == RelationRelationId &&
856 depform->deptype == deptype)
858 *tableId = depform->refobjid;
859 *colId = depform->refobjsubid;
889 Anum_pg_depend_refclassid,
893 Anum_pg_depend_refobjid,
898 Anum_pg_depend_refobjsubid,
914 if (deprec->classid == RelationRelationId &&
915 deprec->objsubid == 0 &&
916 deprec->refobjsubid != 0 &&
920 if (!deptype || deprec->deptype == deptype)
963 elog(
ERROR,
"cache lookup failed for attribute \"%s\" of relation %u",
970 elog(
ERROR,
"more than one owned sequence found");
971 else if (seqlist ==
NIL)
1001 Anum_pg_depend_classid,
1005 Anum_pg_depend_objid,
1009 Anum_pg_depend_objsubid,
1024 if (deprec->refclassid == ConstraintRelationId &&
1025 deprec->refobjsubid == 0 &&
1028 constraintId = deprec->refobjid;
1036 return constraintId;
1057 Anum_pg_depend_refclassid,
1061 Anum_pg_depend_refobjid,
1065 Anum_pg_depend_refobjsubid,
1080 if (deprec->classid == ConstraintRelationId &&
1081 deprec->objsubid == 0 &&
#define InvalidAttrNumber
#define Assert(condition)
#define OidIsValid(objectId)
bool IsPinnedObject(Oid classId, Oid objectId)
@ DEPENDENCY_AUTO_EXTENSION
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
const TupleTableSlotOps TTSOpsHeapTuple
TupleTableSlot * MakeSingleTupleTableSlot(TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
Oid CurrentExtensionObject
char * get_extension_name(Oid ext_oid)
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_copytuple(HeapTuple tuple)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogTuplesMultiInsertWithInfo(Relation heapRel, TupleTableSlot **slot, int ntuples, CatalogIndexState indstate)
void CatalogCloseIndexes(CatalogIndexState indstate)
CatalogIndexState CatalogOpenIndexes(Relation heapRel)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
#define MAX_CATALOG_MULTI_INSERT_BYTES
List * lappend_oid(List *list, Oid datum)
void list_free(List *list)
AttrNumber get_attnum(Oid relid, const char *attname)
char get_rel_relkind(Oid relid)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
void pfree(void *pointer)
#define IsBootstrapProcessingMode()
char * getObjectDescription(const ObjectAddress *object, bool missing_ok)
List * get_partition_ancestors(Oid relid)
static List * getOwnedSequences_internal(Oid relid, AttrNumber attnum, char deptype)
void checkMembershipInCurrentExtension(const ObjectAddress *object)
void recordMultipleDependencies(const ObjectAddress *depender, const ObjectAddress *referenced, int nreferenced, DependencyType behavior)
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long changeDependencyFor(Oid classId, Oid objectId, Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId)
List * getAutoExtensionsOfObject(Oid classId, Oid objectId)
static bool isObjectPinned(const ObjectAddress *object)
long deleteDependencyRecordsForClass(Oid classId, Oid objectId, Oid refclassId, char deptype)
Oid getExtensionOfObject(Oid classId, Oid objectId)
long changeDependenciesOf(Oid classId, Oid oldObjectId, Oid newObjectId)
long deleteDependencyRecordsFor(Oid classId, Oid objectId, bool skipExtensionDeps)
long deleteDependencyRecordsForSpecific(Oid classId, Oid objectId, char deptype, Oid refclassId, Oid refobjectId)
long changeDependenciesOn(Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId)
Oid getIdentitySequence(Relation rel, AttrNumber attnum, bool missing_ok)
Oid get_index_constraint(Oid indexId)
List * get_index_ref_constraints(Oid indexId)
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
List * getOwnedSequences(Oid relid)
bool sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId)
FormData_pg_depend * Form_pg_depend
static int list_length(const List *l)
static Datum ObjectIdGetDatum(Oid X)
static Datum Int32GetDatum(int32 X)
static Datum CharGetDatum(char X)
#define RelationGetForm(relation)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
#define BTEqualStrategyNumber
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)