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-2022, 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 */
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 */
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 */
unsigned int uint32
Definition: c.h:441
#define PGDLLIMPORT
Definition: c.h:1331
uint32 SubTransactionId
Definition: c.h:591
signed int int32
Definition: c.h:429
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:350
int LOCKMODE
Definition: lockdefs.h:26
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:1846
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:536
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3227
void ResetTempTableNamespace(void)
Definition: namespace.c:4309
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:3756
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1529
PGDLLIMPORT char * namespace_search_path
Definition: namespace.c:199
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:2939
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:2657
void(* RangeVarGetRelidCallback)(const RangeVar *relation, Oid relId, Oid oldRelId, void *callback_arg)
Definition: namespace.h:76
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:1962
void DeconstructQualifiedName(List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:2855
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2094
bool TypeIsVisible(Oid typid)
Definition: namespace.c:818
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3264
Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p)
Definition: namespace.c:3041
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:2060
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3108
void PushOverrideSearchPath(OverrideSearchPath *newpath)
Definition: namespace.c:3536
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3203
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3241
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2177
void PopOverrideSearchPath(void)
Definition: namespace.c:3603
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2224
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:2982
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:643
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4431
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3647
char * NameListToQuotedString(List *names)
Definition: namespace.c:3182
bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path)
Definition: namespace.c:3465
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool include_out_arguments, bool missing_ok)
Definition: namespace.c:951
RVROption
Definition: namespace.h:70
@ RVR_SKIP_LOCKED
Definition: namespace.h:73
@ RVR_NOWAIT
Definition: namespace.h:72
@ RVR_MISSING_OK
Definition: namespace.h:71
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3089
Oid TypenameGetTypidExtended(const char *typname, bool temp_ok)
Definition: namespace.c:786
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:451
bool RelationIsVisible(Oid relid)
Definition: namespace.c:710
OverrideSearchPath * CopyOverrideSearchPath(OverrideSearchPath *path)
Definition: namespace.c:3443
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:1879
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2145
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:4178
TempNamespaceStatus checkTempNamespaceStatus(Oid namespaceId)
Definition: namespace.c:3283
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:3013
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3359
void InitializeSearchPath(void)
Definition: namespace.c:4372
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:1793
bool StatisticsObjIsVisible(Oid relid)
Definition: namespace.c:2281
struct OverrideSearchPath OverrideSearchPath
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2404
OverrideSearchPath * GetOverrideSearchPath(MemoryContext context)
Definition: namespace.c:3406
TempNamespaceStatus
Definition: namespace.h:45
@ TEMP_NAMESPACE_IN_USE
Definition: namespace.h:48
@ TEMP_NAMESPACE_NOT_TEMP
Definition: namespace.h:46
@ TEMP_NAMESPACE_IDLE
Definition: namespace.h:47
Oid get_conversion_oid(List *conname, bool missing_ok)
Definition: namespace.c:3701
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1459
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2472
char * NameListToString(List *names)
Definition: namespace.c:3148
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2346
void SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
Definition: namespace.c:3375
Oid GetTempToastNamespace(void)
Definition: namespace.c:3345
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:1929
struct _FuncCandidateList * FuncCandidateList
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:4110
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2725
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1632
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:2909
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:773
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4471
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:238
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:2783
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:682
int GetTempNamespaceBackendId(Oid namespaceId)
Definition: namespace.c:3320
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2530
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3215
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2599
Oid oprid(Operator op)
Definition: parse_oper.c:250
NameData relname
Definition: pg_class.h:38
NameData typname
Definition: pg_type.h:41
unsigned int Oid
Definition: postgres_ext.h:31
Definition: pg_list.h:51
struct _FuncCandidateList * next
Definition: namespace.h:30
Oid args[FLEXIBLE_ARRAY_MEMBER]
Definition: namespace.h:38
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:48