40{
41 bool result = true;
47 char *opclassname;
50 char *opfamilyname;
52 *oprlist;
62
63
66 elog(
ERROR,
"cache lookup failed for operator class %u", opclassoid);
68
69 opfamilyoid = classform->opcfamily;
70 opcintype = classform->opcintype;
71 opckeytype = classform->opckeytype;
72 opclassname =
NameStr(classform->opcname);
73
74
77 elog(
ERROR,
"cache lookup failed for operator family %u", opfamilyoid);
79
80 opfamilyname =
NameStr(familyform->opfname);
81
82
86
87
89 {
92 bool ok;
93
94
95
96
97
98 if (procform->amproclefttype != procform->amprocrighttype)
99 {
101 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
102 errmsg(
"operator family \"%s\" of access method %s contains support function %s with different left and right input types",
103 opfamilyname, "spgist",
105 result = false;
106 }
107
108
109 switch (procform->amprocnum)
110 {
113 2, 2, INTERNALOID, INTERNALOID);
114 configIn.
attType = procform->amproclefttype;
115 memset(&configOut, 0, sizeof(configOut));
116
120
121 configOutLefttype = procform->amproclefttype;
122 configOutRighttype = procform->amprocrighttype;
123
124
126 configOutLeafType = opckeytype;
127 else
128 configOutLeafType = procform->amproclefttype;
129
130
132 configOutLeafType != configOut.
leafType)
133 {
135 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
136 errmsg(
"SP-GiST leaf data type %s does not match declared type %s",
139 result = false;
140 configOutLeafType = configOut.
leafType;
141 }
142
143
144
145
146
147
148 if (configOutLeafType == configIn.
attType)
149 {
150 foreach(lc, grouplist)
151 {
153
154 if (group->
lefttype == procform->amproclefttype &&
155 group->
righttype == procform->amprocrighttype)
156 {
159 break;
160 }
161 }
162 }
163 break;
168 2, 2, INTERNALOID, INTERNALOID);
169 break;
172 2, 2, INTERNALOID, INTERNALOID);
173 break;
175 if (configOutLefttype != procform->amproclefttype ||
176 configOutRighttype != procform->amprocrighttype)
177 ok = false;
178 else
180 configOutLeafType, true,
181 1, 1, procform->amproclefttype);
182 break;
185 break;
186 default:
188 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
189 errmsg(
"operator family \"%s\" of access method %s contains function %s with invalid support number %d",
190 opfamilyname, "spgist",
192 procform->amprocnum)));
193 result = false;
194 continue;
195 }
196
197 if (!ok)
198 {
200 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
201 errmsg(
"operator family \"%s\" of access method %s contains function %s with wrong signature for support number %d",
202 opfamilyname, "spgist",
204 procform->amprocnum)));
205 result = false;
206 }
207 }
208
209
211 {
215
216
217 if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63)
218 {
220 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
221 errmsg(
"operator family \"%s\" of access method %s contains operator %s with invalid strategy number %d",
222 opfamilyname, "spgist",
224 oprform->amopstrategy)));
225 result = false;
226 }
227
228
229 if (oprform->amoppurpose != AMOP_SEARCH)
230 {
231
234 {
236 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
237 errmsg(
"operator family \"%s\" of access method %s contains invalid ORDER BY specification for operator %s",
238 opfamilyname, "spgist",
240 result = false;
241 }
242 }
243 else
244 op_rettype = BOOLOID;
245
246
248 oprform->amoplefttype,
249 oprform->amoprighttype))
250 {
252 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
253 errmsg(
"operator family \"%s\" of access method %s contains operator %s with wrong signature",
254 opfamilyname, "spgist",
256 result = false;
257 }
258 }
259
260
261 opclassgroup = NULL;
262 foreach(lc, grouplist)
263 {
265
266
267 if (thisgroup->
lefttype == opcintype &&
269 opclassgroup = thisgroup;
270
271
272
273
274
275
277 {
279 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
280 errmsg(
"operator family \"%s\" of access method %s is missing operator(s) for types %s and %s",
281 opfamilyname, "spgist",
284 result = false;
285 }
286
287
288
289
290
292 continue;
293
295 {
297 continue;
299 continue;
301 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
302 errmsg(
"operator family \"%s\" of access method %s is missing support function %d for type %s",
303 opfamilyname,
"spgist",
i,
305 result = false;
306 }
307 }
308
309
310
311 if (!opclassgroup)
312 {
314 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
315 errmsg(
"operator class \"%s\" of access method %s is missing operator(s)",
316 opclassname, "spgist")));
317 result = false;
318 }
319
324
325 return result;
326}
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 OidFunctionCall2(functionId, arg1, arg2)
#define HeapTupleIsValid(tuple)
Oid get_op_rettype(Oid opno)
FormData_pg_amop * Form_pg_amop
FormData_pg_amproc * Form_pg_amproc
FormData_pg_opclass * Form_pg_opclass
FormData_pg_opfamily * Form_pg_opfamily
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
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)