39{
40 bool result = true;
46 char *opclassname;
47 char *opfamilyname;
49 *oprlist;
59
60
63 elog(
ERROR,
"cache lookup failed for operator class %u", opclassoid);
65
66 opfamilyoid = classform->opcfamily;
67 opcintype = classform->opcintype;
68 opckeytype = classform->opckeytype;
69 opclassname =
NameStr(classform->opcname);
70
71
73
74
78
79
81 {
84 bool ok;
85
86
87
88
89
90 if (procform->amproclefttype != procform->amprocrighttype)
91 {
93 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
94 errmsg(
"operator family \"%s\" of access method %s contains support function %s with different left and right input types",
95 opfamilyname, "spgist",
97 result = false;
98 }
99
100
101 switch (procform->amprocnum)
102 {
105 2, 2, INTERNALOID, INTERNALOID);
106 configIn.
attType = procform->amproclefttype;
107 memset(&configOut, 0, sizeof(configOut));
108
112
113 configOutLefttype = procform->amproclefttype;
114 configOutRighttype = procform->amprocrighttype;
115
116
118 configOutLeafType = opckeytype;
119 else
120 configOutLeafType = procform->amproclefttype;
121
122
124 configOutLeafType != configOut.
leafType)
125 {
127 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
128 errmsg(
"SP-GiST leaf data type %s does not match declared type %s",
131 result = false;
132 configOutLeafType = configOut.
leafType;
133 }
134
135
136
137
138
139
140 if (configOutLeafType == configIn.
attType)
141 {
142 foreach(lc, grouplist)
143 {
145
146 if (group->
lefttype == procform->amproclefttype &&
147 group->
righttype == procform->amprocrighttype)
148 {
151 break;
152 }
153 }
154 }
155 break;
160 2, 2, INTERNALOID, INTERNALOID);
161 break;
164 2, 2, INTERNALOID, INTERNALOID);
165 break;
167 if (configOutLefttype != procform->amproclefttype ||
168 configOutRighttype != procform->amprocrighttype)
169 ok = false;
170 else
172 configOutLeafType, true,
173 1, 1, procform->amproclefttype);
174 break;
177 break;
178 default:
180 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
181 errmsg(
"operator family \"%s\" of access method %s contains function %s with invalid support number %d",
182 opfamilyname, "spgist",
184 procform->amprocnum)));
185 result = false;
186 continue;
187 }
188
189 if (!ok)
190 {
192 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
193 errmsg(
"operator family \"%s\" of access method %s contains function %s with wrong signature for support number %d",
194 opfamilyname, "spgist",
196 procform->amprocnum)));
197 result = false;
198 }
199 }
200
201
203 {
207
208
209 if (oprform->amopstrategy < 1 || oprform->amopstrategy > 63)
210 {
212 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
213 errmsg(
"operator family \"%s\" of access method %s contains operator %s with invalid strategy number %d",
214 opfamilyname, "spgist",
216 oprform->amopstrategy)));
217 result = false;
218 }
219
220
221 if (oprform->amoppurpose != AMOP_SEARCH)
222 {
223
226 {
228 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
229 errmsg(
"operator family \"%s\" of access method %s contains invalid ORDER BY specification for operator %s",
230 opfamilyname, "spgist",
232 result = false;
233 }
234 }
235 else
236 op_rettype = BOOLOID;
237
238
240 oprform->amoplefttype,
241 oprform->amoprighttype))
242 {
244 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
245 errmsg(
"operator family \"%s\" of access method %s contains operator %s with wrong signature",
246 opfamilyname, "spgist",
248 result = false;
249 }
250 }
251
252
253 opclassgroup = NULL;
254 foreach(lc, grouplist)
255 {
257
258
259 if (thisgroup->
lefttype == opcintype &&
261 opclassgroup = thisgroup;
262
263
264
265
266
267
269 {
271 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
272 errmsg(
"operator family \"%s\" of access method %s is missing operator(s) for types %s and %s",
273 opfamilyname, "spgist",
276 result = false;
277 }
278
279
280
281
282
284 continue;
285
287 {
289 continue;
291 continue;
293 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
294 errmsg(
"operator family \"%s\" of access method %s is missing support function %d for type %s",
295 opfamilyname,
"spgist",
i,
297 result = false;
298 }
299 }
300
301
302
303 if (!opclassgroup)
304 {
306 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
307 errmsg(
"operator class \"%s\" of access method %s is missing operator(s)",
308 opclassname, "spgist")));
309 result = false;
310 }
311
315
316 return result;
317}
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)
static void * GETSTRUCT(const HeapTupleData *tuple)
Oid get_op_rettype(Oid opno)
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 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)