PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, 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 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 */
39 
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? */
49 
50 typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId,
51  Oid oldRelId, void *callback_arg);
52 
53 #define RangeVarGetRelid(relation, lockmode, missing_ok) \
54  RangeVarGetRelidExtended(relation, lockmode, missing_ok, false, NULL, NULL)
55 
56 extern Oid RangeVarGetRelidExtended(const RangeVar *relation,
57  LOCKMODE lockmode, bool missing_ok, bool nowait,
59  void *callback_arg);
60 extern Oid RangeVarGetCreationNamespace(const RangeVar *newRelation);
62  LOCKMODE lockmode,
63  Oid *existing_relation_id);
64 extern void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid);
65 extern Oid RelnameGetRelid(const char *relname);
66 extern bool RelationIsVisible(Oid relid);
67 
68 extern Oid TypenameGetTypid(const char *typname);
69 extern bool TypeIsVisible(Oid typid);
70 
72  int nargs, List *argnames,
73  bool expand_variadic,
74  bool expand_defaults,
75  bool missing_ok);
76 extern bool FunctionIsVisible(Oid funcid);
77 
78 extern Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright);
79 extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind,
80  bool missing_schema_ok);
81 extern bool OperatorIsVisible(Oid oprid);
82 
83 extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname);
84 extern bool OpclassIsVisible(Oid opcid);
85 
86 extern Oid OpfamilynameGetOpfid(Oid amid, const char *opfname);
87 extern bool OpfamilyIsVisible(Oid opfid);
88 
89 extern Oid CollationGetCollid(const char *collname);
90 extern bool CollationIsVisible(Oid collid);
91 
92 extern Oid ConversionGetConid(const char *conname);
93 extern bool ConversionIsVisible(Oid conid);
94 
95 extern Oid get_ts_parser_oid(List *names, bool missing_ok);
96 extern bool TSParserIsVisible(Oid prsId);
97 
98 extern Oid get_ts_dict_oid(List *names, bool missing_ok);
99 extern bool TSDictionaryIsVisible(Oid dictId);
100 
101 extern Oid get_ts_template_oid(List *names, bool missing_ok);
102 extern bool TSTemplateIsVisible(Oid tmplId);
103 
104 extern Oid get_ts_config_oid(List *names, bool missing_ok);
105 extern bool TSConfigIsVisible(Oid cfgid);
106 
107 extern void DeconstructQualifiedName(List *names,
108  char **nspname_p,
109  char **objname_p);
110 extern Oid LookupNamespaceNoError(const char *nspname);
111 extern Oid LookupExplicitNamespace(const char *nspname, bool missing_ok);
112 extern Oid get_namespace_oid(const char *nspname, bool missing_ok);
113 
114 extern Oid LookupCreationNamespace(const char *nspname);
115 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
116 extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p);
117 extern RangeVar *makeRangeVarFromNameList(List *names);
118 extern char *NameListToString(List *names);
119 extern char *NameListToQuotedString(List *names);
120 
121 extern bool isTempNamespace(Oid namespaceId);
122 extern bool isTempToastNamespace(Oid namespaceId);
123 extern bool isTempOrTempToastNamespace(Oid namespaceId);
124 extern bool isAnyTempNamespace(Oid namespaceId);
125 extern bool isOtherTempNamespace(Oid namespaceId);
126 extern int GetTempNamespaceBackendId(Oid namespaceId);
127 extern Oid GetTempToastNamespace(void);
128 extern void GetTempNamespaceState(Oid *tempNamespaceId,
129  Oid *tempToastNamespaceId);
130 extern void SetTempNamespaceState(Oid tempNamespaceId,
131  Oid tempToastNamespaceId);
132 extern void ResetTempTableNamespace(void);
133 
137 extern void PushOverrideSearchPath(OverrideSearchPath *newpath);
138 extern void PopOverrideSearchPath(void);
139 
140 extern Oid get_collation_oid(List *collname, bool missing_ok);
141 extern Oid get_conversion_oid(List *conname, bool missing_ok);
142 extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
143 
144 extern Oid get_statistics_oid(List *names, bool missing_ok);
145 
146 /* initialization & transaction cleanup code */
147 extern void InitializeSearchPath(void);
148 extern void AtEOXact_Namespace(bool isCommit, bool parallel);
149 extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
150  SubTransactionId parentSubid);
151 
152 /* stuff for search_path GUC variable */
153 extern char *namespace_search_path;
154 
155 extern List *fetch_search_path(bool includeImplicit);
156 extern int fetch_search_path_array(Oid *sarray, int sarray_len);
157 
158 #endif /* NAMESPACE_H */
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:1706
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:2587
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:507
int GetTempNamespaceBackendId(Oid namespaceId)
Definition: namespace.c:3085
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:1922
Oid GetTempToastNamespace(void)
Definition: namespace.c:3110
void PushOverrideSearchPath(OverrideSearchPath *newpath)
Definition: namespace.c:3283
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:1792
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:2743
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1373
int LOCKMODE
Definition: lockdefs.h:26
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3124
Oid oprid(Operator op)
Definition: parse_oper.c:245
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2276
void ResetTempTableNamespace(void)
Definition: namespace.c:3953
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2529
Oid get_statistics_oid(List *names, bool missing_ok)
Definition: namespace.c:2094
char * namespace_search_path
Definition: namespace.c:190
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:2461
void(* RangeVarGetRelidCallback)(const RangeVar *relation, Oid relId, Oid oldRelId, void *callback_arg)
Definition: namespace.h:50
uint32 SubTransactionId
Definition: c.h:401
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok, bool nowait, RangeVarGetRelidCallback callback, void *callback_arg)
Definition: namespace.c:217
unsigned int Oid
Definition: postgres_ext.h:31
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:2786
OverrideSearchPath * GetOverrideSearchPath(MemoryContext context)
Definition: namespace.c:3171
signed int int32
Definition: c.h:256
struct _FuncCandidateList * FuncCandidateList
struct OverrideSearchPath OverrideSearchPath
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:3508
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:653
Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p)
Definition: namespace.c:2846
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3032
Oid args[FLEXIBLE_ARRAY_MEMBER]
Definition: namespace.h:37
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3008
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3380
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:2713
void DeconstructQualifiedName(List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:2659
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:3453
char * NameListToQuotedString(List *names)
Definition: namespace.c:2987
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2047
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2015
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:3849
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:747
struct _FuncCandidateList * next
Definition: namespace.h:30
bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path)
Definition: namespace.c:3223
void InitializeSearchPath(void)
Definition: namespace.c:4016
OverrideSearchPath * CopyOverrideSearchPath(OverrideSearchPath *path)
Definition: namespace.c:3207
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2403
char * NameListToString(List *names)
Definition: namespace.c:2953
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:2895
void PopOverrideSearchPath(void)
Definition: namespace.c:3342
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3046
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:2913
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:1875
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2208
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:614
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1546
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2150
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:2818
bool RelationIsVisible(Oid relid)
Definition: namespace.c:681
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3020
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2334
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool missing_ok)
Definition: namespace.c:902
bool TypeIsVisible(Oid typid)
Definition: namespace.c:776
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:1759
void SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
Definition: namespace.c:3140
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4114
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:3794
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3069
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:420
bool CollationIsVisible(Oid collid)
Definition: namespace.c:1965
Definition: pg_list.h:45
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1444
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:1842
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4074