* 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. */
| 906 | * no privilege checking on the individual objects here. |
| 907 | */ |
| 908 | static List * |
| 909 | objectsInSchemaToOids(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++], |
no test coverage detected