Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*-------------------------------------------------------------------------
 *
 * namespace.h
 *    prototypes for functions in backend/catalog/namespace.c
 *
 *
 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/include/catalog/namespace.h
 *
 *-------------------------------------------------------------------------
 */
#ifndef NAMESPACE_H
#define NAMESPACE_H
 
#include "nodes/primnodes.h"
#include "storage/lockdefs.h"
#include "storage/procnumber.h"
 
 
/*
 *  This structure holds a list of possible functions or operators
 *  found by namespace lookup.  Each function/operator is identified
 *  by OID and by argument types; the list must be pruned by type
 *  resolution rules that are embodied in the parser, not here.
 *  See FuncnameGetCandidates's comments for more info.
 */
typedef struct _FuncCandidateList
{
    struct _FuncCandidateList *next;
    int         pathpos;        /* for internal use of namespace lookup */
    Oid         oid;            /* the function or operator's OID */
    int         nominalnargs;   /* either pronargs or length(proallargtypes) */
    int         nargs;          /* number of arg types returned */
    int         nvargs;         /* number of args to become variadic array */
    int         ndargs;         /* number of defaulted args */
    int        *argnumbers;     /* args' positional indexes, if named call */
    Oid         args[FLEXIBLE_ARRAY_MEMBER];    /* arg types */
}          *FuncCandidateList;
 
/*
 * FuncnameGetCandidates also returns a bitmask containing these flags,
 * which report on what it found or didn't find.  They can help callers
 * produce better error reports after a function lookup failure.
 */
#define FGC_SCHEMA_GIVEN    0x0001  /* Func name includes a schema */
#define FGC_SCHEMA_EXISTS   0x0002  /* Found the explicitly-specified schema */
#define FGC_NAME_EXISTS     0x0004  /* Found a routine by that name */
#define FGC_NAME_VISIBLE    0x0008  /* Found a routine name/schema match */
#define FGC_ARGCOUNT_MATCH  0x0010  /* Found a func with right # of args */
/* These bits relate only to calls using named or mixed arguments: */
#define FGC_ARGNAMES_MATCH  0x0020  /* Found a func matching all argnames */
#define FGC_ARGNAMES_NONDUP 0x0040  /* argnames don't overlap positional args */
#define FGC_ARGNAMES_ALL    0x0080  /* Found a func with no missing args */
#define FGC_ARGNAMES_VALID  0x0100  /* Found a fully-valid use of argnames */
/* These bits are actually filled by func_get_detail: */
#define FGC_VARIADIC_FAIL   0x0200  /* Disallowed VARIADIC with named args */
 
/*
 * Result of checkTempNamespaceStatus
 */
typedef enum TempNamespaceStatus
{
    TEMP_NAMESPACE_NOT_TEMP,    /* nonexistent, or non-temp namespace */
    TEMP_NAMESPACE_IDLE,        /* exists, belongs to no active session */
    TEMP_NAMESPACE_IN_USE,      /* belongs to some active session */
} TempNamespaceStatus;
 
/*
 *  Structure for xxxSearchPathMatcher functions
 *
 * The generation counter is private to namespace.c and shouldn't be touched
 * by other code.  It can be initialized to zero if necessary (that means
 * "not known equal to the current active path").
 */
typedef struct SearchPathMatcher
{
    List       *schemas;        /* OIDs of explicitly named schemas */
    bool        addCatalog;     /* implicitly prepend pg_catalog? */
    bool        addTemp;        /* implicitly prepend temp schema? */
    uint64      generation;     /* for quick detection of equality to active */
} SearchPathMatcher;
 
/*
 * Option flag bits for RangeVarGetRelidExtended().
 */
typedef enum RVROption
{
    RVR_MISSING_OK = 1 << 0,    /* don't error if relation doesn't exist */
    RVR_NOWAIT = 1 << 1,        /* error if relation cannot be locked */
    RVR_SKIP_LOCKED = 1 << 2,   /* skip if relation cannot be locked */
}           RVROption;
 
typedef void (*RangeVarGetRelidCallback) (const RangeVar *relation, Oid relId,
                                          Oid oldRelId, void *callback_arg);
 
#define RangeVarGetRelid(relation, lockmode, missing_ok) \
    RangeVarGetRelidExtended(relation, lockmode, \
                             (missing_ok) ? RVR_MISSING_OK : 0, NULL, NULL)
 
extern Oid  RangeVarGetRelidExtended(const RangeVar *relation,
                                     LOCKMODE lockmode, uint32 flags,
                                     RangeVarGetRelidCallback callback,
                                     void *callback_arg);
extern Oid  RangeVarGetCreationNamespace(const RangeVar *newRelation);
extern Oid  RangeVarGetAndCheckCreationNamespace(RangeVar *relation,
                                                 LOCKMODE lockmode,
                                                 Oid *existing_relation_id);
extern void RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid);
extern Oid  RelnameGetRelid(const char *relname);
extern bool RelationIsVisible(Oid relid);
 
extern Oid  TypenameGetTypid(const char *typname);
extern Oid  TypenameGetTypidExtended(const char *typname, bool temp_ok);
extern bool TypeIsVisible(Oid typid);
 
extern FuncCandidateList FuncnameGetCandidates(List *names,
                                               int nargs, List *argnames,
                                               bool expand_variadic,
                                               bool expand_defaults,
                                               bool include_out_arguments,
                                               bool missing_ok,
                                               int *fgc_flags);
extern bool FunctionIsVisible(Oid funcid);
 
extern Oid  OpernameGetOprid(List *names, Oid oprleft, Oid oprright);
extern FuncCandidateList OpernameGetCandidates(List *names, char oprkind,
                                               bool missing_schema_ok,
                                               int *fgc_flags);
extern bool OperatorIsVisible(Oid oprid);
 
extern Oid  OpclassnameGetOpcid(Oid amid, const char *opcname);
extern bool OpclassIsVisible(Oid opcid);
 
extern Oid  OpfamilynameGetOpfid(Oid amid, const char *opfname);
extern bool OpfamilyIsVisible(Oid opfid);
 
extern Oid  CollationGetCollid(const char *collname);
extern bool CollationIsVisible(Oid collid);
 
extern Oid  ConversionGetConid(const char *conname);
extern bool ConversionIsVisible(Oid conid);
 
extern Oid  get_statistics_object_oid(List *names, bool missing_ok);
extern bool StatisticsObjIsVisible(Oid stxid);
 
extern Oid  get_ts_parser_oid(List *names, bool missing_ok);
extern bool TSParserIsVisible(Oid prsId);
 
extern Oid  get_ts_dict_oid(List *names, bool missing_ok);
extern bool TSDictionaryIsVisible(Oid dictId);
 
extern Oid  get_ts_template_oid(List *names, bool missing_ok);
extern bool TSTemplateIsVisible(Oid tmplId);
 
extern Oid  get_ts_config_oid(List *names, bool missing_ok);
extern bool TSConfigIsVisible(Oid cfgid);
 
extern void DeconstructQualifiedName(const List *names,
                                     char **nspname_p,
                                     char **objname_p);
extern Oid  LookupNamespaceNoError(const char *nspname);
extern Oid  LookupExplicitNamespace(const char *nspname, bool missing_ok);
extern Oid  get_namespace_oid(const char *nspname, bool missing_ok);
 
extern Oid  LookupCreationNamespace(const char *nspname);
extern void CheckSetNamespace(Oid oldNspOid, Oid nspOid);
extern Oid  QualifiedNameGetCreationNamespace(const List *names, char **objname_p);
extern RangeVar *makeRangeVarFromNameList(const List *names);
extern char *NameListToString(const List *names);
extern char *NameListToQuotedString(const List *names);
 
extern bool isTempNamespace(Oid namespaceId);
extern bool isTempToastNamespace(Oid namespaceId);
extern bool isTempOrTempToastNamespace(Oid namespaceId);
extern bool isAnyTempNamespace(Oid namespaceId);
extern bool isOtherTempNamespace(Oid namespaceId);
extern TempNamespaceStatus checkTempNamespaceStatus(Oid namespaceId);
extern ProcNumber GetTempNamespaceProcNumber(Oid namespaceId);
extern Oid  GetTempToastNamespace(void);
extern void GetTempNamespaceState(Oid *tempNamespaceId,
                                  Oid *tempToastNamespaceId);
extern void SetTempNamespaceState(Oid tempNamespaceId,
                                  Oid tempToastNamespaceId);
extern void ResetTempTableNamespace(void);
 
extern SearchPathMatcher *GetSearchPathMatcher(MemoryContext context);
extern SearchPathMatcher *CopySearchPathMatcher(SearchPathMatcher *path);
extern bool SearchPathMatchesCurrentEnvironment(SearchPathMatcher *path);
 
extern Oid  get_collation_oid(List *collname, bool missing_ok);
extern Oid  get_conversion_oid(List *conname, bool missing_ok);
extern Oid  FindDefaultConversionProc(int32 for_encoding, int32 to_encoding);
 
 
/* initialization & transaction cleanup code */
extern void InitializeSearchPath(void);
extern void AtEOXact_Namespace(bool isCommit, bool parallel);
extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
                                  SubTransactionId parentSubid);
 
/* stuff for search_path GUC variable */
extern PGDLLIMPORT char *namespace_search_path;
 
extern List *fetch_search_path(bool includeImplicit);
extern int  fetch_search_path_array(Oid *sarray, int sarray_len);
 
#endif                          /* NAMESPACE_H */