]> granicus.if.org Git - postgresql/blob - src/include/catalog/namespace.h
af82072edb7e90f243b0976337ae7d68fd2b9ce8
[postgresql] / src / include / catalog / namespace.h
1 /*-------------------------------------------------------------------------
2  *
3  * namespace.h
4  *        prototypes for functions in backend/catalog/namespace.c
5  *
6  *
7  * Portions Copyright (c) 1996-2013, 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 {
30         struct _FuncCandidateList *next;
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[1];                /* arg types --- VARIABLE LENGTH ARRAY */
38 }       *FuncCandidateList;     /* VARIABLE LENGTH STRUCT */
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? */
48 } OverrideSearchPath;
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,
58                                                  RangeVarGetRelidCallback callback,
59                                                  void *callback_arg);
60 extern Oid      RangeVarGetCreationNamespace(const RangeVar *newRelation);
61 extern Oid RangeVarGetAndCheckCreationNamespace(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
71 extern FuncCandidateList FuncnameGetCandidates(List *names,
72                                           int nargs, List *argnames,
73                                           bool expand_variadic,
74                                           bool expand_defaults);
75 extern bool FunctionIsVisible(Oid funcid);
76
77 extern Oid      OpernameGetOprid(List *names, Oid oprleft, Oid oprright);
78 extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind);
79 extern bool OperatorIsVisible(Oid oprid);
80
81 extern Oid      OpclassnameGetOpcid(Oid amid, const char *opcname);
82 extern bool OpclassIsVisible(Oid opcid);
83
84 extern Oid      OpfamilynameGetOpfid(Oid amid, const char *opfname);
85 extern bool OpfamilyIsVisible(Oid opfid);
86
87 extern Oid      CollationGetCollid(const char *collname);
88 extern bool CollationIsVisible(Oid collid);
89
90 extern Oid      ConversionGetConid(const char *conname);
91 extern bool ConversionIsVisible(Oid conid);
92
93 extern Oid      get_ts_parser_oid(List *names, bool missing_ok);
94 extern bool TSParserIsVisible(Oid prsId);
95
96 extern Oid      get_ts_dict_oid(List *names, bool missing_ok);
97 extern bool TSDictionaryIsVisible(Oid dictId);
98
99 extern Oid      get_ts_template_oid(List *names, bool missing_ok);
100 extern bool TSTemplateIsVisible(Oid tmplId);
101
102 extern Oid      get_ts_config_oid(List *names, bool missing_ok);
103 extern bool TSConfigIsVisible(Oid cfgid);
104
105 extern void DeconstructQualifiedName(List *names,
106                                                  char **nspname_p,
107                                                  char **objname_p);
108 extern Oid      LookupNamespaceNoError(const char *nspname);
109 extern Oid      LookupExplicitNamespace(const char *nspname);
110 extern Oid      get_namespace_oid(const char *nspname, bool missing_ok);
111
112 extern Oid      LookupCreationNamespace(const char *nspname);
113 extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid, Oid classid,
114                                   Oid objid);
115 extern Oid      QualifiedNameGetCreationNamespace(List *names, char **objname_p);
116 extern RangeVar *makeRangeVarFromNameList(List *names);
117 extern char *NameListToString(List *names);
118 extern char *NameListToQuotedString(List *names);
119
120 extern bool isTempNamespace(Oid namespaceId);
121 extern bool isTempToastNamespace(Oid namespaceId);
122 extern bool isTempOrToastNamespace(Oid namespaceId);
123 extern bool isAnyTempNamespace(Oid namespaceId);
124 extern bool isOtherTempNamespace(Oid namespaceId);
125 extern int      GetTempNamespaceBackendId(Oid namespaceId);
126 extern Oid      GetTempToastNamespace(void);
127 extern void ResetTempTableNamespace(void);
128
129 extern OverrideSearchPath *GetOverrideSearchPath(MemoryContext context);
130 extern OverrideSearchPath *CopyOverrideSearchPath(OverrideSearchPath *path);
131 extern void PushOverrideSearchPath(OverrideSearchPath *newpath);
132 extern void PopOverrideSearchPath(void);
133
134 extern Oid      get_collation_oid(List *collname, bool missing_ok);
135 extern Oid      get_conversion_oid(List *conname, bool missing_ok);
136 extern Oid      FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
137
138 /* initialization & transaction cleanup code */
139 extern void InitializeSearchPath(void);
140 extern void AtEOXact_Namespace(bool isCommit);
141 extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
142                                           SubTransactionId parentSubid);
143
144 /* stuff for search_path GUC variable */
145 extern char *namespace_search_path;
146
147 extern List *fetch_search_path(bool includeImplicit);
148 extern int      fetch_search_path_array(Oid *sarray, int sarray_len);
149
150 #endif   /* NAMESPACE_H */