PostgreSQL Source Code  git master
namespace.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * namespace.h
4  * prototypes for functions in backend/catalog/namespace.c
5  *
6  *
7  * Portions Copyright (c) 1996-2018, 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 {
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 */
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? */
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,
70  void *callback_arg);
71 extern Oid RangeVarGetCreationNamespace(const 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 bool TypeIsVisible(Oid typid);
81 
83  int nargs, List *argnames,
84  bool expand_variadic,
85  bool expand_defaults,
86  bool missing_ok);
87 extern bool FunctionIsVisible(Oid funcid);
88 
89 extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright);
90 extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind,
91  bool missing_schema_ok);
92 extern bool OperatorIsVisible(Oid oprid);
93 
94 extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname);
95 extern bool OpclassIsVisible(Oid opcid);
96 
97 extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname);
98 extern bool OpfamilyIsVisible(Oid opfid);
99 
100 extern Oid CollationGetCollid(const char *collname);
101 extern bool CollationIsVisible(Oid collid);
102 
103 extern Oid ConversionGetConid(const char *conname);
104 extern bool ConversionIsVisible(Oid conid);
105 
106 extern Oid get_statistics_object_oid(List *names, bool missing_ok);
107 extern bool StatisticsObjIsVisible(Oid stxid);
108 
109 extern Oid get_ts_parser_oid(List *names, bool missing_ok);
110 extern bool TSParserIsVisible(Oid prsId);
111 
112 extern Oid get_ts_dict_oid(List *names, bool missing_ok);
113 extern bool TSDictionaryIsVisible(Oid dictId);
114 
115 extern Oid get_ts_template_oid(List *names, bool missing_ok);
116 extern bool TSTemplateIsVisible(Oid tmplId);
117 
118 extern Oid get_ts_config_oid(List *names, bool missing_ok);
119 extern bool TSConfigIsVisible(Oid cfgid);
120 
121 extern void DeconstructQualifiedName(List *names,
122  char **nspname_p,
123  char **objname_p);
124 extern Oid LookupNamespaceNoError(const char *nspname);
125 extern Oid LookupExplicitNamespace(const char *nspname, bool missing_ok);
126 extern Oid get_namespace_oid(const char *nspname, bool missing_ok);
127 
128 extern Oid LookupCreationNamespace(const char *nspname);
129 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
130 extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p);
131 extern RangeVar *makeRangeVarFromNameList(List *names);
132 extern char *NameListToString(List *names);
133 extern char *NameListToQuotedString(List *names);
134 
135 extern bool isTempNamespace(Oid namespaceId);
136 extern bool isTempToastNamespace(Oid namespaceId);
137 extern bool isTempOrTempToastNamespace(Oid namespaceId);
138 extern bool isAnyTempNamespace(Oid namespaceId);
139 extern bool isOtherTempNamespace(Oid namespaceId);
140 extern int GetTempNamespaceBackendId(Oid namespaceId);
141 extern Oid GetTempToastNamespace(void);
142 extern void GetTempNamespaceState(Oid *tempNamespaceId,
143  Oid *tempToastNamespaceId);
144 extern void SetTempNamespaceState(Oid tempNamespaceId,
145  Oid tempToastNamespaceId);
146 extern void ResetTempTableNamespace(void);
147 
151 extern void PushOverrideSearchPath(OverrideSearchPath *newpath);
152 extern void PopOverrideSearchPath(void);
153 
154 extern Oid get_collation_oid(List *collname, bool missing_ok);
155 extern Oid get_conversion_oid(List *conname, bool missing_ok);
156 extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
157 
158 
159 /* initialization & transaction cleanup code */
160 extern void InitializeSearchPath(void);
161 extern void AtEOXact_Namespace(bool isCommit, bool parallel);
162 extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
163  SubTransactionId parentSubid);
164 
165 /* stuff for search_path GUC variable */
166 extern char *namespace_search_path;
167 
168 extern List *fetch_search_path(bool includeImplicit);
169 extern int fetch_search_path_array(Oid *sarray, int sarray_len);
170 
171 #endif /* NAMESPACE_H */
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:1726
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:2716
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:527
int GetTempNamespaceBackendId(Oid namespaceId)
Definition: namespace.c:3214
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:1993
Oid GetTempToastNamespace(void)
Definition: namespace.c:3239
void PushOverrideSearchPath(OverrideSearchPath *newpath)
Definition: namespace.c:3412
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:1812
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:2872
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1393
int LOCKMODE
Definition: lockdefs.h:26
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3253
Oid oprid(Operator op)
Definition: parse_oper.c:245
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2405
void ResetTempTableNamespace(void)
Definition: namespace.c:4066
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2658
char * namespace_search_path
Definition: namespace.c:190
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:2590
uint32 SubTransactionId
Definition: c.h:478
unsigned int Oid
Definition: postgres_ext.h:31
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:2915
OverrideSearchPath * GetOverrideSearchPath(MemoryContext context)
Definition: namespace.c:3300
signed int int32
Definition: c.h:313
struct OverrideSearchPath OverrideSearchPath
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:3621
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:673
Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p)
Definition: namespace.c:2975
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3161
Oid args[FLEXIBLE_ARRAY_MEMBER]
Definition: namespace.h:37
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3137
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3512
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:2842
void DeconstructQualifiedName(List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:2788
struct _FuncCandidateList * FuncCandidateList
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48
Oid get_conversion_oid(List *conname, bool missing_ok)
Definition: namespace.c:3566
char * NameListToQuotedString(List *names)
Definition: namespace.c:3116
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2110
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2078
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:3962
unsigned int uint32
Definition: c.h:325
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:767
struct _FuncCandidateList * next
Definition: namespace.h:30
bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path)
Definition: namespace.c:3352
void InitializeSearchPath(void)
Definition: namespace.c:4129
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2157
OverrideSearchPath * CopyOverrideSearchPath(OverrideSearchPath *path)
Definition: namespace.c:3336
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2532
RVROption
Definition: namespace.h:53
char * NameListToString(List *names)
Definition: namespace.c:3082
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3024
void PopOverrideSearchPath(void)
Definition: namespace.c:3471
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3175
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3042
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:1895
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2337
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:634
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1566
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:227
bool StatisticsObjIsVisible(Oid stxid)
Definition: namespace.c:2214
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2279
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:2947
bool RelationIsVisible(Oid relid)
Definition: namespace.c:701
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3149
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2463
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool missing_ok)
Definition: namespace.c:922
bool TypeIsVisible(Oid typid)
Definition: namespace.c:796
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:1779
void(* RangeVarGetRelidCallback)(const RangeVar *relation, Oid relId, Oid oldRelId, void *callback_arg)
Definition: namespace.h:60
void SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
Definition: namespace.c:3269
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4227
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:3907
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3198
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:440
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2027
Definition: pg_list.h:45
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1464
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:1862
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4187