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-2021, 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 nominalnargs; /* either pronargs or length(proallargtypes) */
34  int nargs; /* number of arg types returned */
35  int nvargs; /* number of args to become variadic array */
36  int ndargs; /* number of defaulted args */
37  int *argnumbers; /* args' positional indexes, if named call */
38  Oid args[FLEXIBLE_ARRAY_MEMBER]; /* arg types */
40 
41 /*
42  * Result of checkTempNamespaceStatus
43  */
44 typedef enum TempNamespaceStatus
45 {
46  TEMP_NAMESPACE_NOT_TEMP, /* nonexistent, or non-temp namespace */
47  TEMP_NAMESPACE_IDLE, /* exists, belongs to no active session */
48  TEMP_NAMESPACE_IN_USE /* belongs to some active session */
50 
51 /*
52  * Structure for xxxOverrideSearchPath functions
53  *
54  * The generation counter is private to namespace.c and shouldn't be touched
55  * by other code. It can be initialized to zero if necessary (that means
56  * "not known equal to the current active path").
57  */
58 typedef struct OverrideSearchPath
59 {
60  List *schemas; /* OIDs of explicitly named schemas */
61  bool addCatalog; /* implicitly prepend pg_catalog? */
62  bool addTemp; /* implicitly prepend temp schema? */
63  uint64 generation; /* for quick detection of equality to active */
65 
66 /*
67  * Option flag bits for RangeVarGetRelidExtended().
68  */
69 typedef enum RVROption
70 {
71  RVR_MISSING_OK = 1 << 0, /* don't error if relation doesn't exist */
72  RVR_NOWAIT = 1 << 1, /* error if relation cannot be locked */
73  RVR_SKIP_LOCKED = 1 << 2 /* skip if relation cannot be locked */
74 } RVROption;
75 
76 typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId,
77  Oid oldRelId, void *callback_arg);
78 
79 #define RangeVarGetRelid(relation, lockmode, missing_ok) \
80  RangeVarGetRelidExtended(relation, lockmode, \
81  (missing_ok) ? RVR_MISSING_OK : 0, NULL, NULL)
82 
83 extern Oid RangeVarGetRelidExtended(const RangeVar *relation,
84  LOCKMODE lockmode, uint32 flags,
86  void *callback_arg);
87 extern Oid RangeVarGetCreationNamespace(const RangeVar *newRelation);
89  LOCKMODE lockmode,
90  Oid *existing_relation_id);
91 extern void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid);
92 extern Oid RelnameGetRelid(const char *relname);
93 extern bool RelationIsVisible(Oid relid);
94 
95 extern Oid TypenameGetTypid(const char *typname);
96 extern Oid TypenameGetTypidExtended(const char *typname, bool temp_ok);
97 extern bool TypeIsVisible(Oid typid);
98 
100  int nargs, List *argnames,
101  bool expand_variadic,
102  bool expand_defaults,
103  bool include_out_arguments,
104  bool missing_ok);
105 extern bool FunctionIsVisible(Oid funcid);
106 
107 extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright);
108 extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind,
109  bool missing_schema_ok);
110 extern bool OperatorIsVisible(Oid oprid);
111 
112 extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname);
113 extern bool OpclassIsVisible(Oid opcid);
114 
115 extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname);
116 extern bool OpfamilyIsVisible(Oid opfid);
117 
118 extern Oid CollationGetCollid(const char *collname);
119 extern bool CollationIsVisible(Oid collid);
120 
121 extern Oid ConversionGetConid(const char *conname);
122 extern bool ConversionIsVisible(Oid conid);
123 
124 extern Oid get_statistics_object_oid(List *names, bool missing_ok);
125 extern bool StatisticsObjIsVisible(Oid relid);
126 
127 extern Oid get_ts_parser_oid(List *names, bool missing_ok);
128 extern bool TSParserIsVisible(Oid prsId);
129 
130 extern Oid get_ts_dict_oid(List *names, bool missing_ok);
131 extern bool TSDictionaryIsVisible(Oid dictId);
132 
133 extern Oid get_ts_template_oid(List *names, bool missing_ok);
134 extern bool TSTemplateIsVisible(Oid tmplId);
135 
136 extern Oid get_ts_config_oid(List *names, bool missing_ok);
137 extern bool TSConfigIsVisible(Oid cfgid);
138 
139 extern void DeconstructQualifiedName(List *names,
140  char **nspname_p,
141  char **objname_p);
142 extern Oid LookupNamespaceNoError(const char *nspname);
143 extern Oid LookupExplicitNamespace(const char *nspname, bool missing_ok);
144 extern Oid get_namespace_oid(const char *nspname, bool missing_ok);
145 
146 extern Oid LookupCreationNamespace(const char *nspname);
147 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
148 extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p);
149 extern RangeVar *makeRangeVarFromNameList(List *names);
150 extern char *NameListToString(List *names);
151 extern char *NameListToQuotedString(List *names);
152 
153 extern bool isTempNamespace(Oid namespaceId);
154 extern bool isTempToastNamespace(Oid namespaceId);
155 extern bool isTempOrTempToastNamespace(Oid namespaceId);
156 extern bool isAnyTempNamespace(Oid namespaceId);
157 extern bool isOtherTempNamespace(Oid namespaceId);
159 extern int GetTempNamespaceBackendId(Oid namespaceId);
160 extern Oid GetTempToastNamespace(void);
161 extern void GetTempNamespaceState(Oid *tempNamespaceId,
162  Oid *tempToastNamespaceId);
163 extern void SetTempNamespaceState(Oid tempNamespaceId,
164  Oid tempToastNamespaceId);
165 extern void ResetTempTableNamespace(void);
166 
170 extern void PushOverrideSearchPath(OverrideSearchPath *newpath);
171 extern void PopOverrideSearchPath(void);
172 
173 extern Oid get_collation_oid(List *collname, bool missing_ok);
174 extern Oid get_conversion_oid(List *conname, bool missing_ok);
175 extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
176 
177 
178 /* initialization & transaction cleanup code */
179 extern void InitializeSearchPath(void);
180 extern void AtEOXact_Namespace(bool isCommit, bool parallel);
181 extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
182  SubTransactionId parentSubid);
183 
184 /* stuff for search_path GUC variable */
185 extern char *namespace_search_path;
186 
187 extern List *fetch_search_path(bool includeImplicit);
188 extern int fetch_search_path_array(Oid *sarray, int sarray_len);
189 
190 #endif /* NAMESPACE_H */
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:1792
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:2782
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:535
int GetTempNamespaceBackendId(Oid namespaceId)
Definition: namespace.c:3319
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:2059
Oid GetTempToastNamespace(void)
Definition: namespace.c:3344
void PushOverrideSearchPath(OverrideSearchPath *newpath)
Definition: namespace.c:3535
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:1878
Oid TypenameGetTypidExtended(const char *typname, bool temp_ok)
Definition: namespace.c:785
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:2938
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1458
int LOCKMODE
Definition: lockdefs.h:26
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3358
Oid oprid(Operator op)
Definition: parse_oper.c:250
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2471
void ResetTempTableNamespace(void)
Definition: namespace.c:4306
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2724
char * namespace_search_path
Definition: namespace.c:198
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:350
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:2656
uint32 SubTransactionId
Definition: c.h:591
NameData relname
Definition: pg_class.h:38
unsigned int Oid
Definition: postgres_ext.h:31
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:2981
OverrideSearchPath * GetOverrideSearchPath(MemoryContext context)
Definition: namespace.c:3405
signed int int32
Definition: c.h:429
struct OverrideSearchPath OverrideSearchPath
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:3755
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:681
Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p)
Definition: namespace.c:3040
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3226
Oid args[FLEXIBLE_ARRAY_MEMBER]
Definition: namespace.h:38
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3202
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3646
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:2908
void DeconstructQualifiedName(List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:2854
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:3700
char * NameListToQuotedString(List *names)
Definition: namespace.c:3181
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2176
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2144
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:4177
unsigned int uint32
Definition: c.h:441
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:772
struct _FuncCandidateList * next
Definition: namespace.h:30
bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path)
Definition: namespace.c:3464
void InitializeSearchPath(void)
Definition: namespace.c:4369
TempNamespaceStatus checkTempNamespaceStatus(Oid namespaceId)
Definition: namespace.c:3282
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2223
OverrideSearchPath * CopyOverrideSearchPath(OverrideSearchPath *path)
Definition: namespace.c:3442
NameData typname
Definition: pg_type.h:41
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2598
RVROption
Definition: namespace.h:69
char * NameListToString(List *names)
Definition: namespace.c:3147
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3088
void PopOverrideSearchPath(void)
Definition: namespace.c:3602
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3240
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3107
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:1961
TempNamespaceStatus
Definition: namespace.h:44
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2403
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:642
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool include_out_arguments, bool missing_ok)
Definition: namespace.c:950
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1631
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:237
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2345
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:3012
bool RelationIsVisible(Oid relid)
Definition: namespace.c:709
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3214
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2529
bool TypeIsVisible(Oid typid)
Definition: namespace.c:817
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:1845
void(* RangeVarGetRelidCallback)(const RangeVar *relation, Oid relId, Oid oldRelId, void *callback_arg)
Definition: namespace.h:76
void SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
Definition: namespace.c:3374
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4468
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:4109
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3263
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:450
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2093
Definition: pg_list.h:50
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1528
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:1928
bool StatisticsObjIsVisible(Oid relid)
Definition: namespace.c:2280
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4428