mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Create core infrastructure for KNNGIST.
This is a heavily revised version of builtin_knngist_core-0.9. The ordering operators are no longer mixed in with actual quals, which would have confused not only humans but significant parts of the planner. Instead, ordering operators are carried separately throughout planning and execution. Since the API for ambeginscan and amrescan functions had to be changed anyway, this commit takes the opportunity to rationalize that a bit. RelationGetIndexScan no longer forces a premature index_rescan call; instead, callers of index_beginscan must call index_rescan too. Aside from making the AM-side initialization logic a bit less peculiar, this has the advantage that we do not make a useless extra am_rescan call when there are runtime key values. AMs formerly could not assume that the key values passed to amrescan were actually valid; now they can. Teodor Sigaev and Tom Lane
This commit is contained in:
31
src/backend/utils/cache/lsyscache.c
vendored
31
src/backend/utils/cache/lsyscache.c
vendored
@ -85,19 +85,42 @@ get_op_opfamily_strategy(Oid opno, Oid opfamily)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_op_opfamily_sortfamily
|
||||
*
|
||||
* If the operator is an ordering operator within the specified opfamily,
|
||||
* return its amopsortfamily OID; else return InvalidOid.
|
||||
*/
|
||||
Oid
|
||||
get_op_opfamily_sortfamily(Oid opno, Oid opfamily)
|
||||
{
|
||||
HeapTuple tp;
|
||||
Form_pg_amop amop_tup;
|
||||
Oid result;
|
||||
|
||||
tp = SearchSysCache3(AMOPOPID,
|
||||
ObjectIdGetDatum(opno),
|
||||
CharGetDatum(AMOP_ORDER),
|
||||
ObjectIdGetDatum(opfamily));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
return InvalidOid;
|
||||
amop_tup = (Form_pg_amop) GETSTRUCT(tp);
|
||||
result = amop_tup->amopsortfamily;
|
||||
ReleaseSysCache(tp);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_op_opfamily_properties
|
||||
*
|
||||
* Get the operator's strategy number and declared input data types
|
||||
* within the specified opfamily.
|
||||
*
|
||||
* This function only considers search operators, not ordering operators.
|
||||
*
|
||||
* Caller should already have verified that opno is a member of opfamily,
|
||||
* therefore we raise an error if the tuple is not found.
|
||||
*/
|
||||
void
|
||||
get_op_opfamily_properties(Oid opno, Oid opfamily,
|
||||
get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,
|
||||
int *strategy,
|
||||
Oid *lefttype,
|
||||
Oid *righttype)
|
||||
@ -107,7 +130,7 @@ get_op_opfamily_properties(Oid opno, Oid opfamily,
|
||||
|
||||
tp = SearchSysCache3(AMOPOPID,
|
||||
ObjectIdGetDatum(opno),
|
||||
CharGetDatum(AMOP_SEARCH),
|
||||
CharGetDatum(ordering_op ? AMOP_ORDER : AMOP_SEARCH),
|
||||
ObjectIdGetDatum(opfamily));
|
||||
if (!HeapTupleIsValid(tp))
|
||||
elog(ERROR, "operator %u is not a member of opfamily %u",
|
||||
|
Reference in New Issue
Block a user