summaryrefslogtreecommitdiff
path: root/contrib/btree_gist/btree_utils_num.h
diff options
context:
space:
mode:
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);