aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/date.c17
-rw-r--r--src/backend/utils/adt/nabstime.c9
-rw-r--r--src/backend/utils/adt/timestamp.c83
3 files changed, 25 insertions, 84 deletions
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 70f60c94622..5b6b9ebfa97 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.139 2008/02/17 02:09:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.140 2008/03/21 01:31:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1838,9 +1838,9 @@ timetztypmodout(PG_FUNCTION_ARGS)
static int
timetz2tm(TimeTzADT *time, struct pg_tm * tm, fsec_t *fsec, int *tzp)
{
-#ifdef HAVE_INT64_TIMESTAMP
- int64 trem = time->time;
+ TimeOffset trem = time->time;
+#ifdef HAVE_INT64_TIMESTAMP
tm->tm_hour = trem / USECS_PER_HOUR;
trem -= tm->tm_hour * USECS_PER_HOUR;
tm->tm_min = trem / USECS_PER_MINUTE;
@@ -1848,8 +1848,6 @@ timetz2tm(TimeTzADT *time, struct pg_tm * tm, fsec_t *fsec, int *tzp)
tm->tm_sec = trem / USECS_PER_SEC;
*fsec = trem - tm->tm_sec * USECS_PER_SEC;
#else
- double trem = time->time;
-
recalc:
TMODULO(trem, tm->tm_hour, (double) SECS_PER_HOUR);
TMODULO(trem, tm->tm_min, (double) SECS_PER_MINUTE);
@@ -1895,17 +1893,14 @@ timetz_scale(PG_FUNCTION_ARGS)
static int
timetz_cmp_internal(TimeTzADT *time1, TimeTzADT *time2)
{
- /* Primary sort is by true (GMT-equivalent) time */
-#ifdef HAVE_INT64_TIMESTAMP
- int64 t1,
+ TimeOffset t1,
t2;
+ /* Primary sort is by true (GMT-equivalent) time */
+#ifdef HAVE_INT64_TIMESTAMP
t1 = time1->time + (time1->zone * USECS_PER_SEC);
t2 = time2->time + (time2->zone * USECS_PER_SEC);
#else
- double t1,
- t2;
-
t1 = time1->time + time1->zone;
t2 = time2->time + time2->zone;
#endif
diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c
index 2265b7d903e..c1a484d9bb6 100644
--- a/src/backend/utils/adt/nabstime.c
+++ b/src/backend/utils/adt/nabstime.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.153 2008/02/17 02:09:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.154 2008/03/21 01:31:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -831,12 +831,7 @@ interval_reltime(PG_FUNCTION_ARGS)
int year,
month,
day;
-
-#ifdef HAVE_INT64_TIMESTAMP
- int64 span;
-#else
- double span;
-#endif
+ TimeOffset span;
year = interval->month / MONTHS_PER_YEAR;
month = interval->month % MONTHS_PER_YEAR;
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index f450922f26e..8ca6f998c98 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.185 2008/02/17 02:09:28 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.186 2008/03/21 01:31:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -44,11 +44,7 @@
TimestampTz PgStartTime;
-#ifdef HAVE_INT64_TIMESTAMP
-static int64 time2t(const int hour, const int min, const int sec, const fsec_t fsec);
-#else
-static double time2t(const int hour, const int min, const int sec, const fsec_t fsec);
-#endif
+static TimeOffset time2t(const int hour, const int min, const int sec, const fsec_t fsec);
static int EncodeSpecialTimestamp(Timestamp dt, char *str);
static Timestamp dt2local(Timestamp dt, int timezone);
static void AdjustTimestampForTypmod(Timestamp *time, int32 typmod);
@@ -977,11 +973,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
}
else if (range == INTERVAL_MASK(MINUTE))
{
-#ifdef HAVE_INT64_TIMESTAMP
- int64 hour;
-#else
- double hour;
-#endif
+ TimeOffset hour;
interval->month = 0;
interval->day = 0;
@@ -998,11 +990,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
}
else if (range == INTERVAL_MASK(SECOND))
{
-#ifdef HAVE_INT64_TIMESTAMP
- int64 minute;
-#else
- double minute;
-#endif
+ TimeOffset minute;
interval->month = 0;
interval->day = 0;
@@ -1076,11 +1064,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
else if (range == (INTERVAL_MASK(MINUTE) |
INTERVAL_MASK(SECOND)))
{
-#ifdef HAVE_INT64_TIMESTAMP
- int64 hour;
-#else
- double hour;
-#endif
+ TimeOffset hour;
interval->month = 0;
interval->day = 0;
@@ -1342,11 +1326,7 @@ timestamptz_to_str(TimestampTz t)
void
dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec)
{
-#ifdef HAVE_INT64_TIMESTAMP
- int64 time;
-#else
- double time;
-#endif
+ TimeOffset time;
time = jd;
@@ -1547,13 +1527,8 @@ recalc_t:
int
tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
{
-#ifdef HAVE_INT64_TIMESTAMP
- int date;
- int64 time;
-#else
- double date,
- time;
-#endif
+ TimeOffset date;
+ TimeOffset time;
/* Julian day routines are not correct for negative Julian days */
if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday))
@@ -1596,13 +1571,8 @@ tm2timestamp(struct pg_tm * tm, fsec_t fsec, int *tzp, Timestamp *result)
int
interval2tm(Interval span, struct pg_tm * tm, fsec_t *fsec)
{
-#ifdef HAVE_INT64_TIMESTAMP
- int64 time;
- int64 tfrac;
-#else
- double time;
- double tfrac;
-#endif
+ TimeOffset time;
+ TimeOffset tfrac;
tm->tm_year = span.month / MONTHS_PER_YEAR;
tm->tm_mon = span.month % MONTHS_PER_YEAR;
@@ -1658,19 +1628,15 @@ tm2interval(struct pg_tm * tm, fsec_t fsec, Interval *span)
return 0;
}
-#ifdef HAVE_INT64_TIMESTAMP
-static int64
+static TimeOffset
time2t(const int hour, const int min, const int sec, const fsec_t fsec)
{
+#ifdef HAVE_INT64_TIMESTAMP
return (((((hour * MINS_PER_HOUR) + min) * SECS_PER_MINUTE) + sec) * USECS_PER_SEC) + fsec;
-} /* time2t() */
#else
-static double
-time2t(const int hour, const int min, const int sec, const fsec_t fsec)
-{
return (((hour * MINS_PER_HOUR) + min) * SECS_PER_MINUTE) + sec + fsec;
-} /* time2t() */
#endif
+}
static Timestamp
dt2local(Timestamp dt, int tz)
@@ -1681,7 +1647,7 @@ dt2local(Timestamp dt, int tz)
dt -= tz;
#endif
return dt;
-} /* dt2local() */
+}
/*****************************************************************************
@@ -2042,13 +2008,8 @@ timestamptz_cmp_timestamp(PG_FUNCTION_ARGS)
static int
interval_cmp_internal(Interval *interval1, Interval *interval2)
{
-#ifdef HAVE_INT64_TIMESTAMP
- int64 span1,
- span2;
-#else
- double span1,
+ TimeOffset span1,
span2;
-#endif
span1 = interval1->time;
span2 = interval2->time;
@@ -2387,12 +2348,7 @@ interval_justify_interval(PG_FUNCTION_ARGS)
{
Interval *span = PG_GETARG_INTERVAL_P(0);
Interval *result;
-
-#ifdef HAVE_INT64_TIMESTAMP
- int64 wholeday;
-#else
- double wholeday;
-#endif
+ TimeOffset wholeday;
int32 wholemonth;
result = (Interval *) palloc(sizeof(Interval));
@@ -2459,12 +2415,7 @@ interval_justify_hours(PG_FUNCTION_ARGS)
{
Interval *span = PG_GETARG_INTERVAL_P(0);
Interval *result;
-
-#ifdef HAVE_INT64_TIMESTAMP
- int64 wholeday;
-#else
- double wholeday;
-#endif
+ TimeOffset wholeday;
result = (Interval *) palloc(sizeof(Interval));
result->month = span->month;