]> granicus.if.org Git - postgresql/commitdiff
Fix timestamptz_in so that parsing of 'now'::timestamptz gives right
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 20 Feb 2003 05:25:25 +0000 (05:25 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 20 Feb 2003 05:25:25 +0000 (05:25 +0000)
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.

src/backend/utils/adt/datetime.c
src/backend/utils/adt/nabstime.c
src/include/utils/datetime.h

index b21c5f217d154f6e0a6cdaefd748bcad55332959..0ce56d0774638cda81b5c472cdfeab83000de3f6 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.96.2.3 2003/01/29 01:09:03 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.96.2.4 2003/02/20 05:25:24 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1242,9 +1242,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
                                                        case DTK_NOW:
                                                                tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ));
                                                                *dtype = DTK_DATE;
-                                                               GetCurrentTimeUsec(tm, fsec);
-                                                               if (tzp != NULL)
-                                                                       *tzp = CTimeZone;
+                                                               GetCurrentTimeUsec(tm, fsec, tzp);
                                                                break;
 
                                                        case DTK_YESTERDAY:
@@ -1958,7 +1956,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
                                                        case DTK_NOW:
                                                                tmask = DTK_TIME_M;
                                                                *dtype = DTK_TIME;
-                                                               GetCurrentTimeUsec(tm, fsec);
+                                                               GetCurrentTimeUsec(tm, fsec, NULL);
                                                                break;
 
                                                        case DTK_ZULU:
index c773ccbdab7a2b61af5344cbc192d42b264a7acd..6de79aaa9cdf78f64bf87c0337c47a11ea07ff81 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.100.2.2 2002/12/12 19:17:04 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.100.2.3 2003/02/20 05:25:24 tgl Exp $
  *
  * NOTES
  *
@@ -243,25 +243,24 @@ GetCurrentDateTime(struct tm * tm)
        int                     tz;
 
        abstime2tm(GetCurrentTransactionStartTime(), &tz, tm, NULL);
-
-       return;
 }      /* GetCurrentDateTime() */
 
 
 void
-GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec)
+GetCurrentTimeUsec(struct tm * tm, fsec_t *fsec, int *tzp)
 {
        int                     tz;
        int                     usec;
 
        abstime2tm(GetCurrentTransactionStartTimeUsec(&usec), &tz, tm, NULL);
+       /* Note: don't pass NULL tzp directly to abstime2tm */
+       if (tzp != NULL)
+               *tzp = tz;
 #ifdef HAVE_INT64_TIMESTAMP
        *fsec = usec;
 #else
        *fsec = usec * 1.0e-6;
 #endif
-
-       return;
 }      /* GetCurrentTimeUsec() */
 
 
index d788ea4d529ff1ade0fc21b038d169afae69865a..1c7950bd529402256f9d6191a0364fdf3cbf1836 100644 (file)
@@ -9,7 +9,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: datetime.h,v 1.33.2.1 2003/01/16 00:27:17 tgl Exp $
+ * $Id: datetime.h,v 1.33.2.2 2003/02/20 05:25:25 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -261,7 +261,7 @@ extern int  day_tab[2][13];
 
 
 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 int     date2j(int year, int month, int day);