1 /*------------------------------------------------------------------------- 2 * 3 * namespace.h 4 * prototypes for functions in backend/catalog/namespace.c 5 * 6 * 7 * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group 8 * Portions Copyright (c) 1994, Regents of the University of California 9 * 10 * src/include/catalog/namespace.h 11 * 12 *------------------------------------------------------------------------- 13 */ 14 #ifndef NAMESPACE_H 15 #define NAMESPACE_H 16 17 #include "nodes/primnodes.h" 18 #include "storage/lock.h" 19 20 21 /* 22 * This structure holds a list of possible functions or operators 23 * found by namespace lookup. Each function/operator is identified 24 * by OID and by argument types; the list must be pruned by type 25 * resolution rules that are embodied in the parser, not here. 26 * See FuncnameGetCandidates's comments for more info. 27 */ 28 typedef struct _FuncCandidateList 29 { 30 struct _FuncCandidateList *next; 31 int pathpos; /* for internal use of namespace lookup */ 32 Oid oid; /* the function or operator's OID */ 33 int nargs; /* number of arg types returned */ 34 int nvargs; /* number of args to become variadic array */ 35 int ndargs; /* number of defaulted args */ 36 int *argnumbers; /* args' positional indexes, if named call */ 37 Oid args[FLEXIBLE_ARRAY_MEMBER]; /* arg types */ 38 } *FuncCandidateList; 39 40 /* 41 * Structure for xxxOverrideSearchPath functions 42 */ 43 typedef struct OverrideSearchPath 44 { 45 List *schemas; /* OIDs of explicitly named schemas */ 46 bool addCatalog; /* implicitly prepend pg_catalog? */ 47 bool addTemp; /* implicitly prepend temp schema? */ 48 } OverrideSearchPath; 49 50 typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId, 51 Oid oldRelId, void *callback_arg); 52 53 #define RangeVarGetRelid(relation, lockmode, missing_ok) \ 54 RangeVarGetRelidExtended(relation, lockmode, missing_ok, false, NULL, NULL) 55 56 extern Oid RangeVarGetRelidExtended(const RangeVar *relation, 57 LOCKMODE lockmode, bool missing_ok, bool nowait, 58 RangeVarGetRelidCallback callback, 59 void *callback_arg); 60 extern Oid RangeVarGetCreationNamespace(const RangeVar *newRelation); 61 extern Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation, 62 LOCKMODE lockmode, 63 Oid *existing_relation_id); 64 extern void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid); 65 extern Oid RelnameGetRelid(const char *relname); 66 extern bool RelationIsVisible(Oid relid); 67 68 extern Oid TypenameGetTypid(const char *typname); 69 extern Oid TypenameGetTypidExtended(const char *typname, bool temp_ok); 70 extern bool TypeIsVisible(Oid typid); 71 72 extern FuncCandidateList FuncnameGetCandidates(List *names, 73 int nargs, List *argnames, 74 bool expand_variadic, 75 bool expand_defaults, 76 bool missing_ok); 77 extern bool FunctionIsVisible(Oid funcid); 78 79 extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright); 80 extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind, 81 bool missing_schema_ok); 82 extern bool OperatorIsVisible(Oid oprid); 83 84 extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname); 85 extern bool OpclassIsVisible(Oid opcid); 86 87 extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname); 88 extern bool OpfamilyIsVisible(Oid opfid); 89 90 extern Oid CollationGetCollid(const char *collname); 91 extern bool CollationIsVisible(Oid collid); 92 93 extern Oid ConversionGetConid(const char *conname); 94 extern bool ConversionIsVisible(Oid conid); 95 96 extern Oid get_statistics_object_oid(List *names, bool missing_ok); 97 extern bool StatisticsObjIsVisible(Oid stxid); 98 99 extern Oid get_ts_parser_oid(List *names, bool missing_ok); 100 extern bool TSParserIsVisible(Oid prsId); 101 102 extern Oid get_ts_dict_oid(List *names, bool missing_ok); 103 extern bool TSDictionaryIsVisible(Oid dictId); 104 105 extern Oid get_ts_template_oid(List *names, bool missing_ok); 106 extern bool TSTemplateIsVisible(Oid tmplId); 107 108 extern Oid get_ts_config_oid(List *names, bool missing_ok); 109 extern bool TSConfigIsVisible(Oid cfgid); 110 111 extern void DeconstructQualifiedName(List *names, 112 char **nspname_p, 113 char **objname_p); 114 extern Oid LookupNamespaceNoError(const char *nspname); 115 extern Oid LookupExplicitNamespace(const char *nspname, bool missing_ok); 116 extern Oid get_namespace_oid(const char *nspname, bool missing_ok); 117 118 extern Oid LookupCreationNamespace(const char *nspname); 119 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid); 120 extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p); 121 extern RangeVar *makeRangeVarFromNameList(List *names); 122 extern char *NameListToString(List *names); 123 extern char *NameListToQuotedString(List *names); 124 125 extern bool isTempNamespace(Oid namespaceId); 126 extern bool isTempToastNamespace(Oid namespaceId); 127 extern bool isTempOrTempToastNamespace(Oid namespaceId); 128 extern bool isAnyTempNamespace(Oid namespaceId); 129 extern bool isOtherTempNamespace(Oid namespaceId); 130 extern int GetTempNamespaceBackendId(Oid namespaceId); 131 extern Oid GetTempToastNamespace(void); 132 extern void GetTempNamespaceState(Oid *tempNamespaceId, 133 Oid *tempToastNamespaceId); 134 extern void SetTempNamespaceState(Oid tempNamespaceId, 135 Oid tempToastNamespaceId); 136 extern void ResetTempTableNamespace(void); 137 138 extern OverrideSearchPath *GetOverrideSearchPath(MemoryContext context); 139 extern OverrideSearchPath *CopyOverrideSearchPath(OverrideSearchPath *path); 140 extern bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path); 141 extern void PushOverrideSearchPath(OverrideSearchPath *newpath); 142 extern void PopOverrideSearchPath(void); 143 144 extern Oid get_collation_oid(List *collname, bool missing_ok); 145 extern Oid get_conversion_oid(List *conname, bool missing_ok); 146 extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding); 147 148 149 /* initialization & transaction cleanup code */ 150 extern void InitializeSearchPath(void); 151 extern void AtEOXact_Namespace(bool isCommit, bool parallel); 152 extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, 153 SubTransactionId parentSubid); 154 155 /* stuff for search_path GUC variable */ 156 extern char *namespace_search_path; 157 158 extern List *fetch_search_path(bool includeImplicit); 159 extern int fetch_search_path_array(Oid *sarray, int sarray_len); 160 161 #endif /* NAMESPACE_H */ 162