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_statistics_object_oid(List *names, bool missing_ok);
96 extern bool StatisticsObjIsVisible(Oid stxid);
97 
98 extern Oid get_ts_parser_oid(List *names, bool missing_ok);
99 extern bool TSParserIsVisible(Oid prsId);
100 
101 extern Oid get_ts_dict_oid(List *names, bool missing_ok);
102 extern bool TSDictionaryIsVisible(Oid dictId);
103 
104 extern Oid get_ts_template_oid(List *names, bool missing_ok);
105 extern bool TSTemplateIsVisible(Oid tmplId);
106 
107 extern Oid get_ts_config_oid(List *names, bool missing_ok);
108 extern bool TSConfigIsVisible(Oid cfgid);
109 
110 extern void DeconstructQualifiedName(List *names,
111  char **nspname_p,
112  char **objname_p);
113 extern Oid LookupNamespaceNoError(const char *nspname);
114 extern Oid LookupExplicitNamespace(const char *nspname, bool missing_ok);
115 extern Oid get_namespace_oid(const char *nspname, bool missing_ok);
116 
117 extern Oid LookupCreationNamespace(const char *nspname);
118 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
119 extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p);
120 extern RangeVar *makeRangeVarFromNameList(List *names);
121 extern char *NameListToString(List *names);
122 extern char *NameListToQuotedString(List *names);
123 
124 extern bool isTempNamespace(Oid namespaceId);
125 extern bool isTempToastNamespace(Oid namespaceId);
126 extern bool isTempOrTempToastNamespace(Oid namespaceId);
127 extern bool isAnyTempNamespace(Oid namespaceId);
128 extern bool isOtherTempNamespace(Oid namespaceId);
129 extern int GetTempNamespaceBackendId(Oid namespaceId);
130 extern Oid GetTempToastNamespace(void);
131 extern void GetTempNamespaceState(Oid *tempNamespaceId,
132  Oid *tempToastNamespaceId);
133 extern void SetTempNamespaceState(Oid tempNamespaceId,
134  Oid tempToastNamespaceId);
135 extern void ResetTempTableNamespace(void);
136 
140 extern void PushOverrideSearchPath(OverrideSearchPath *newpath);
141 extern void PopOverrideSearchPath(void);
142 
143 extern Oid get_collation_oid(List *collname, bool missing_ok);
144 extern Oid get_conversion_oid(List *conname, bool missing_ok);
145 extern Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
146 
147 
148 /* initialization & transaction cleanup code */
149 extern void InitializeSearchPath(void);
150 extern void AtEOXact_Namespace(bool isCommit, bool parallel);
151 extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
152  SubTransactionId parentSubid);
153 
154 /* stuff for search_path GUC variable */
155 extern char *namespace_search_path;
156 
157 extern List *fetch_search_path(bool includeImplicit);
158 extern int fetch_search_path_array(Oid *sarray, int sarray_len);
159 
160 #endif /* NAMESPACE_H */
bool OperatorIsVisible(Oid oprid)
Definition: namespace.c:1707
bool TSConfigIsVisible(Oid cfgid)
Definition: namespace.c:2654
Oid RangeVarGetAndCheckCreationNamespace(RangeVar *newRelation, LOCKMODE lockmode, Oid *existing_relation_id)
Definition: namespace.c:508
int GetTempNamespaceBackendId(Oid namespaceId)
Definition: namespace.c:3152
Oid CollationGetCollid(const char *collname)
Definition: namespace.c:1923
Oid GetTempToastNamespace(void)
Definition: namespace.c:3177
void PushOverrideSearchPath(OverrideSearchPath *newpath)
Definition: namespace.c:3350
bool OpclassIsVisible(Oid opcid)
Definition: namespace.c:1793
Oid LookupExplicitNamespace(const char *nspname, bool missing_ok)
Definition: namespace.c:2810
bool FunctionIsVisible(Oid funcid)
Definition: namespace.c:1374
int LOCKMODE
Definition: lockdefs.h:26
void GetTempNamespaceState(Oid *tempNamespaceId, Oid *tempToastNamespaceId)
Definition: namespace.c:3191
Oid oprid(Operator op)
Definition: parse_oper.c:245
Oid get_ts_dict_oid(List *names, bool missing_ok)
Definition: namespace.c:2343
void ResetTempTableNamespace(void)
Definition: namespace.c:4020
Oid get_ts_config_oid(List *names, bool missing_ok)
Definition: namespace.c:2596
char * namespace_search_path
Definition: namespace.c:191
bool TSTemplateIsVisible(Oid tmplId)
Definition: namespace.c:2528
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:218
unsigned int Oid
Definition: postgres_ext.h:31
Oid LookupCreationNamespace(const char *nspname)
Definition: namespace.c:2853
OverrideSearchPath * GetOverrideSearchPath(MemoryContext context)
Definition: namespace.c:3238
signed int int32
Definition: c.h:256
struct _FuncCandidateList * FuncCandidateList
struct OverrideSearchPath OverrideSearchPath
Oid FindDefaultConversionProc(int32 for_encoding, int32 to_encoding)
Definition: namespace.c:3575
Oid RelnameGetRelid(const char *relname)
Definition: namespace.c:654
Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p)
Definition: namespace.c:2913
bool isTempOrTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3099
Oid args[FLEXIBLE_ARRAY_MEMBER]
Definition: namespace.h:37
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3075
Oid get_collation_oid(List *collname, bool missing_ok)
Definition: namespace.c:3447
Oid LookupNamespaceNoError(const char *nspname)
Definition: namespace.c:2780
void DeconstructQualifiedName(List *names, char **nspname_p, char **objname_p)
Definition: namespace.c:2726
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:3520
char * NameListToQuotedString(List *names)
Definition: namespace.c:3054
bool ConversionIsVisible(Oid conid)
Definition: namespace.c:2048
Oid ConversionGetConid(const char *conname)
Definition: namespace.c:2016
void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, SubTransactionId parentSubid)
Definition: namespace.c:3916
Oid TypenameGetTypid(const char *typname)
Definition: namespace.c:748
struct _FuncCandidateList * next
Definition: namespace.h:30
bool OverrideSearchPathMatchesCurrent(OverrideSearchPath *path)
Definition: namespace.c:3290
void InitializeSearchPath(void)
Definition: namespace.c:4083
Oid get_statistics_object_oid(List *names, bool missing_ok)
Definition: namespace.c:2095
OverrideSearchPath * CopyOverrideSearchPath(OverrideSearchPath *path)
Definition: namespace.c:3274
Oid get_ts_template_oid(List *names, bool missing_ok)
Definition: namespace.c:2470
char * NameListToString(List *names)
Definition: namespace.c:3020
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:2962
void PopOverrideSearchPath(void)
Definition: namespace.c:3409
bool isAnyTempNamespace(Oid namespaceId)
Definition: namespace.c:3113
RangeVar * makeRangeVarFromNameList(List *names)
Definition: namespace.c:2980
bool OpfamilyIsVisible(Oid opfid)
Definition: namespace.c:1876
bool TSParserIsVisible(Oid prsId)
Definition: namespace.c:2275
void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
Definition: namespace.c:615
FuncCandidateList OpernameGetCandidates(List *names, char oprkind, bool missing_schema_ok)
Definition: namespace.c:1547
bool StatisticsObjIsVisible(Oid stxid)
Definition: namespace.c:2152
Oid get_ts_parser_oid(List *names, bool missing_ok)
Definition: namespace.c:2217
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
Definition: namespace.c:2885
bool RelationIsVisible(Oid relid)
Definition: namespace.c:682
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3087
bool TSDictionaryIsVisible(Oid dictId)
Definition: namespace.c:2401
FuncCandidateList FuncnameGetCandidates(List *names, int nargs, List *argnames, bool expand_variadic, bool expand_defaults, bool missing_ok)
Definition: namespace.c:903
bool TypeIsVisible(Oid typid)
Definition: namespace.c:777
Oid OpclassnameGetOpcid(Oid amid, const char *opcname)
Definition: namespace.c:1760
void SetTempNamespaceState(Oid tempNamespaceId, Oid tempToastNamespaceId)
Definition: namespace.c:3207
int fetch_search_path_array(Oid *sarray, int sarray_len)
Definition: namespace.c:4181
void AtEOXact_Namespace(bool isCommit, bool parallel)
Definition: namespace.c:3861
bool isOtherTempNamespace(Oid namespaceId)
Definition: namespace.c:3136
Oid RangeVarGetCreationNamespace(const RangeVar *newRelation)
Definition: namespace.c:421
bool CollationIsVisible(Oid collid)
Definition: namespace.c:1966
Definition: pg_list.h:45
Oid OpernameGetOprid(List *names, Oid oprleft, Oid oprright)
Definition: namespace.c:1445
Oid OpfamilynameGetOpfid(Oid amid, const char *opfname)
Definition: namespace.c:1843
List * fetch_search_path(bool includeImplicit)
Definition: namespace.c:4141