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

Function getExtensionOfObject

src/backend/catalog/pg_depend.c:764–804  ·  view source on GitHub ↗

* Find the extension containing the specified object, if any * * Returns the OID of the extension, or InvalidOid if the object does not * belong to any extension. * * Extension membership is marked by an EXTENSION dependency from the object * to the extension. Note that the result will be indeterminate if pg_depend * contains links from this object to more than one extension ... but that

Source from the content-addressed store, hash-verified

762 * should never happen.
763 */
764Oid
765getExtensionOfObject(Oid classId, Oid objectId)
766{
767 Oid result = InvalidOid;
768 Relation depRel;
769 ScanKeyData key[2];
770 SysScanDesc scan;
771 HeapTuple tup;
772
773 depRel = table_open(DependRelationId, AccessShareLock);
774
775 ScanKeyInit(&key[0],
776 Anum_pg_depend_classid,
777 BTEqualStrategyNumber, F_OIDEQ,
778 ObjectIdGetDatum(classId));
779 ScanKeyInit(&key[1],
780 Anum_pg_depend_objid,
781 BTEqualStrategyNumber, F_OIDEQ,
782 ObjectIdGetDatum(objectId));
783
784 scan = systable_beginscan(depRel, DependDependerIndexId, true,
785 NULL, 2, key);
786
787 while (HeapTupleIsValid((tup = systable_getnext(scan))))
788 {
789 Form_pg_depend depform = (Form_pg_depend) GETSTRUCT(tup);
790
791 if (depform->refclassid == ExtensionRelationId &&
792 depform->deptype == DEPENDENCY_EXTENSION)
793 {
794 result = depform->refobjid;
795 break; /* no need to keep scanning */
796 }
797 }
798
799 systable_endscan(scan);
800
801 table_close(depRel, AccessShareLock);
802
803 return result;
804}
805
806/*
807 * Return (possibly NIL) list of extensions that the given object depends on

Calls 7

table_openFunction · 0.85
ScanKeyInitFunction · 0.85
ObjectIdGetDatumFunction · 0.85
systable_beginscanFunction · 0.85
systable_getnextFunction · 0.85
systable_endscanFunction · 0.85
table_closeFunction · 0.85

Tested by

no test coverage detected