mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +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:
@@ -135,11 +135,13 @@ extern bool index_insert(Relation indexRelation,
|
||||
extern IndexScanDesc index_beginscan(Relation heapRelation,
|
||||
Relation indexRelation,
|
||||
Snapshot snapshot,
|
||||
int nkeys, ScanKey key);
|
||||
int nkeys, int norderbys);
|
||||
extern IndexScanDesc index_beginscan_bitmap(Relation indexRelation,
|
||||
Snapshot snapshot,
|
||||
int nkeys, ScanKey key);
|
||||
extern void index_rescan(IndexScanDesc scan, ScanKey key);
|
||||
int nkeys);
|
||||
extern void index_rescan(IndexScanDesc scan,
|
||||
ScanKey keys, int nkeys,
|
||||
ScanKey orderbys, int norderbys);
|
||||
extern void index_endscan(IndexScanDesc scan);
|
||||
extern void index_markpos(IndexScanDesc scan);
|
||||
extern void index_restrpos(IndexScanDesc scan);
|
||||
@@ -161,7 +163,7 @@ extern FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum,
|
||||
* index access method support routines (in genam.c)
|
||||
*/
|
||||
extern IndexScanDesc RelationGetIndexScan(Relation indexRelation,
|
||||
int nkeys, ScanKey key);
|
||||
int nkeys, int norderbys);
|
||||
extern void IndexScanEnd(IndexScanDesc scan);
|
||||
extern char *BuildIndexValueDescription(Relation indexRelation,
|
||||
Datum *values, bool *isnull);
|
||||
|
||||
@@ -62,8 +62,10 @@ typedef struct IndexScanDescData
|
||||
Relation heapRelation; /* heap relation descriptor, or NULL */
|
||||
Relation indexRelation; /* index relation descriptor */
|
||||
Snapshot xs_snapshot; /* snapshot to see */
|
||||
int numberOfKeys; /* number of scan keys */
|
||||
ScanKey keyData; /* array of scan key descriptors */
|
||||
int numberOfKeys; /* number of index qualifier conditions */
|
||||
int numberOfOrderBys; /* number of ordering operators */
|
||||
ScanKey keyData; /* array of index qualifier descriptors */
|
||||
ScanKey orderByData; /* array of ordering op descriptors */
|
||||
|
||||
/* signaling to index AM about killing index tuples */
|
||||
bool kill_prior_tuple; /* last-returned tuple is dead */
|
||||
|
||||
@@ -60,6 +60,11 @@ typedef uint16 StrategyNumber;
|
||||
* supported only for index scans, not heap scans; and not all index AMs
|
||||
* support them.
|
||||
*
|
||||
* A ScanKey can also represent an ordering operator invocation, that is
|
||||
* an ordering requirement "ORDER BY indexedcol op constant". This looks
|
||||
* the same as a comparison operator, except that the operator doesn't
|
||||
* (usually) yield boolean. We mark such ScanKeys with SK_ORDER_BY.
|
||||
*
|
||||
* Note: in some places, ScanKeys are used as a convenient representation
|
||||
* for the invocation of an access method support procedure. In this case
|
||||
* sk_strategy/sk_subtype are not meaningful, and sk_func may refer to a
|
||||
@@ -122,6 +127,7 @@ typedef ScanKeyData *ScanKey;
|
||||
#define SK_SEARCHNULL 0x0020 /* scankey represents "col IS NULL" */
|
||||
#define SK_SEARCHNOTNULL 0x0040 /* scankey represents "col IS NOT
|
||||
* NULL" */
|
||||
#define SK_ORDER_BY 0x0080 /* scankey is for ORDER BY op */
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user