datum = OidFunctionCall0(amhandler);
routine = (IndexAmRoutine *) DatumGetPointer(datum);
if (routine == NULL || !IsA(routine, IndexAmRoutine))
elog(ERROR, "index access method handler function %u did not return an IndexAmRoutine struct",
amhandler);
/* Get handler function OID for the access method */
tuple = SearchSysCache1(AMOID, ObjectIdGetDatum(amoid)); if (!HeapTupleIsValid(tuple))
{ if (noerror) return NULL;
elog(ERROR, "cache lookup failed for access method %u",
amoid);
}
amform = (Form_pg_am) GETSTRUCT(tuple);
/* Check if it's an index access method as opposed to some other AM */ if (amform->amtype != AMTYPE_INDEX)
{ if (noerror)
{
ReleaseSysCache(tuple); return NULL;
}
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("access method \"%s\" is not of type %s",
NameStr(amform->amname), "INDEX")));
}
amhandler = amform->amhandler;
/* Complain if handler OID is invalid */ if (!RegProcedureIsValid(amhandler))
{ if (noerror)
{
ReleaseSysCache(tuple); return NULL;
}
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("index access method \"%s\" does not have a handler",
NameStr(amform->amname))));
}
ReleaseSysCache(tuple);
/* And finally, call the handler function to get the API struct. */ return GetIndexAmRoutine(amhandler);
}
/* shortcut for common case */ if (amoid == BTREE_AM_OID &&
(strategy > InvalidStrategy && strategy <= BTMaxStrategyNumber)) return (CompareType) strategy;
amroutine = GetIndexAmRoutineByAmId(amoid, false); if (amroutine->amtranslatestrategy)
result = amroutine->amtranslatestrategy(strategy, opfamily); else
result = COMPARE_INVALID;
if (!missing_ok && result == COMPARE_INVALID)
elog(ERROR, "could not translate strategy number %d for index AM %u", strategy, amoid);
/* shortcut for common case */ if (amoid == BTREE_AM_OID &&
(cmptype > COMPARE_INVALID && cmptype <= COMPARE_GT)) return (StrategyNumber) cmptype;
amroutine = GetIndexAmRoutineByAmId(amoid, false); if (amroutine->amtranslatecmptype)
result = amroutine->amtranslatecmptype(cmptype, opfamily); else
result = InvalidStrategy;
if (!missing_ok && result == InvalidStrategy)
elog(ERROR, "could not translate compare type %u for index AM %u", cmptype, amoid);
return result;
}
/* *Askappropriateaccessmethodtovalidatethespecifiedopclass.
*/
Datum
amvalidate(PG_FUNCTION_ARGS)
{
Oid opclassoid = PG_GETARG_OID(0); bool result;
HeapTuple classtup;
Form_pg_opclass classform;
Oid amoid;
IndexAmRoutine *amroutine;
classtup = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclassoid)); if (!HeapTupleIsValid(classtup))
elog(ERROR, "cache lookup failed for operator class %u", opclassoid);
classform = (Form_pg_opclass) GETSTRUCT(classtup);
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.