{
return DatumGetInt32(
DirectFunctionCall2(interval_cmp,
- IntervalPGetDatum(((Nsrt *) a)->t),
- IntervalPGetDatum(((Nsrt *) b)->t)
+ IntervalPGetDatum(((Nsrt *) a)->t),
+ IntervalPGetDatum(((Nsrt *) b)->t)
)
);
}
static double
intr2num(const Interval *i)
{
- double ret = 0.0;
- struct pg_tm tm;
- fsec_t fsec;
-
- interval2tm(*i, &tm, &fsec);
- ret += (tm.tm_year * 360.0 * 86400.0);
- ret += (tm.tm_mon * 12.0 * 86400.0);
- ret += (tm.tm_mday * 86400.0);
- ret += (tm.tm_hour * 3600.0);
- ret += (tm.tm_min * 60.0);
- ret += (tm.tm_sec);
- ret += (fsec / 1000000.0);
-
- return (ret);
+ return INTERVAL_TO_SEC(i);
}
-#define INTERVALSIZE 12
+/*
+ * INTERVALSIZE should be the actual size-on-disk of an Interval, as shown
+ * in pg_type. This might be less than sizeof(Interval) if the compiler
+ * insists on adding alignment padding at the end of the struct.
+ */
+#define INTERVALSIZE 16
static const gbtree_ninfo tinfo =
{
inew[0] = intr2num(&newentry->lower);
inew[1] = intr2num(&newentry->upper);
- penalty_num(result,iorg[0],iorg[1],inew[0],inew[1]);
+ penalty_num(result, iorg[0], iorg[1], inew[0], inew[1]);
PG_RETURN_POINTER(result);
gbt_intv_picksplit(PG_FUNCTION_ARGS)
{
PG_RETURN_POINTER(gbt_num_picksplit(
- (GistEntryVector *) PG_GETARG_POINTER(0),
- (GIST_SPLITVEC *) PG_GETARG_POINTER(1),
+ (GistEntryVector *) PG_GETARG_POINTER(0),
+ (GIST_SPLITVEC *) PG_GETARG_POINTER(1),
&tinfo
));
}