/* We need the lists to be ordered; should be true in normal operation */ if (!oprlist->ordered || !proclist->ordered)
elog(ERROR, "cannot validate operator family without ordered data");
while (oprform || procform)
{ if (oprform && thisgroup &&
oprform->amoplefttype == thisgroup->lefttype &&
oprform->amoprighttype == thisgroup->righttype)
{ /* Operator belongs to current group; include it and advance */
if (procform && thisgroup &&
procform->amproclefttype == thisgroup->lefttype &&
procform->amprocrighttype == thisgroup->righttype)
{ /* Procedure belongs to current group; include it and advance */
/* Ignore function numbers outside supported range */ if (procform->amprocnum > 0 && procform->amprocnum < 64)
thisgroup->functionset |= ((uint64) 1) << procform->amprocnum;
/* Time for a new group */
thisgroup = (OpFamilyOpFuncGroup *) palloc(sizeof(OpFamilyOpFuncGroup)); if (oprform &&
(!procform ||
(oprform->amoplefttype < procform->amproclefttype ||
(oprform->amoplefttype == procform->amproclefttype &&
oprform->amoprighttype < procform->amprocrighttype))))
{
thisgroup->lefttype = oprform->amoplefttype;
thisgroup->righttype = oprform->amoprighttype;
} else
{
thisgroup->lefttype = procform->amproclefttype;
thisgroup->righttype = procform->amprocrighttype;
}
thisgroup->operatorset = thisgroup->functionset = 0;
result = lappend(result, thisgroup);
}
return result;
}
/* *Validatethesignature(argumentandresulttypes)ofanopclasssupport *function.ReturntrueifOK,falseifnot. * *The"..."representsmaxargsargument-typeOIDs.If"exact"istrue,they *mustmatchthefunctionargtypesexactly,elseonlybinary-coercibly. *Inanycasethefunctionresulttypemustmatchrestypeexactly.
*/ bool
check_amproc_signature(Oid funcid, Oid restype, bool exact, int minargs, int maxargs,...)
{ bool result = true;
HeapTuple tp;
Form_pg_proc procform;
va_list ap; int i;
tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(tp))
elog(ERROR, "cache lookup failed for function %u", funcid);
procform = (Form_pg_proc) GETSTRUCT(tp);
if (procform->prorettype != restype || procform->proretset ||
procform->pronargs < minargs || procform->pronargs > maxargs)
result = false;
va_start(ap, maxargs); for (i = 0; i < maxargs; i++)
{
Oid argtype = va_arg(ap, Oid);
if (i >= procform->pronargs)
continue; if (exact ? (argtype != procform->proargtypes.values[i]) :
!IsBinaryCoercible(argtype, procform->proargtypes.values[i]))
result = false;
}
va_end(ap);
if (opform->oprresult != restype || opform->oprkind != 'b' ||
opform->oprleft != lefttype || opform->oprright != righttype)
result = false;
ReleaseSysCache(tp); return result;
}
/* *GettheOIDoftheopclassbelongingtoanopfamilyandaccepting *thespecifiedtypeasinputtype.ReturnsInvalidOidifnosuchopclass. * *Ifthereismorethanonesuchopclass,yougetarandomoneofthem. *Sincethatshouldn'thappen,wedon'twastecycleschecking. * *WecouldlookuptheAM'sOIDfromtheopfamily,butallexistingcallers *knowthatorcangetitwithoutanextralookup,sowemakethempassit.
*/
Oid
opclass_for_family_datatype(Oid amoid, Oid opfamilyoid, Oid datatypeoid)
{
Oid result = InvalidOid;
CatCList *opclist; int i;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.