aboutsummaryrefslogtreecommitdiff
path: root/contrib/btree_gist/btree_utils_num.c
diff options
context:
space:
mode:
authorTomas Vondra <tomas.vondra@postgresql.org>2021-11-06 17:00:43 +0100
committerTomas Vondra <tomas.vondra@postgresql.org>2021-11-06 17:00:43 +0100
commit57e3c5160b24e61758f817feb7aac152cd695c6f (patch)
treeaf80841b8c3eab2e46d003bcbc573b62557e4644 /contrib/btree_gist/btree_utils_num.c
parentdafcf887daa472b0a49bee7e07042372bc37cee4 (diff)
downloadpostgresql-57e3c5160b24e61758f817feb7aac152cd695c6f.tar.gz
postgresql-57e3c5160b24e61758f817feb7aac152cd695c6f.zip
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
Diffstat (limited to 'contrib/btree_gist/btree_utils_num.c')
-rw-r--r--contrib/btree_gist/btree_utils_num.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/contrib/btree_gist/btree_utils_num.c b/contrib/btree_gist/btree_utils_num.c
index 7564a403c7d..5632ee0586c 100644
--- a/contrib/btree_gist/btree_utils_num.c
+++ b/contrib/btree_gist/btree_utils_num.c
@@ -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;