summaryrefslogtreecommitdiff
path: root/contrib/btree_gist/btree_utils_num.h
diff options
context:
space:
mode:
authorTom Lane2005-07-21 04:15:04 +0000
committerTom Lane2005-07-21 04:15:04 +0000
commit3976899f295c336b2a40c7fd1b4f1c345a45a446 (patch)
tree3dce1de87b701bb212a94fc0cfad2ab5ceec82dc /contrib/btree_gist/btree_utils_num.h
parenta536b2dd80f29464b0461e3980043ec4a822e820 (diff)
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...
Diffstat (limited to 'contrib/btree_gist/btree_utils_num.h')
-rw-r--r--contrib/btree_gist/btree_utils_num.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/contrib/btree_gist/btree_utils_num.h b/contrib/btree_gist/btree_utils_num.h
index 8f140953f5c..94d4bf74374 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);