PostgreSQL Source Code: src/backend/access/index/amvalidate.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
28
29
30
31
32
33
34
35
36
37
38
39
40
41
44{
49 int io,
50 ip;
51
52
54 elog(ERROR, "cannot validate operator family without ordered data");
55
56
57
58
59
60
61 thisgroup = NULL;
62 io = ip = 0;
63 if (io < oprlist->n_members)
64 {
66 io++;
67 }
68 else
69 oprform = NULL;
70 if (ip < proclist->n_members)
71 {
73 ip++;
74 }
75 else
76 procform = NULL;
77
78 while (oprform || procform)
79 {
80 if (oprform && thisgroup &&
81 oprform->amoplefttype == thisgroup->lefttype &&
82 oprform->amoprighttype == thisgroup->righttype)
83 {
84
85
86
87 if (oprform->amopstrategy > 0 && oprform->amopstrategy < 64)
89
90 if (io < oprlist->n_members)
91 {
93 io++;
94 }
95 else
96 oprform = NULL;
97 continue;
98 }
99
100 if (procform && thisgroup &&
101 procform->amproclefttype == thisgroup->lefttype &&
102 procform->amprocrighttype == thisgroup->righttype)
103 {
104
105
106
107 if (procform->amprocnum > 0 && procform->amprocnum < 64)
109
110 if (ip < proclist->n_members)
111 {
113 ip++;
114 }
115 else
116 procform = NULL;
117 continue;
118 }
119
120
122 if (oprform &&
123 (!procform ||
124 (oprform->amoplefttype < procform->amproclefttype ||
125 (oprform->amoplefttype == procform->amproclefttype &&
126 oprform->amoprighttype < procform->amprocrighttype))))
127 {
128 thisgroup->lefttype = oprform->amoplefttype;
129 thisgroup->righttype = oprform->amoprighttype;
130 }
131 else
132 {
133 thisgroup->lefttype = procform->amproclefttype;
134 thisgroup->righttype = procform->amprocrighttype;
135 }
137 result = lappend(result, thisgroup);
138 }
139
140 return result;
141}
142
143
144
145
146
147
148
149
150
151bool
153 int minargs, int maxargs,...)
154{
155 bool result = true;
158 va_list ap;
159 int i;
160
163 elog(ERROR, "cache lookup failed for function %u", funcid);
165
166 if (procform->prorettype != restype || procform->proretset ||
167 procform->pronargs < minargs || procform->pronargs > maxargs)
168 result = false;
169
170 va_start(ap, maxargs);
171 for (i = 0; i < maxargs; i++)
172 {
173 Oid argtype = va_arg(ap, Oid);
174
175 if (i >= procform->pronargs)
176 continue;
177 if (exact ? (argtype != procform->proargtypes.values[i]) :
179 result = false;
180 }
181 va_end(ap);
182
184 return result;
185}
186
187
188
189
190
191bool
193{
195}
196
197
198
199
200
201
202
203
204
205bool
207{
208 bool result = true;
211
214 elog(ERROR, "cache lookup failed for operator %u", opno);
216
217 if (opform->oprresult != restype || opform->oprkind != 'b' ||
218 opform->oprleft != lefttype || opform->oprright != righttype)
219 result = false;
220
222 return result;
223}
224
225
226
227
228
229
230
231
232
233
234
237{
240 int i;
241
242
243
244
245
246
248
250 {
253
254 if (classform->opcfamily == opfamilyoid &&
255 classform->opcintype == datatypeoid)
256 {
257 result = classform->oid;
258 break;
259 }
260 }
261
263
264 return result;
265}
266
267
268
269
270bool
272{
274 opfamilyoid,
275 datatypeoid));
276}
Oid opclass_for_family_datatype(Oid amoid, Oid opfamilyoid, Oid datatypeoid)
bool check_amproc_signature(Oid funcid, Oid restype, bool exact, int minargs, int maxargs,...)
bool check_amop_signature(Oid opno, Oid restype, Oid lefttype, Oid righttype)
List * identify_opfamily_groups(CatCList *oprlist, CatCList *proclist)
bool opfamily_can_sort_type(Oid opfamilyoid, Oid datatypeoid)
bool check_amoptsproc_signature(Oid funcid)
#define OidIsValid(objectId)
void ReleaseCatCacheList(CatCList *list)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
List * lappend(List *list, void *datum)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
FormData_pg_amop * Form_pg_amop
FormData_pg_amproc * Form_pg_amproc
FormData_pg_opclass * Form_pg_opclass
FormData_pg_operator * Form_pg_operator
FormData_pg_proc * Form_pg_proc
static Datum ObjectIdGetDatum(Oid X)
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define SearchSysCacheList1(cacheId, key1)