PostgreSQL Source Code  git master
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
17 #include "nodes/primnodes.h"
18 #include "storage/lock.h"
19 #include "storage/procnumber.h"
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 */
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 */
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 */
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 */
77 typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId,
78  Oid oldRelId, void *callback_arg);
80 #define RangeVarGetRelid(relation, lockmode, missing_ok) \
81  RangeVarGetRelidExtended(relation, lockmode, \
82  (missing_ok) ? RVR_MISSING_OK : 0, NULL, NULL)
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);
96 extern Oid TypenameGetTypid(const char *typname);
97 extern Oid TypenameGetTypidExtended(const char *typname, bool temp_ok);
98 extern bool TypeIsVisible(Oid typid);
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);
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);
113 extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname);
114 extern bool OpclassIsVisible(Oid opcid);
116 extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname);
117 extern bool OpfamilyIsVisible(Oid opfid);
119 extern Oid CollationGetCollid(const char *collname);
120 extern bool CollationIsVisible(Oid collid);
122 extern Oid ConversionGetConid(const char *conname);
123 extern bool ConversionIsVisible(Oid conid);
125 extern Oid get_statistics_object_oid(List *names, bool missing_ok);
126 extern bool StatisticsObjIsVisible(Oid stxid);
128 extern Oid get_ts_parser_oid(List *names, bool missing_ok);
129 extern bool TSParserIsVisible(Oid prsId);
131 extern Oid get_ts_dict_oid(List *names, bool missing_ok);
132 extern bool TSDictionaryIsVisible(Oid dictId);
134 extern Oid get_ts_template_oid(List *names, bool missing_ok);
135 extern bool TSTemplateIsVisible(Oid tmplId);
137 extern Oid get_ts_config_oid(List *names, bool missing_ok);
138 extern bool TSConfigIsVisible(Oid cfgid);
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);
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);
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);
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);
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);
183 /* stuff for search_path GUC variable */
186 extern List *fetch_search_path(bool includeImplicit);
187 extern int fetch_search_path_array(Oid *sarray, int sarray_len);
189 #endif /* NAMESPACE_H */
unsigned int uint32
Definition: c.h:506
Definition: c.h:1316
uint32 SubTransactionId
Definition: c.h:656
signed int int32
Definition: c.h:494
Definition: c.h:398
int nspid
Oid collid
Definition: lockdefs.h:26
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *relation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:724
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:2106
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3658
void ResetTempTableNamespace(void)
Definition: namespace.c:4629
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:4065
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1770
PGDLLIMPORT char * namespace_search_path
Definition: namespace.c:211
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:3370
char * NameListToQuotedString(const List *names)
Definition: namespace.c:3613
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:3050
Oid QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
Definition: namespace.c:3472
void(* RangeVarGetRelidCallback)(const RangeVar *relation, Oid relId, Oid oldRelId, void *callback_arg)
Definition: namespace.h:77
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:2241
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2392
bool TypeIsVisible(Oid typid)
Definition: namespace.c:1025
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3695
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:2358
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3634
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3672
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2494
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2560
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:3413
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:831
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4795
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3956
void DeconstructQualifiedName(const List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:3286
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool include_out_arguments, bool missing_ok)
Definition: namespace.c:1177
Definition: namespace.h:71
Definition: namespace.h:74
Definition: namespace.h:73
Definition: namespace.h:72
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3520
Oid TypenameGetTypidExtended(const char *typname, bool temp_ok)
Definition: namespace.c:993
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:639
bool RelationIsVisible(Oid relid)
Definition: namespace.c:898
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:2139
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2462
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:4543
TempNamespaceStatus checkTempNamespaceStatus(Oid namespaceId)
Definition: namespace.c:3714
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:3444
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3790
RangeVar * makeRangeVarFromNameList(const List *names)
Definition: namespace.c:3539
void InitializeSearchPath(void)
Definition: namespace.c:4721
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:2034
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2759
SearchPathMatcher * CopySearchPathMatcher(SearchPathMatcher *path)
Definition: namespace.c:3874
bool SearchPathMatchesCurrentEnvironment(SearchPathMatcher *path)
Definition: namespace.c:3896
Definition: namespace.h:46
Definition: namespace.h:49
Definition: namespace.h:47
Definition: namespace.h:48
Oid get_conversion_oid(List *conname, bool missing_ok)
Definition: namespace.c:4010
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1681
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2846
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2701
char * NameListToString(const List *names)
Definition: namespace.c:3579
void SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
Definition: namespace.c:3806
Oid GetTempToastNamespace(void)
Definition: namespace.c:3776
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:2208
struct _FuncCandidateList * FuncCandidateList
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:4497
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:3137
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1873
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:3340
ProcNumber GetTempNamespaceProcNumber(Oid namespaceId)
Definition: namespace.c:3751
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:980
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4835
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:426
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:3195
SearchPathMatcher * GetSearchPathMatcher(MemoryContext context)
Definition: namespace.c:3837
bool StatisticsObjIsVisible(Oid stxid)
Definition: namespace.c:2617
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:870
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2904
struct SearchPathMatcher SearchPathMatcher
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3646
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2992
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:1829
Definition: pg_list.h:54
uint64 generation
Definition: namespace.h:64
struct _FuncCandidateList * next
Definition: namespace.h:31
Definition: namespace.h:39
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46