From 7861d72ea204ef4085861f79f9c1749597160f72 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Fri, 18 Apr 2008 18:43:09 +0000 Subject: Modify the float4 datatype to be pass-by-val. Along the way, remove the last uses of the long-deprecated float32 in contrib/seg; the definitions themselves are still there, but no longer used. fmgr/README updated to match. I added a CREATE FUNCTION to account for existing seg_center() code in seg.c too, and some tests for it and the neighbor functions. At the same time, remove checks for NULL which are not needed (because the functions are declared STRICT). I had to do some adjustments to contrib's btree_gist too. The choices for representation there are not ideal for changing the underlying types :-( Original patch by Zoltan Boszormenyi, with some adjustments by me. --- contrib/btree_gist/btree_utils_num.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'contrib/btree_gist/btree_utils_num.c') diff --git a/contrib/btree_gist/btree_utils_num.c b/contrib/btree_gist/btree_utils_num.c index 9798d015635..c7b41f16c1e 100644 --- a/contrib/btree_gist/btree_utils_num.c +++ b/contrib/btree_gist/btree_utils_num.c @@ -13,10 +13,11 @@ gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, const gbtree_ninfo * tinfo { int16 i2; int32 i4; + float4 f4; DateADT dt; } v; - GBT_NUMKEY *r = (GBT_NUMKEY *) palloc(2 * tinfo->size); + GBT_NUMKEY *r = (GBT_NUMKEY *) palloc0(2 * tinfo->size); void *leaf = NULL; switch (tinfo->t) @@ -37,11 +38,14 @@ gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, const gbtree_ninfo * tinfo v.dt = DatumGetDateADT(entry->key); leaf = &v.dt; break; + case gbt_t_float4: + v.f4 = DatumGetFloat4(entry->key); + leaf = &v.f4; + break; default: leaf = DatumGetPointer(entry->key); } - memset((void *) &r[0], 0, 2 * tinfo->size); memcpy((void *) &r[0], leaf, tinfo->size); memcpy((void *) &r[tinfo->size], leaf, tinfo->size); retval = palloc(sizeof(GISTENTRY)); -- cgit v1.2.3