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

Function objectsInSchemaToOids

src/backend/catalog/aclchk.c:908–992  ·  view source on GitHub ↗

* objectsInSchemaToOids * * Find all objects of a given type in specified schemas, and make a list * of their Oids. We check USAGE privilege on the schemas, but there is * no privilege checking on the individual objects here. */

Source from the content-addressed store, hash-verified

906 * no privilege checking on the individual objects here.
907 */
908static List *
909objectsInSchemaToOids(ObjectType objtype, List *nspnames)
910{
911 List *objects = NIL;
912 ListCell *cell;
913
914 foreach(cell, nspnames)
915 {
916 char *nspname = strVal(lfirst(cell));
917 Oid namespaceId;
918 List *objs;
919
920 namespaceId = LookupExplicitNamespace(nspname, false);
921
922 switch (objtype)
923 {
924 case OBJECT_TABLE:
925 objs = getRelationsInNamespace(namespaceId, RELKIND_RELATION);
926 objects = list_concat(objects, objs);
927 objs = getRelationsInNamespace(namespaceId, RELKIND_VIEW);
928 objects = list_concat(objects, objs);
929 objs = getRelationsInNamespace(namespaceId, RELKIND_MATVIEW);
930 objects = list_concat(objects, objs);
931 objs = getRelationsInNamespace(namespaceId, RELKIND_FOREIGN_TABLE);
932 objects = list_concat(objects, objs);
933 objs = getRelationsInNamespace(namespaceId, RELKIND_PARTITIONED_TABLE);
934 objects = list_concat(objects, objs);
935 objs = getRelationsInNamespace(namespaceId, RELKIND_DIRECTORY_TABLE);
936 objects = list_concat(objects, objs);
937 break;
938 case OBJECT_SEQUENCE:
939 objs = getRelationsInNamespace(namespaceId, RELKIND_SEQUENCE);
940 objects = list_concat(objects, objs);
941 break;
942 case OBJECT_FUNCTION:
943 case OBJECT_PROCEDURE:
944 case OBJECT_ROUTINE:
945 {
946 ScanKeyData key[2];
947 int keycount;
948 Relation rel;
949 TableScanDesc scan;
950 HeapTuple tuple;
951
952 keycount = 0;
953 ScanKeyInit(&key[keycount++],
954 Anum_pg_proc_pronamespace,
955 BTEqualStrategyNumber, F_OIDEQ,
956 ObjectIdGetDatum(namespaceId));
957
958 if (objtype == OBJECT_FUNCTION)
959 /* includes aggregates and window functions */
960 ScanKeyInit(&key[keycount++],
961 Anum_pg_proc_prokind,
962 BTEqualStrategyNumber, F_CHARNE,
963 CharGetDatum(PROKIND_PROCEDURE));
964 else if (objtype == OBJECT_PROCEDURE)
965 ScanKeyInit(&key[keycount++],

Callers 1

ExecuteGrantStmtFunction · 0.85

Calls 13

LookupExplicitNamespaceFunction · 0.85
getRelationsInNamespaceFunction · 0.85
list_concatFunction · 0.85
ScanKeyInitFunction · 0.85
ObjectIdGetDatumFunction · 0.85
CharGetDatumFunction · 0.85
table_openFunction · 0.85
table_beginscan_catalogFunction · 0.85
heap_getnextFunction · 0.85
lappend_oidFunction · 0.85
table_endscanFunction · 0.85
table_closeFunction · 0.85

Tested by

no test coverage detected