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-2024, 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 #include "storage/procnumber.h"
20 
21 
22 /*
23  * This structure holds a list of possible functions or operators
24  * found by namespace lookup. Each function/operator is identified
25  * by OID and by argument types; the list must be pruned by type
26  * resolution rules that are embodied in the parser, not here.
27  * See FuncnameGetCandidates's comments for more info.
28  */
29 typedef struct _FuncCandidateList
30 {
32  int pathpos; /* for internal use of namespace lookup */
33  Oid oid; /* the function or operator's OID */
34  int nominalnargs; /* either pronargs or length(proallargtypes) */
35  int nargs; /* number of arg types returned */
36  int nvargs; /* number of args to become variadic array */
37  int ndargs; /* number of defaulted args */
38  int *argnumbers; /* args' positional indexes, if named call */
39  Oid args[FLEXIBLE_ARRAY_MEMBER]; /* arg types */
41 
42 /*
43  * Result of checkTempNamespaceStatus
44  */
45 typedef enum TempNamespaceStatus
46 {
47  TEMP_NAMESPACE_NOT_TEMP, /* nonexistent, or non-temp namespace */
48  TEMP_NAMESPACE_IDLE, /* exists, belongs to no active session */
49  TEMP_NAMESPACE_IN_USE, /* belongs to some active session */
51 
52 /*
53  * Structure for xxxSearchPathMatcher functions
54  *
55  * The generation counter is private to namespace.c and shouldn't be touched
56  * by other code. It can be initialized to zero if necessary (that means
57  * "not known equal to the current active path").
58  */
59 typedef struct SearchPathMatcher
60 {
61  List *schemas; /* OIDs of explicitly named schemas */
62  bool addCatalog; /* implicitly prepend pg_catalog? */
63  bool addTemp; /* implicitly prepend temp schema? */
64  uint64 generation; /* for quick detection of equality to active */
66 
67 /*
68  * Option flag bits for RangeVarGetRelidExtended().
69  */
70 typedef enum RVROption
71 {
72  RVR_MISSING_OK = 1 << 0, /* don't error if relation doesn't exist */
73  RVR_NOWAIT = 1 << 1, /* error if relation cannot be locked */
74  RVR_SKIP_LOCKED = 1 << 2, /* skip if relation cannot be locked */
76 
77 typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId,
78  Oid oldRelId, void *callback_arg);
79 
80 #define RangeVarGetRelid(relation, lockmode, missing_ok) \
81  RangeVarGetRelidExtended(relation, lockmode, \
82  (missing_ok) ? RVR_MISSING_OK : 0, NULL, NULL)
83 
84 extern Oid RangeVarGetRelidExtended(const RangeVar *relation,
85  LOCKMODE lockmode, uint32 flags,
87  void *callback_arg);
88 extern Oid RangeVarGetCreationNamespace(const RangeVar *newRelation);
90  LOCKMODE lockmode,
91  Oid *existing_relation_id);
92 extern void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid);
93 extern Oid RelnameGetRelid(const char *relname);
94 extern bool RelationIsVisible(Oid relid);
95 
96 extern Oid TypenameGetTypid(const char *typname);
97 extern Oid TypenameGetTypidExtended(const char *typname, bool temp_ok);
98 extern bool TypeIsVisible(Oid typid);
99 
101  int nargs, List *argnames,
102  bool expand_variadic,
103  bool expand_defaults,
104  bool include_out_arguments,
105  bool missing_ok);
106 extern bool FunctionIsVisible(Oid funcid);
107 
108 extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright);
109 extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind,
110  bool missing_schema_ok);
111 extern bool OperatorIsVisible(Oid oprid);
112 
113 extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname);
114 extern bool OpclassIsVisible(Oid opcid);
115 
116 extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname);
117 extern bool OpfamilyIsVisible(Oid opfid);
118 
119 extern Oid CollationGetCollid(const char *collname);
120 extern bool CollationIsVisible(Oid collid);
121 
122 extern Oid ConversionGetConid(const char *conname);
123 extern bool ConversionIsVisible(Oid conid);
124 
125 extern Oid get_statistics_object_oid(List *names, bool missing_ok);
126 extern bool StatisticsObjIsVisible(Oid stxid);
127 
128 extern Oid get_ts_parser_oid(List *names, bool missing_ok);
129 extern bool TSParserIsVisible(Oid prsId);
130 
131 extern Oid get_ts_dict_oid(List *names, bool missing_ok);
132 extern bool TSDictionaryIsVisible(Oid dictId);
133 
134 extern Oid get_ts_template_oid(List *names, bool missing_ok);
135 extern bool TSTemplateIsVisible(Oid tmplId);
136 
137 extern Oid get_ts_config_oid(List *names, bool missing_ok);
138 extern bool TSConfigIsVisible(Oid cfgid);
139 
140 extern void DeconstructQualifiedName(const List *names,
141  char **nspname_p,
142  char **objname_p);
143 extern Oid LookupNamespaceNoError(const char *nspname);
144 extern Oid LookupExplicitNamespace(const char *nspname, bool missing_ok);
145 extern Oid get_namespace_oid(const char *nspname, bool missing_ok);
146 
147 extern Oid LookupCreationNamespace(const char *nspname);
148 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
149 extern Oid QualifiedNameGetCreationNamespace(const List *names, char **objname_p);
150 extern RangeVar *makeRangeVarFromNameList(const List *names);
151 extern char *NameListToString(const List *names);
152 extern char *NameListToQuotedString(const List *names);
153 
154 extern bool isTempNamespace(Oid namespaceId);
155 extern bool isTempToastNamespace(Oid namespaceId);
156 extern bool isTempOrTempToastNamespace(Oid namespaceId);
157 extern bool isAnyTempNamespace(Oid namespaceId);
158 extern bool isOtherTempNamespace(Oid namespaceId);
160 extern ProcNumber GetTempNamespaceProcNumber(Oid namespaceId);
161 extern Oid GetTempToastNamespace(void);
162 extern void GetTempNamespaceState(Oid *tempNamespaceId,
163  Oid *tempToastNamespaceId);
164 extern void SetTempNamespaceState(Oid tempNamespaceId,
165  Oid tempToastNamespaceId);
166 extern void ResetTempTableNamespace(void);
167 
171 
172 extern Oid get_collation_oid(List *collname, bool missing_ok);
173 extern Oid get_conversion_oid(List *conname, bool missing_ok);
174 extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
175 
176 
177 /* initialization & transaction cleanup code */
178 extern void InitializeSearchPath(void);
179 extern void AtEOXact_Namespace(bool isCommit, bool parallel);
180 extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
181  SubTransactionId parentSubid);
182 
183 /* stuff for search_path GUC variable */
185 
186 extern List *fetch_search_path(bool includeImplicit);
187 extern int fetch_search_path_array(Oid *sarray, int sarray_len);
188 
189 #endif /* NAMESPACE_H */
unsigned int uint32
Definition: c.h:506
#define PGDLLIMPORT
Definition: c.h:1307
uint32 SubTransactionId
Definition: c.h:647
signed int int32
Definition: c.h:496
#define FLEXIBLE_ARRAY_MEMBER
Definition: c.h:401
int nspid
Oid collid
int LOCKMODE
Definition: lockdefs.h:26
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *relation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:739
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:2121
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3673
void ResetTempTableNamespace(void)
Definition: namespace.c:4644
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:4080
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1785
PGDLLIMPORT char * namespace_search_path
Definition: namespace.c:211
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:3385
char * NameListToQuotedString(const List *names)
Definition: namespace.c:3628
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:3065
Oid QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
Definition: namespace.c:3487
void(* RangeVarGetRelidCallback)(const RangeVar *relation, Oid relId, Oid oldRelId, void *callback_arg)
Definition: namespace.h:77
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:2256
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2407
bool TypeIsVisible(Oid typid)
Definition: namespace.c:1040
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3710
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:2373
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3649
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3687
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2509
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2575
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:3428
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:846
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4819
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3971
void DeconstructQualifiedName(const List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:3301
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool include_out_arguments, bool missing_ok)
Definition: namespace.c:1192
RVROption
Definition: namespace.h:71
@ RVR_SKIP_LOCKED
Definition: namespace.h:74
@ RVR_NOWAIT
Definition: namespace.h:73
@ RVR_MISSING_OK
Definition: namespace.h:72
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3535
Oid TypenameGetTypidExtended(const char *typname, bool temp_ok)
Definition: namespace.c:1008
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:654
bool RelationIsVisible(Oid relid)
Definition: namespace.c:913
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:2154
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2477
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:4558
TempNamespaceStatus checkTempNamespaceStatus(Oid namespaceId)
Definition: namespace.c:3729
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:3459
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3805
RangeVar * makeRangeVarFromNameList(const List *names)
Definition: namespace.c:3554
void InitializeSearchPath(void)
Definition: namespace.c:4736
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:2049
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2774
SearchPathMatcher * CopySearchPathMatcher(SearchPathMatcher *path)
Definition: namespace.c:3889
bool SearchPathMatchesCurrentEnvironment(SearchPathMatcher *path)
Definition: namespace.c:3911
TempNamespaceStatus
Definition: namespace.h:46
@ TEMP_NAMESPACE_IN_USE
Definition: namespace.h:49
@ TEMP_NAMESPACE_NOT_TEMP
Definition: namespace.h:47
@ TEMP_NAMESPACE_IDLE
Definition: namespace.h:48
Oid get_conversion_oid(List *conname, bool missing_ok)
Definition: namespace.c:4025
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1696
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2861
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2716
char * NameListToString(const List *names)
Definition: namespace.c:3594
void SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
Definition: namespace.c:3821
Oid GetTempToastNamespace(void)
Definition: namespace.c:3791
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:2223
struct _FuncCandidateList * FuncCandidateList
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:4512
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:3152
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1888
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:3355
ProcNumber GetTempNamespaceProcNumber(Oid namespaceId)
Definition: namespace.c:3766
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:995
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4859
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:441
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:3210
SearchPathMatcher * GetSearchPathMatcher(MemoryContext context)
Definition: namespace.c:3852
bool StatisticsObjIsVisible(Oid stxid)
Definition: namespace.c:2632
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:885
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2919
struct SearchPathMatcher SearchPathMatcher
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3661
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:3007
Oid oprid(Operator op)
Definition: parse_oper.c:238
NameData relname
Definition: pg_class.h:38
NameData typname
Definition: pg_type.h:41
unsigned int Oid
Definition: postgres_ext.h:31
int ProcNumber
Definition: procnumber.h:24
tree context
Definition: radixtree.h:1835
Definition: pg_list.h:54
uint64 generation
Definition: namespace.h:64
struct _FuncCandidateList * next
Definition: namespace.h:31
Oid args[FLEXIBLE_ARRAY_MEMBER]
Definition: namespace.h:39
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46