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-2023, 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"
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 */
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 */
51 /*
52  * Structure for xxxSearchPathMatcher 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 SearchPathMatcher
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 */
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 */
76 typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId,
77  Oid oldRelId, void *callback_arg);
79 #define RangeVarGetRelid(relation, lockmode, missing_ok) \
80  RangeVarGetRelidExtended(relation, lockmode, \
81  (missing_ok) ? RVR_MISSING_OK : 0, NULL, NULL)
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);
95 extern Oid TypenameGetTypid(const char *typname);
96 extern Oid TypenameGetTypidExtended(const char *typname, bool temp_ok);
97 extern bool TypeIsVisible(Oid typid);
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);
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);
112 extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname);
113 extern bool OpclassIsVisible(Oid opcid);
115 extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname);
116 extern bool OpfamilyIsVisible(Oid opfid);
118 extern Oid CollationGetCollid(const char *collname);
119 extern bool CollationIsVisible(Oid collid);
121 extern Oid ConversionGetConid(const char *conname);
122 extern bool ConversionIsVisible(Oid conid);
124 extern Oid get_statistics_object_oid(List *names, bool missing_ok);
125 extern bool StatisticsObjIsVisible(Oid stxid);
127 extern Oid get_ts_parser_oid(List *names, bool missing_ok);
128 extern bool TSParserIsVisible(Oid prsId);
130 extern Oid get_ts_dict_oid(List *names, bool missing_ok);
131 extern bool TSDictionaryIsVisible(Oid dictId);
133 extern Oid get_ts_template_oid(List *names, bool missing_ok);
134 extern bool TSTemplateIsVisible(Oid tmplId);
136 extern Oid get_ts_config_oid(List *names, bool missing_ok);
137 extern bool TSConfigIsVisible(Oid cfgid);
139 extern void DeconstructQualifiedName(const 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);
146 extern Oid LookupCreationNamespace(const char *nspname);
147 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
148 extern Oid QualifiedNameGetCreationNamespace(const List *names, char **objname_p);
149 extern RangeVar *makeRangeVarFromNameList(const List *names);
150 extern char *NameListToString(const List *names);
151 extern char *NameListToQuotedString(const List *names);
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);
171 extern Oid get_collation_oid(List *collname, bool missing_ok);
172 extern Oid get_conversion_oid(List *conname, bool missing_ok);
173 extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
176 /* initialization & transaction cleanup code */
177 extern void InitializeSearchPath(void);
178 extern void AtEOXact_Namespace(bool isCommit, bool parallel);
179 extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
180  SubTransactionId parentSubid);
182 /* stuff for search_path GUC variable */
185 extern List *fetch_search_path(bool includeImplicit);
186 extern int fetch_search_path_array(Oid *sarray, int sarray_len);
188 #endif /* NAMESPACE_H */
unsigned int uint32
Definition: c.h:495
Definition: c.h:1326
uint32 SubTransactionId
Definition: c.h:645
signed int int32
Definition: c.h:483
Definition: c.h:387
int nspid
Oid collid
Definition: lockdefs.h:26
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *relation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:680
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:2062
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3614
void ResetTempTableNamespace(void)
Definition: namespace.c:4585
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:4021
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1726
PGDLLIMPORT char * namespace_search_path
Definition: namespace.c:206
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:3326
char * NameListToQuotedString(const List *names)
Definition: namespace.c:3569
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:3006
Oid QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
Definition: namespace.c:3428
void(* RangeVarGetRelidCallback)(const RangeVar *relation, Oid relId, Oid oldRelId, void *callback_arg)
Definition: namespace.h:76
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:2197
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2348
bool TypeIsVisible(Oid typid)
Definition: namespace.c:981
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3651
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:2314
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3590
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3628
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2450
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2516
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:3369
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:787
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4758
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3912
void DeconstructQualifiedName(const List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:3242
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool include_out_arguments, bool missing_ok)
Definition: namespace.c:1133
Definition: namespace.h:70
Definition: namespace.h:73
Definition: namespace.h:72
Definition: namespace.h:71
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3476
Oid TypenameGetTypidExtended(const char *typname, bool temp_ok)
Definition: namespace.c:949
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:595
bool RelationIsVisible(Oid relid)
Definition: namespace.c:854
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:2095
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2418
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:4499
TempNamespaceStatus checkTempNamespaceStatus(Oid namespaceId)
Definition: namespace.c:3670
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:3400
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3746
RangeVar * makeRangeVarFromNameList(const List *names)
Definition: namespace.c:3495
void InitializeSearchPath(void)
Definition: namespace.c:4685
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:1990
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2715
SearchPathMatcher * CopySearchPathMatcher(SearchPathMatcher *path)
Definition: namespace.c:3830
bool SearchPathMatchesCurrentEnvironment(SearchPathMatcher *path)
Definition: namespace.c:3852
Definition: namespace.h:45
Definition: namespace.h:48
Definition: namespace.h:46
Definition: namespace.h:47
Oid get_conversion_oid(List *conname, bool missing_ok)
Definition: namespace.c:3966
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1637
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2802
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2657
char * NameListToString(const List *names)
Definition: namespace.c:3535
void SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
Definition: namespace.c:3762
Oid GetTempToastNamespace(void)
Definition: namespace.c:3732
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:2164
struct _FuncCandidateList * FuncCandidateList
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:4453
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:3093
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1829
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:3296
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:936
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4798
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:382
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:3151
SearchPathMatcher * GetSearchPathMatcher(MemoryContext context)
Definition: namespace.c:3793
bool StatisticsObjIsVisible(Oid stxid)
Definition: namespace.c:2573
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:826
int GetTempNamespaceBackendId(Oid namespaceId)
Definition: namespace.c:3707
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2860
struct SearchPathMatcher SearchPathMatcher
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3602
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2948
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
Definition: pg_list.h:54
uint64 generation
Definition: namespace.h:63
struct _FuncCandidateList * next
Definition: namespace.h:30
Definition: namespace.h:38
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46