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-2019, 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 nargs; /* number of arg types returned */
34  int nvargs; /* number of args to become variadic array */
35  int ndargs; /* number of defaulted args */
36  int *argnumbers; /* args' positional indexes, if named call */
37  Oid args[FLEXIBLE_ARRAY_MEMBER]; /* arg types */
40 /*
41  * Structure for xxxOverrideSearchPath functions
42  */
43 typedef struct OverrideSearchPath
44 {
45  List *schemas; /* OIDs of explicitly named schemas */
46  bool addCatalog; /* implicitly prepend pg_catalog? */
47  bool addTemp; /* implicitly prepend temp schema? */
50 /*
51  * Option flag bits for RangeVarGetRelidExtended().
52  */
53 typedef enum RVROption
54 {
55  RVR_MISSING_OK = 1 << 0, /* don't error if relation doesn't exist */
56  RVR_NOWAIT = 1 << 1, /* error if relation cannot be locked */
57  RVR_SKIP_LOCKED = 1 << 2 /* skip if relation cannot be locked */
58 } RVROption;
60 typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId,
61  Oid oldRelId, void *callback_arg);
63 #define RangeVarGetRelid(relation, lockmode, missing_ok) \
64  RangeVarGetRelidExtended(relation, lockmode, \
65  (missing_ok) ? RVR_MISSING_OK : 0, NULL, NULL)
67 extern Oid RangeVarGetRelidExtended(const RangeVar *relation,
68  LOCKMODE lockmode, uint32 flags,
70  void *callback_arg);
71 extern Oid RangeVarGetCreationNamespace(const RangeVar *newRelation);
73  LOCKMODE lockmode,
74  Oid *existing_relation_id);
75 extern void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid);
76 extern Oid RelnameGetRelid(const char *relname);
77 extern bool RelationIsVisible(Oid relid);
79 extern Oid TypenameGetTypid(const char *typname);
80 extern bool TypeIsVisible(Oid typid);
83  int nargs, List *argnames,
84  bool expand_variadic,
85  bool expand_defaults,
86  bool missing_ok);
87 extern bool FunctionIsVisible(Oid funcid);
89 extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright);
90 extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind,
91  bool missing_schema_ok);
92 extern bool OperatorIsVisible(Oid oprid);
94 extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname);
95 extern bool OpclassIsVisible(Oid opcid);
97 extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname);
98 extern bool OpfamilyIsVisible(Oid opfid);
100 extern Oid CollationGetCollid(const char *collname);
101 extern bool CollationIsVisible(Oid collid);
103 extern Oid ConversionGetConid(const char *conname);
104 extern bool ConversionIsVisible(Oid conid);
106 extern Oid get_statistics_object_oid(List *names, bool missing_ok);
107 extern bool StatisticsObjIsVisible(Oid stxid);
109 extern Oid get_ts_parser_oid(List *names, bool missing_ok);
110 extern bool TSParserIsVisible(Oid prsId);
112 extern Oid get_ts_dict_oid(List *names, bool missing_ok);
113 extern bool TSDictionaryIsVisible(Oid dictId);
115 extern Oid get_ts_template_oid(List *names, bool missing_ok);
116 extern bool TSTemplateIsVisible(Oid tmplId);
118 extern Oid get_ts_config_oid(List *names, bool missing_ok);
119 extern bool TSConfigIsVisible(Oid cfgid);
121 extern void DeconstructQualifiedName(List *names,
122  char **nspname_p,
123  char **objname_p);
124 extern Oid LookupNamespaceNoError(const char *nspname);
125 extern Oid LookupExplicitNamespace(const char *nspname, bool missing_ok);
126 extern Oid get_namespace_oid(const char *nspname, bool missing_ok);
128 extern Oid LookupCreationNamespace(const char *nspname);
129 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
130 extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p);
131 extern RangeVar *makeRangeVarFromNameList(List *names);
132 extern char *NameListToString(List *names);
133 extern char *NameListToQuotedString(List *names);
135 extern bool isTempNamespace(Oid namespaceId);
136 extern bool isTempToastNamespace(Oid namespaceId);
137 extern bool isTempOrTempToastNamespace(Oid namespaceId);
138 extern bool isAnyTempNamespace(Oid namespaceId);
139 extern bool isOtherTempNamespace(Oid namespaceId);
140 extern bool isTempNamespaceInUse(Oid namespaceId);
141 extern int GetTempNamespaceBackendId(Oid namespaceId);
142 extern Oid GetTempToastNamespace(void);
143 extern void GetTempNamespaceState(Oid *tempNamespaceId,
144  Oid *tempToastNamespaceId);
145 extern void SetTempNamespaceState(Oid tempNamespaceId,
146  Oid tempToastNamespaceId);
147 extern void ResetTempTableNamespace(void);
152 extern void PushOverrideSearchPath(OverrideSearchPath *newpath);
153 extern void PopOverrideSearchPath(void);
155 extern Oid get_collation_oid(List *collname, bool missing_ok);
156 extern Oid get_conversion_oid(List *conname, bool missing_ok);
157 extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
160 /* initialization & transaction cleanup code */
161 extern void InitializeSearchPath(void);
162 extern void AtEOXact_Namespace(bool isCommit, bool parallel);
163 extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
164  SubTransactionId parentSubid);
166 /* stuff for search_path GUC variable */
167 extern char *namespace_search_path;
169 extern List *fetch_search_path(bool includeImplicit);
170 extern int fetch_search_path_array(Oid *sarray, int sarray_len);
172 #endif /* NAMESPACE_H */
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:1726
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:2716
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:526
int GetTempNamespaceBackendId(Oid namespaceId)
Definition: namespace.c:3253
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:1993
Oid GetTempToastNamespace(void)
Definition: namespace.c:3278
bool isTempNamespaceInUse(Oid namespaceId)
Definition: namespace.c:3216
void PushOverrideSearchPath(OverrideSearchPath *newpath)
Definition: namespace.c:3451
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:1812
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:2872
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1392
Definition: lockdefs.h:26
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3292
Oid oprid(Operator op)
Definition: parse_oper.c:245
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2405
void ResetTempTableNamespace(void)
Definition: namespace.c:4171
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2658
char * namespace_search_path
Definition: namespace.c:190
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:2590
uint32 SubTransactionId
Definition: c.h:511
NameData relname
Definition: pg_class.h:35
unsigned int Oid
Definition: postgres_ext.h:31
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:2915
OverrideSearchPath * GetOverrideSearchPath(MemoryContext context)
Definition: namespace.c:3339
signed int int32
Definition: c.h:346
struct OverrideSearchPath OverrideSearchPath
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:3660
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:672
Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p)
Definition: namespace.c:2974
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3160
Definition: namespace.h:37
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3136
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3551
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:2842
void DeconstructQualifiedName(List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:2788
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:3605
char * NameListToQuotedString(List *names)
Definition: namespace.c:3115
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2110
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2078
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:4056
unsigned int uint32
Definition: c.h:358
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:766
struct _FuncCandidateList * next
Definition: namespace.h:30
bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path)
Definition: namespace.c:3391
void InitializeSearchPath(void)
Definition: namespace.c:4234
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2157
OverrideSearchPath * CopyOverrideSearchPath(OverrideSearchPath *path)
Definition: namespace.c:3375
NameData typname
Definition: pg_type.h:42
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2532
Definition: namespace.h:53
char * NameListToString(List *names)
Definition: namespace.c:3081
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3022
void PopOverrideSearchPath(void)
Definition: namespace.c:3510
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3174
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:3041
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:1895
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2337
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:633
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1566
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:228
bool StatisticsObjIsVisible(Oid stxid)
Definition: namespace.c:2214
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2279
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:2946
bool RelationIsVisible(Oid relid)
Definition: namespace.c:700
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3148
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2463
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool missing_ok)
Definition: namespace.c:921
bool TypeIsVisible(Oid typid)
Definition: namespace.c:795
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:1779
void(* RangeVarGetRelidCallback)(const RangeVar *relation, Oid relId, Oid oldRelId, void *callback_arg)
Definition: namespace.h:60
void SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
Definition: namespace.c:3308
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4332
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:3990
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3197
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:441
bool CollationIsVisible(Oid collid)
Definition: namespace.c:2027
Definition: pg_list.h:50
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1463
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:1862
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4292