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-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 {
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 Oid TypenameGetTypidExtended(const char *typname, bool temp_ok);
81 extern bool TypeIsVisible(Oid typid);
82 
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 relid);
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 
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 */
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:1739
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:2729
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:526
int GetTempNamespaceBackendId(Oid namespaceId)
Definition: namespace.c:3266
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:2006
Oid GetTempToastNamespace(void)
Definition: namespace.c:3291
bool isTempNamespaceInUse(Oid namespaceId)
Definition: namespace.c:3229
void PushOverrideSearchPath(OverrideSearchPath *newpath)
Definition: namespace.c:3464
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:1825
Oid TypenameGetTypidExtended(const char *typname, bool temp_ok)
Definition: namespace.c:776
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:2885
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1405
int LOCKMODE
Definition: lockdefs.h:26
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3305
Oid oprid(Operator op)
Definition: parse_oper.c:245
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2418
void ResetTempTableNamespace(void)
Definition: namespace.c:4184
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2671
char * namespace_search_path
Definition: namespace.c:190
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:2603
uint32 SubTransactionId
Definition: c.h:512
NameData relname
Definition: pg_class.h:35
unsigned int Oid
Definition: postgres_ext.h:31
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:2928
OverrideSearchPath * GetOverrideSearchPath(MemoryContext context)
Definition: namespace.c:3352
signed int int32
Definition: c.h:347
struct OverrideSearchPath OverrideSearchPath
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:3673
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:672
Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p)
Definition: namespace.c:2987
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3173
Oid args[FLEXIBLE_ARRAY_MEMBER]
Definition: namespace.h:37
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3149
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3564
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:2855
void DeconstructQualifiedName(List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:2801
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:3618
char * NameListToQuotedString(List *names)
Definition: namespace.c:3128
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2123
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2091
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:4069
unsigned int uint32
Definition: c.h:359
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:763
struct _FuncCandidateList * next
Definition: namespace.h:30
bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path)
Definition: namespace.c:3404
void InitializeSearchPath(void)
Definition: namespace.c:4247
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2170
OverrideSearchPath * CopyOverrideSearchPath(OverrideSearchPath *path)
Definition: namespace.c:3388
NameData typname
Definition: pg_type.h:42
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2545
RVROption
Definition: namespace.h:53
char * NameListToString(List *names)
Definition: namespace.c:3094
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3035
void PopOverrideSearchPath(void)
Definition: namespace.c:3523
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3187
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3054
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:1908
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2350
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:633
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1579
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:228
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2292
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:2959
bool RelationIsVisible(Oid relid)
Definition: namespace.c:700
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3161
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2476
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool missing_ok)
Definition: namespace.c:934
bool TypeIsVisible(Oid typid)
Definition: namespace.c:808
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:1792
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:3321
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4345
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:4003
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3210
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:441
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2040
Definition: pg_list.h:50
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1476
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:1875
bool StatisticsObjIsVisible(Oid relid)
Definition: namespace.c:2227
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4305