From 3976899f295c336b2a40c7fd1b4f1c345a45a446 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 21 Jul 2005 04:15:04 +0000 Subject: Fix storage size for btree_gist interval indexes. Fix penalty calculations for interval and time/timetz to behave sanely for both integer and float timestamps; up to now I think it's been doing something pretty strange... --- contrib/btree_gist/btree_utils_num.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'contrib/btree_gist/btree_utils_num.h') diff --git a/contrib/btree_gist/btree_utils_num.h b/contrib/btree_gist/btree_utils_num.h index 8f140953f5..94d4bf7437 100644 --- a/contrib/btree_gist/btree_utils_num.h +++ b/contrib/btree_gist/btree_utils_num.h @@ -63,6 +63,24 @@ typedef struct } while (0); +/* + * Convert an Interval to an approximate equivalent number of seconds + * (as a double). Here because we need it for time/timetz as well as + * interval. See interval_cmp_internal for comparison. + */ +#ifdef HAVE_INT64_TIMESTAMP +#define INTERVAL_TO_SEC(ivp) \ + (((double) (ivp)->time) / ((double) USECS_PER_SEC) + \ + (ivp)->day * (24.0 * SECS_PER_HOUR) + \ + (ivp)->month * (30.0 * SECS_PER_DAY)) +#else +#define INTERVAL_TO_SEC(ivp) \ + ((ivp)->time + \ + (ivp)->day * (24.0 * SECS_PER_HOUR) + \ + (ivp)->month * (30.0 * SECS_PER_DAY)) +#endif + + extern bool gbt_num_consistent(const GBT_NUMKEY_R * key, const void *query, const StrategyNumber *strategy, bool is_leaf, const gbtree_ninfo * tinfo); -- cgit v1.2.1