summaryrefslogtreecommitdiff
path: root/contrib/btree_gist/btree_utils_num.h
diff options
context:
space:
mode:
authorTeodor Sigaev <teodor@sigaev.ru>2005-07-01 13:44:56 +0000
committerTeodor Sigaev <teodor@sigaev.ru>2005-07-01 13:44:56 +0000
commitef770cbb6913cc4c816bb09acd7cb13f996281bd (patch)
treefe973e6aeb9c018d54ea6267f49d5d1b2d5d2f95 /contrib/btree_gist/btree_utils_num.h
parent8f6e8e8fed372a592f645d8900b6f456db82cc59 (diff)
downloadpostgresql-ef770cbb6913cc4c816bb09acd7cb13f996281bd.tar.gz
Fixes from Janko Richter <jankorichter@yahoo.de>
- Fix wrong index results on text, char, varchar for multibyte strings - Fix some SIGFPE signals - Add support for infinite timestamps - Because of locale settings, btree_gist can not be a prefix index anymore (for text). Each node holds now just the lower and upper boundary.
Diffstat (limited to 'contrib/btree_gist/btree_utils_num.h')
-rw-r--r--contrib/btree_gist/btree_utils_num.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/contrib/btree_gist/btree_utils_num.h b/contrib/btree_gist/btree_utils_num.h
index 714144f676..8f140953f5 100644
--- a/contrib/btree_gist/btree_utils_num.h
+++ b/contrib/btree_gist/btree_utils_num.h
@@ -43,16 +43,26 @@ typedef struct
*/
-#define penalty_range_enlarge(olower,oupper,nlower,nupper) do { \
- res = 0; \
+
+/*
+ * Note: The factor 0.49 in following macro avoids floating point overflows
+*/
+#define penalty_num(result,olower,oupper,nlower,nupper) do { \
+ double tmp = 0.0F; \
+ (*(result)) = 0.0F; \
if ( (nupper) > (oupper) ) \
- res += ( (nupper) - (oupper) ); \
+ tmp += ( ((double)nupper)*0.49F - ((double)oupper)*0.49F ); \
if ( (olower) > (nlower) ) \
- res += ( (olower) - (nlower) ); \
+ tmp += ( ((double)olower)*0.49F - ((double)nlower)*0.49F ); \
+ if (tmp > 0.0F) \
+ { \
+ (*(result)) += FLT_MIN; \
+ (*(result)) += (float) ( ((double)(tmp)) / ( (double)(tmp) + ( ((double)(oupper))*0.49F - ((double)(olower))*0.49F ) ) ); \
+ (*(result)) *= (FLT_MAX / (((GISTENTRY *) PG_GETARG_POINTER(0))->rel->rd_att->natts + 1)); \
+ } \
} while (0);
-
extern bool gbt_num_consistent(const GBT_NUMKEY_R * key, const void *query,
const StrategyNumber *strategy, bool is_leaf,
const gbtree_ninfo * tinfo);