PostgreSQL Source Code: src/backend/access/gin/ginvalidate.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
15
26
27
28
29
30bool
32{
33 bool result = true;
36 Oid opfamilyoid;
37 Oid opcintype;
38 Oid opckeytype;
39 char *opclassname;
40 char *opfamilyname;
42 *oprlist;
43 List *grouplist;
45 int i;
47
48
51 elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
53
54 opfamilyoid = classform->opcfamily;
55 opcintype = classform->opcintype;
56 opckeytype = classform->opckeytype;
58 opckeytype = opcintype;
59 opclassname = NameStr(classform->opcname);
60
61
63
64
67
68
70 {
73 bool ok;
74
75
76
77
78
79 if (procform->amproclefttype != procform->amprocrighttype)
80 {
82 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
83 errmsg("operator family \"%s\" of access method %s contains support function %s with different left and right input types",
84 opfamilyname, "gin",
86 result = false;
87 }
88
89
90
91
92
93 if (procform->amproclefttype != opcintype)
94 continue;
95
96
97 switch (procform->amprocnum)
98 {
101 2, 2, opckeytype, opckeytype);
102 break;
104
106 2, 3, opcintype, INTERNALOID,
107 INTERNALOID);
108 break;
110
112 5, 7, opcintype, INTERNALOID,
113 INT2OID, INTERNALOID, INTERNALOID,
114 INTERNALOID, INTERNALOID);
115 break;
117
119 6, 8, INTERNALOID, INT2OID,
120 opcintype, INT4OID,
121 INTERNALOID, INTERNALOID,
122 INTERNALOID, INTERNALOID);
123 break;
126 4, 4, opckeytype, opckeytype,
127 INT2OID, INTERNALOID);
128 break;
131 7, 7, INTERNALOID, INT2OID,
132 opcintype, INT4OID,
133 INTERNALOID, INTERNALOID,
134 INTERNALOID);
135 break;
138 break;
139 default:
141 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
142 errmsg("operator family \"%s\" of access method %s contains function %s with invalid support number %d",
143 opfamilyname, "gin",
145 procform->amprocnum)));
146 result = false;
147 continue;
148 }
149
150 if (!ok)
151 {
153 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
154 errmsg("operator family \"%s\" of access method %s contains function %s with wrong signature for support number %d",
155 opfamilyname, "gin",
157 procform->amprocnum)));
158 result = false;
159 }
160 }
161
162
164 {
167
168
169 if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63)
170 {
172 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
173 errmsg("operator family \"%s\" of access method %s contains operator %s with invalid strategy number %d",
174 opfamilyname, "gin",
176 oprform->amopstrategy)));
177 result = false;
178 }
179
180
181 if (oprform->amoppurpose != AMOP_SEARCH ||
183 {
185 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
186 errmsg("operator family \"%s\" of access method %s contains invalid ORDER BY specification for operator %s",
187 opfamilyname, "gin",
189 result = false;
190 }
191
192
194 oprform->amoplefttype,
195 oprform->amoprighttype))
196 {
198 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
199 errmsg("operator family \"%s\" of access method %s contains operator %s with wrong signature",
200 opfamilyname, "gin",
202 result = false;
203 }
204 }
205
206
208 opclassgroup = NULL;
209 foreach(lc, grouplist)
210 {
212
213
214 if (thisgroup->lefttype == opcintype &&
215 thisgroup->righttype == opcintype)
216 opclassgroup = thisgroup;
217
218
219
220
221
222
223
224
225
226 }
227
228
230 {
231 if (opclassgroup &&
233 continue;
236 continue;
238 continue;
240 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
241 errmsg("operator class \"%s\" of access method %s is missing support function %d",
242 opclassname, "gin", i)));
243 result = false;
244 }
245 if (!opclassgroup ||
248 {
250 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
251 errmsg("operator class \"%s\" of access method %s is missing support function %d or %d",
252 opclassname, "gin",
254 result = false;
255 }
256
257
261
262 return result;
263}
264
265
266
267
268void
270 Oid opclassoid,
271 List *operators,
273{
275
276
277
278
279
280
281
282
283 foreach(lc, operators)
284 {
286
290 }
291
292
293
294
295
296
297
298
300 {
302
304 {
307
309 break;
315
319 break;
320 default:
322 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
323 errmsg("support function number %d is invalid for access method %s",
324 op->number, "gin")));
325 break;
326 }
327 }
328}
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 check_amoptsproc_signature(Oid funcid)
#define OidIsValid(objectId)
void ReleaseCatCacheList(CatCList *list)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define GIN_CONSISTENT_PROC
#define GIN_EXTRACTQUERY_PROC
#define GIN_EXTRACTVALUE_PROC
#define GIN_TRICONSISTENT_PROC
#define GIN_COMPARE_PARTIAL_PROC
bool ginvalidate(Oid opclassoid)
void ginadjustmembers(Oid opfamilyoid, Oid opclassoid, List *operators, List *functions)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
char * get_opfamily_name(Oid opfid, bool missing_ok)
FormData_pg_amop * Form_pg_amop
FormData_pg_amproc * Form_pg_amproc
FormData_pg_opclass * Form_pg_opclass
static Datum ObjectIdGetDatum(Oid X)
static const struct fns functions
char * format_procedure(Oid procedure_oid)
char * format_operator(Oid operator_oid)
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define SearchSysCacheList1(cacheId, key1)