Commit 4df0f1d2 authored by Tom Lane's avatar Tom Lane

Fix timestamptz_in so that parsing of 'now'::timestamptz gives right

answer when SET TIMEZONE has been done since the start of the current
transaction.  Per bug report from Robert Haas.
I plan some futher cleanup in HEAD, but this is a low-risk patch for
the immediate issue in 7.3.
parent 69c049ce
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.100 2003/02/19 03:48:10 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.101 2003/02/20 05:24:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1253,9 +1253,7 @@ DecodeDateTime(char **field, int *ftype, int nf, ...@@ -1253,9 +1253,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
case DTK_NOW: case DTK_NOW:
tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ)); tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ));
*dtype = DTK_DATE; *dtype = DTK_DATE;
GetCurrentTimeUsec(tm, fsec); GetCurrentTimeUsec(tm, fsec, tzp);
if (tzp != NULL)
*tzp = CTimeZone;
break; break;
case DTK_YESTERDAY: case DTK_YESTERDAY:
...@@ -1969,7 +1967,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, ...@@ -1969,7 +1967,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
case DTK_NOW: case DTK_NOW:
tmask = DTK_TIME_M; tmask = DTK_TIME_M;
*dtype = DTK_TIME; *dtype = DTK_TIME;
GetCurrentTimeUsec(tm, fsec); GetCurrentTimeUsec(tm, fsec, NULL);
break; break;
case DTK_ZULU: case DTK_ZULU:
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.102 2002/12/12 19:16:55 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.103 2003/02/20 05:24:55 tgl Exp $
* *
* NOTES * NOTES
* *
...@@ -243,25 +243,24 @@ GetCurrentDateTime(struct tm * tm) ...@@ -243,25 +243,24 @@ GetCurrentDateTime(struct tm * tm)
int tz; int tz;
abstime2tm(GetCurrentTransactionStartTime(), &tz, tm, NULL); abstime2tm(GetCurrentTransactionStartTime(), &tz, tm, NULL);
return;
} /* GetCurrentDateTime() */ } /* GetCurrentDateTime() */
void void
GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec) GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec, int *tzp)
{ {
int tz; int tz;
int usec; int usec;
abstime2tm(GetCurrentTransactionStartTimeUsec(&usec), &tz, tm, NULL); abstime2tm(GetCurrentTransactionStartTimeUsec(&usec), &tz, tm, NULL);
/* Note: don't pass NULL tzp directly to abstime2tm */
if (tzp != NULL)
*tzp = tz;
#ifdef HAVE_INT64_TIMESTAMP #ifdef HAVE_INT64_TIMESTAMP
*fsec = usec; *fsec = usec;
#else #else
*fsec = usec * 1.0e-6; *fsec = usec * 1.0e-6;
#endif #endif
return;
} /* GetCurrentTimeUsec() */ } /* GetCurrentTimeUsec() */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: datetime.h,v 1.35 2003/02/19 03:48:10 momjian Exp $ * $Id: datetime.h,v 1.36 2003/02/20 05:24:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -261,7 +261,7 @@ extern int day_tab[2][13]; ...@@ -261,7 +261,7 @@ extern int day_tab[2][13];
extern void GetCurrentDateTime(struct tm * tm); extern void GetCurrentDateTime(struct tm * tm);
extern void GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec); extern void GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec, int *tzp);
extern void j2date(int jd, int *year, int *month, int *day); extern void j2date(int jd, int *year, int *month, int *day);
extern int date2j(int year, int month, int day); extern int date2j(int year, int month, int day);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment