1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * namespace.h |
4 | * prototypes for functions in backend/catalog/namespace.c |
5 | * |
6 | * |
7 | * Portions Copyright (c) 1996-2019, 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 | /* |
51 | * Option flag bits for RangeVarGetRelidExtended(). |
52 | */ |
53 | typedef enum RVROption |
54 | { |
55 | RVR_MISSING_OK = 1 << 0, /* don't error if relation doesn't exist */ |
56 | RVR_NOWAIT = 1 << 1, /* error if relation cannot be locked */ |
57 | RVR_SKIP_LOCKED = 1 << 2 /* skip if relation cannot be locked */ |
58 | } RVROption; |
59 | |
60 | typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId, |
61 | Oid oldRelId, void *callback_arg); |
62 | |
63 | #define RangeVarGetRelid(relation, lockmode, missing_ok) \ |
64 | RangeVarGetRelidExtended(relation, lockmode, \ |
65 | (missing_ok) ? RVR_MISSING_OK : 0, NULL, NULL) |
66 | |
67 | extern Oid RangeVarGetRelidExtended(const RangeVar *relation, |
68 | LOCKMODE lockmode, uint32 flags, |
69 | RangeVarGetRelidCallback callback, |
70 | void *callback_arg); |
71 | extern Oid RangeVarGetCreationNamespace(const RangeVar *newRelation); |
72 | extern Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation, |
73 | LOCKMODE lockmode, |
74 | Oid *existing_relation_id); |
75 | extern void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid); |
76 | extern Oid RelnameGetRelid(const char *relname); |
77 | extern bool RelationIsVisible(Oid relid); |
78 | |
79 | extern Oid TypenameGetTypid(const char *typname); |
80 | extern Oid TypenameGetTypidExtended(const char *typname, bool temp_ok); |
81 | extern bool TypeIsVisible(Oid typid); |
82 | |
83 | extern FuncCandidateList FuncnameGetCandidates(List *names, |
84 | int nargs, List *argnames, |
85 | bool expand_variadic, |
86 | bool expand_defaults, |
87 | bool missing_ok); |
88 | extern bool FunctionIsVisible(Oid funcid); |
89 | |
90 | extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright); |
91 | extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind, |
92 | bool missing_schema_ok); |
93 | extern bool OperatorIsVisible(Oid oprid); |
94 | |
95 | extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname); |
96 | extern bool OpclassIsVisible(Oid opcid); |
97 | |
98 | extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname); |
99 | extern bool OpfamilyIsVisible(Oid opfid); |
100 | |
101 | extern Oid CollationGetCollid(const char *collname); |
102 | extern bool CollationIsVisible(Oid collid); |
103 | |
104 | extern Oid ConversionGetConid(const char *conname); |
105 | extern bool ConversionIsVisible(Oid conid); |
106 | |
107 | extern Oid get_statistics_object_oid(List *names, bool missing_ok); |
108 | extern bool StatisticsObjIsVisible(Oid stxid); |
109 | |
110 | extern Oid get_ts_parser_oid(List *names, bool missing_ok); |
111 | extern bool TSParserIsVisible(Oid prsId); |
112 | |
113 | extern Oid get_ts_dict_oid(List *names, bool missing_ok); |
114 | extern bool TSDictionaryIsVisible(Oid dictId); |
115 | |
116 | extern Oid get_ts_template_oid(List *names, bool missing_ok); |
117 | extern bool TSTemplateIsVisible(Oid tmplId); |
118 | |
119 | extern Oid get_ts_config_oid(List *names, bool missing_ok); |
120 | extern bool TSConfigIsVisible(Oid cfgid); |
121 | |
122 | extern void DeconstructQualifiedName(List *names, |
123 | char **nspname_p, |
124 | char **objname_p); |
125 | extern Oid LookupNamespaceNoError(const char *nspname); |
126 | extern Oid LookupExplicitNamespace(const char *nspname, bool missing_ok); |
127 | extern Oid get_namespace_oid(const char *nspname, bool missing_ok); |
128 | |
129 | extern Oid LookupCreationNamespace(const char *nspname); |
130 | extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid); |
131 | extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p); |
132 | extern RangeVar *makeRangeVarFromNameList(List *names); |
133 | extern char *NameListToString(List *names); |
134 | extern char *NameListToQuotedString(List *names); |
135 | |
136 | extern bool isTempNamespace(Oid namespaceId); |
137 | extern bool isTempToastNamespace(Oid namespaceId); |
138 | extern bool isTempOrTempToastNamespace(Oid namespaceId); |
139 | extern bool isAnyTempNamespace(Oid namespaceId); |
140 | extern bool isOtherTempNamespace(Oid namespaceId); |
141 | extern bool isTempNamespaceInUse(Oid namespaceId); |
142 | extern int GetTempNamespaceBackendId(Oid namespaceId); |
143 | extern Oid GetTempToastNamespace(void); |
144 | extern void GetTempNamespaceState(Oid *tempNamespaceId, |
145 | Oid *tempToastNamespaceId); |
146 | extern void SetTempNamespaceState(Oid tempNamespaceId, |
147 | Oid tempToastNamespaceId); |
148 | extern void ResetTempTableNamespace(void); |
149 | |
150 | extern OverrideSearchPath *GetOverrideSearchPath(MemoryContext context); |
151 | extern OverrideSearchPath *CopyOverrideSearchPath(OverrideSearchPath *path); |
152 | extern bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path); |
153 | extern void PushOverrideSearchPath(OverrideSearchPath *newpath); |
154 | extern void PopOverrideSearchPath(void); |
155 | |
156 | extern Oid get_collation_oid(List *collname, bool missing_ok); |
157 | extern Oid get_conversion_oid(List *conname, bool missing_ok); |
158 | extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding); |
159 | |
160 | |
161 | /* initialization & transaction cleanup code */ |
162 | extern void InitializeSearchPath(void); |
163 | extern void AtEOXact_Namespace(bool isCommit, bool parallel); |
164 | extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, |
165 | SubTransactionId parentSubid); |
166 | |
167 | /* stuff for search_path GUC variable */ |
168 | extern char *namespace_search_path; |
169 | |
170 | extern List *fetch_search_path(bool includeImplicit); |
171 | extern int fetch_search_path_array(Oid *sarray, int sarray_len); |
172 | |
173 | #endif /* NAMESPACE_H */ |
174 | |