OSDN Git Service

contrib uninstall scripts
[pg-rex/syncrep.git] / contrib / btree_gist / btree_interval.c
index 206b4c9..b777629 100644 (file)
@@ -63,8 +63,8 @@ gbt_intvkey_cmp(const void *a, const void *b)
 {
        return DatumGetInt32(
                                                 DirectFunctionCall2(interval_cmp,
-                                                                         IntervalPGetDatum(((Nsrt *) a)->t),
-                                                                          IntervalPGetDatum(((Nsrt *) b)->t)
+                                                                                 IntervalPGetDatum(((Nsrt *) a)->t),
+                                                                                  IntervalPGetDatum(((Nsrt *) b)->t)
                                                                                         )
                );
 }
@@ -73,23 +73,15 @@ gbt_intvkey_cmp(const void *a, const void *b)
 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 =
 {
@@ -210,7 +202,7 @@ gbt_intv_penalty(PG_FUNCTION_ARGS)
        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);
 
@@ -220,8 +212,8 @@ Datum
 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
                                                                                ));
 }