1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Add bool GiST opclass to btree_gist

Adds bool opclass to btree_gist extension, to allow creating GiST
indexes on bool columns. GiST indexes on a single bool column don't seem
particularly useful, but this allows defining exclusion constraings
involving a bool column, for example.

Author: Emre Hasegeli
Reviewed-by: Andrey Borodin
Discussion: https://postgr.es/m/CAE2gYzyDKJBZngssR84VGZEN=Ux=V9FV23QfPgo+7-yYnKKg4g@mail.gmail.com
This commit is contained in:
Tomas Vondra
2021-11-06 17:00:43 +01:00
parent dafcf887da
commit 57e3c5160b
8 changed files with 382 additions and 3 deletions

View File

@ -19,6 +19,7 @@ gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
{
union
{
bool bo;
int16 i2;
int32 i4;
int64 i8;
@ -35,6 +36,10 @@ gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
switch (tinfo->t)
{
case gbt_t_bool:
v.bo = DatumGetBool(entry->key);
leaf = &v.bo;
break;
case gbt_t_int2:
v.i2 = DatumGetInt16(entry->key);
leaf = &v.i2;
@ -113,6 +118,9 @@ gbt_num_fetch(GISTENTRY *entry, const gbtree_ninfo *tinfo)
*/
switch (tinfo->t)
{
case gbt_t_bool:
datum = BoolGetDatum(*(bool *) entry->key);
break;
case gbt_t_int2:
datum = Int16GetDatum(*(int16 *) entry->key);
break;