1/*-------------------------------------------------------------------------
4 * Opclass validator for bloom.
6 * Copyright (c) 2016-2025, PostgreSQL Global Development Group
9 * contrib/bloom/blvalidate.c
11 *-------------------------------------------------------------------------
27 * Validator for a bloom opclass.
47 /* Fetch opclass information */
50 elog(
ERROR,
"cache lookup failed for operator class %u", opclassoid);
53 opfamilyoid = classform->opcfamily;
54 opcintype = classform->opcintype;
55 opckeytype = classform->opckeytype;
57 opckeytype = opcintype;
58 opclassname =
NameStr(classform->opcname);
60 /* Fetch opfamily information */
63 /* Fetch all operators and support functions of the opfamily */
67 /* Check individual support functions */
75 * All bloom support functions should be registered with matching
78 if (procform->amproclefttype != procform->amprocrighttype)
81 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
82 errmsg(
"bloom opfamily %s contains support procedure %s with cross-type registration",
89 * We can't check signatures except within the specific opclass, since
90 * we need to know the associated opckeytype in many cases.
92 if (procform->amproclefttype != opcintype)
95 /* Check procedure numbers and function signatures */
96 switch (procform->amprocnum)
107 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
108 errmsg(
"bloom opfamily %s contains function %s with invalid support number %d",
111 procform->amprocnum)));
113 continue;
/* don't want additional message */
119 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
120 errmsg(
"bloom opfamily %s contains function %s with wrong signature for support number %d",
123 procform->amprocnum)));
128 /* Check individual operators */
134 /* Check it's allowed strategy for bloom */
135 if (oprform->amopstrategy < 1 ||
139 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
140 errmsg(
"bloom opfamily %s contains operator %s with invalid strategy number %d",
143 oprform->amopstrategy)));
147 /* bloom doesn't support ORDER BY operators */
148 if (oprform->amoppurpose != AMOP_SEARCH ||
152 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
153 errmsg(
"bloom opfamily %s contains invalid ORDER BY specification for operator %s",
159 /* Check operator signature --- same for all bloom strategies */
161 oprform->amoplefttype,
162 oprform->amoprighttype))
165 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
166 errmsg(
"bloom opfamily %s contains operator %s with wrong signature",
173 /* Now check for inconsistent groups of operators/functions */
176 foreach(lc, grouplist)
180 /* Remember the group exactly matching the test opclass */
181 if (thisgroup->
lefttype == opcintype &&
183 opclassgroup = thisgroup;
186 * There is not a lot we can do to check the operator sets, since each
187 * bloom opclass is more or less a law unto itself, and some contain
188 * only operators that are binary-compatible with the opclass datatype
189 * (meaning that empty operator sets can be OK). That case also means
190 * that we shouldn't insist on nonempty function sets except for the
191 * opclass's own group.
195 /* Check that the originally-named opclass is complete */
200 continue;
/* got it */
202 continue;
/* optional method */
204 (
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
205 errmsg(
"bloom opclass %s is missing support function %d",
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 BLOOM_NSTRATEGIES
#define BLOOM_OPTIONS_PROC
bool blvalidate(Oid opclassoid)
#define OidIsValid(objectId)
void ReleaseCatCacheList(CatCList *list)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#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)
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)