mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Add index-only scan support to btree_gist.
inet, cidr, and timetz indexes still cannot support index-only scans, because they don't store the original unmodified value in the index, but a derived approximate value.
This commit is contained in:
@ -93,6 +93,64 @@ gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a compressed leaf item back to the original type, for index-only
|
||||
* scans.
|
||||
*/
|
||||
GISTENTRY *
|
||||
gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)
|
||||
{
|
||||
GISTENTRY *retval;
|
||||
Datum datum;
|
||||
|
||||
Assert(tinfo->indexsize >= 2 * tinfo->size);
|
||||
|
||||
/*
|
||||
* Get the original Datum from the stored datum. On leaf entries, the
|
||||
* lower and upper bound are the same. We just grab the lower bound and
|
||||
* return it.
|
||||
*/
|
||||
switch (tinfo->t)
|
||||
{
|
||||
case gbt_t_int2:
|
||||
datum = Int16GetDatum(*(int16 *) entry->key);
|
||||
break;
|
||||
case gbt_t_int4:
|
||||
datum = Int32GetDatum(*(int32 *) entry->key);
|
||||
break;
|
||||
case gbt_t_int8:
|
||||
datum = Int64GetDatum(*(int64 *) entry->key);
|
||||
break;
|
||||
case gbt_t_oid:
|
||||
datum = ObjectIdGetDatum(*(Oid *) entry->key);
|
||||
break;
|
||||
case gbt_t_float4:
|
||||
datum = Float4GetDatum(*(float4 *) entry->key);
|
||||
break;
|
||||
case gbt_t_float8:
|
||||
datum = Float8GetDatum(*(float8 *) entry->key);
|
||||
break;
|
||||
case gbt_t_date:
|
||||
datum = DateADTGetDatum(*(DateADT *) entry->key);
|
||||
break;
|
||||
case gbt_t_time:
|
||||
datum = TimeADTGetDatum(*(TimeADT *) entry->key);
|
||||
break;
|
||||
case gbt_t_ts:
|
||||
datum = TimestampGetDatum(*(Timestamp *) entry->key);
|
||||
break;
|
||||
case gbt_t_cash:
|
||||
datum = CashGetDatum(*(Cash *) entry->key);
|
||||
break;
|
||||
default:
|
||||
datum = PointerGetDatum(entry->key);
|
||||
}
|
||||
|
||||
retval = palloc(sizeof(GISTENTRY));
|
||||
gistentryinit(*retval, datum, entry->rel, entry->page, entry->offset,
|
||||
FALSE);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user