Skip to content

Commit 4df0f1d

Browse files
committed
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.
1 parent 69c049c commit 4df0f1d

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

src/backend/utils/adt/datetime.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.100 2003/02/19 03:48:10 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.101 2003/02/20 05:24:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1253,9 +1253,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
12531253
case DTK_NOW:
12541254
tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ));
12551255
*dtype = DTK_DATE;
1256-
GetCurrentTimeUsec(tm, fsec);
1257-
if (tzp != NULL)
1258-
*tzp = CTimeZone;
1256+
GetCurrentTimeUsec(tm, fsec, tzp);
12591257
break;
12601258

12611259
case DTK_YESTERDAY:
@@ -1969,7 +1967,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
19691967
case DTK_NOW:
19701968
tmask = DTK_TIME_M;
19711969
*dtype = DTK_TIME;
1972-
GetCurrentTimeUsec(tm, fsec);
1970+
GetCurrentTimeUsec(tm, fsec, NULL);
19731971
break;
19741972

19751973
case DTK_ZULU:

src/backend/utils/adt/nabstime.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.102 2002/12/12 19:16:55 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.103 2003/02/20 05:24:55 tgl Exp $
1313
*
1414
* NOTES
1515
*
@@ -243,25 +243,24 @@ GetCurrentDateTime(struct tm * tm)
243243
int tz;
244244

245245
abstime2tm(GetCurrentTransactionStartTime(), &tz, tm, NULL);
246-
247-
return;
248246
} /* GetCurrentDateTime() */
249247

250248

251249
void
252-
GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec)
250+
GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec, int *tzp)
253251
{
254252
int tz;
255253
int usec;
256254

257255
abstime2tm(GetCurrentTransactionStartTimeUsec(&usec), &tz, tm, NULL);
256+
/* Note: don't pass NULL tzp directly to abstime2tm */
257+
if (tzp != NULL)
258+
*tzp = tz;
258259
#ifdef HAVE_INT64_TIMESTAMP
259260
*fsec = usec;
260261
#else
261262
*fsec = usec * 1.0e-6;
262263
#endif
263-
264-
return;
265264
} /* GetCurrentTimeUsec() */
266265

267266

src/include/utils/datetime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Id: datetime.h,v 1.35 2003/02/19 03:48:10 momjian Exp $
12+
* $Id: datetime.h,v 1.36 2003/02/20 05:24:55 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -261,7 +261,7 @@ extern int day_tab[2][13];
261261

262262

263263
extern void GetCurrentDateTime(struct tm * tm);
264-
extern void GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec);
264+
extern void GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec, int *tzp);
265265
extern void j2date(int jd, int *year, int *month, int *day);
266266
extern int date2j(int year, int month, int day);
267267

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy