Add exemptor functions to avoid rewrites for conversions involving the temporal
data types.  I needed a find-last-set function for the interval_scale exemptor
function, so I imported one from FreeBSD.  To improve timestamp<->timestamptz
when the timezone "is" UTC/GMT, I compare the current timezone definition to the
gmt_timezone we keep handy.  To make that actually work, I've changed pg_tzset
to zero its unused bytes.
*** a/configure
--- b/configure
***************
*** 20269,20275 **** LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 
's/-lreadline//g'`
  
  
  
! for ac_func in crypt erand48 getopt getrusage inet_aton random rint srandom 
strdup strerror strlcat strlcpy strtol strtoul
  do
  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
  { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
--- 20269,20276 ----
  
  
  
! 
! for ac_func in crypt erand48 fls getopt getrusage inet_aton random rint 
srandom strdup strerror strlcat strlcpy strtol strtoul
  do
  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
  { $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
*** a/configure.in
--- b/configure.in
***************
*** 1288,1294 **** fi
  pgac_save_LIBS="$LIBS"
  LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
  
! AC_REPLACE_FUNCS([crypt erand48 getopt getrusage inet_aton random rint 
srandom strdup strerror strlcat strlcpy strtol strtoul])
  
  case $host_os in
  
--- 1288,1294 ----
  pgac_save_LIBS="$LIBS"
  LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
  
! AC_REPLACE_FUNCS([crypt erand48 fls getopt getrusage inet_aton random rint 
srandom strdup strerror strlcat strlcpy strtol strtoul])
  
  case $host_os in
  
*** a/src/backend/utils/adt/date.c
--- b/src/backend/utils/adt/date.c
***************
*** 1187,1192 **** timetypmodout(PG_FUNCTION_ARGS)
--- 1187,1203 ----
  }
  
  
+ /* time_exemptor()
+  * Identify superfluous calls to time_scale.  Also suitable for timetz_scale.
+  */
+ Datum
+ time_exemptor(PG_FUNCTION_ARGS)
+ {
+       PG_RETURN_INT32(TemporalExemptor(MAX_TIME_PRECISION,
+                                                                        
PG_GETARG_INT32(0),
+                                                                        
PG_GETARG_INT32(1)));
+ }
+ 
  /* time_scale()
   * Adjust time type for specified scale factor.
   * Used by PostgreSQL type system to stuff columns.
*** a/src/backend/utils/adt/datetime.c
--- b/src/backend/utils/adt/datetime.c
***************
*** 4135,4140 **** CheckDateTokenTables(void)
--- 4135,4158 ----
  }
  
  /*
+  * Helper for temporal exemptor functions.  Under !HAVE_INT64_TIMESTAMP and 
the
+  * wrong floating point implementation, rounding could make a fib of our
+  * COERCE_EXEMPT_NOCHANGE.  Genuine users will appreciate this as a feature: 
we
+  * avoid gratuitous data churn due to rounding anomalies in the cast.  This
+  * would yield an Assert failure in a suitably enabled build, at which point 
we
+  * might need to weaken that Assert or get serious about the precise truth 
here.
+  */
+ int32
+ TemporalExemptor(int32 max_precis, int32 old_precis, int32 new_precis)
+ {
+       if (new_precis == -1 ||
+               new_precis == max_precis ||
+               (old_precis != -1 && new_precis >= old_precis))
+               return COERCE_EXEMPT_NOCHANGE | COERCE_EXEMPT_NOERROR;
+       return COERCE_EXEMPT_NOERROR;
+ }
+ 
+ /*
   * This function gets called during timezone config file load or reload
   * to create the final array of timezone tokens.  The argument array
   * is already sorted in name order.  This data is in a temporary memory
*** a/src/backend/utils/adt/timestamp.c
--- b/src/backend/utils/adt/timestamp.c
***************
*** 308,313 **** timestamptypmodout(PG_FUNCTION_ARGS)
--- 308,329 ----
  }
  
  
+ /* timestamp_exemptor()
+  * Identify superfluous calls to timestamp_scale.  Also suitable for
+  * timestamptz_scale.
+  */
+ Datum
+ timestamp_exemptor(PG_FUNCTION_ARGS)
+ {
+       /*
+        * timestamp_scale throws an error when the typmod is out of range, but 
we
+        * can't get there from a cast: our typmodin will have caught it 
already.
+        */
+       PG_RETURN_INT32(TemporalExemptor(MAX_TIMESTAMP_PRECISION,
+                                                                        
PG_GETARG_INT32(0),
+                                                                        
PG_GETARG_INT32(1)));
+ }
+ 
  /* timestamp_scale()
   * Adjust time type for specified scale factor.
   * Used by PostgreSQL type system to stuff columns.
***************
*** 745,750 **** interval_send(PG_FUNCTION_ARGS)
--- 761,779 ----
        PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
  }
  
+ /*
+  * The interval typmod stores a "range" in its high 16 bits and a "precision" 
in
+  * its low 16 bits.  Both address the resolution of the type, with the range
+  * affecting resolution larger than one second, and precision affecting
+  * resolution smaller than one second.  The representation is sufficient to
+  * represent all SQL standard resolutions, but we implement them all terms of
+  * truncating rightward from some position.  Range is a bitmap of permitted
+  * fields, but only the smallest (temporal) such field is significant to our
+  * calculations.  The smallest temporal field is the most-significant bit set 
in
+  * the range.  Precision is a count of subsecond decimal places to retain.
+  * Alternately, setting all bits in the precision (INTERVAL_FULL_PRECISION) is
+  * equalivalent to setting INTERVAL_MAX_PRECISION.
+  */
  Datum
  intervaltypmodin(PG_FUNCTION_ARGS)
  {
***************
*** 901,906 **** intervaltypmodout(PG_FUNCTION_ARGS)
--- 930,973 ----
  }
  
  
+ /* interval_exemptor()
+  * Identify superfluous calls to interval_scale.
+  */
+ Datum
+ interval_exemptor(PG_FUNCTION_ARGS)
+ {
+       int32           old_typmod = PG_GETARG_INT32(0);
+       int32           new_typmod = PG_GETARG_INT32(1);
+       int                     old_range;
+       int                     old_precis;
+       int                     new_range = INTERVAL_RANGE(new_typmod);
+       int                     new_precis = INTERVAL_PRECISION(new_typmod);
+       int                     new_range_fls;
+ 
+       if (new_typmod == -1)
+               PG_RETURN_INT32(COERCE_EXEMPT_NOCHANGE | COERCE_EXEMPT_NOERROR);
+ 
+       if (old_typmod == -1)
+       {
+               old_range = INTERVAL_FULL_RANGE;
+               old_precis = INTERVAL_FULL_PRECISION;
+       }
+       else
+       {
+               old_range = INTERVAL_RANGE(old_typmod);
+               old_precis = INTERVAL_PRECISION(old_typmod);
+       }
+ 
+       /* See intervaltypmodin for the basis of this test. */
+       new_range_fls = fls(new_range);
+       if ((new_range_fls >= SECOND || new_range_fls >= fls(old_range))
+               &&
+               (new_precis >= MAX_INTERVAL_PRECISION || new_precis >= 
old_precis))
+               PG_RETURN_INT32(COERCE_EXEMPT_NOCHANGE | COERCE_EXEMPT_NOERROR);
+ 
+       PG_RETURN_INT32(COERCE_EXEMPT_NOERROR);
+ }
+ 
  /* interval_scale()
   * Adjust interval type for specified fields.
   * Used by PostgreSQL type system to stuff columns.
***************
*** 4529,4534 **** timestamp2timestamptz(Timestamp timestamp)
--- 4596,4619 ----
        return result;
  }
  
+ /* timestamp_tz_exemptor()
+  * Identify superfluous calls to timestamptz_timestamp or 
timestamp_timestamptz.
+  * We effectively store GMT internally; timestamptz converts to local time on
+  * input and output, while timestamp does not.  When local time is GMT, we 
have
+  * nothing to do.
+  */
+ Datum
+ timestamp_tz_exemptor(PG_FUNCTION_ARGS)
+ {
+       int32           ret = COERCE_EXEMPT_NOERROR;
+ 
+       if ((HasCTZSet && CTimeZone == 0)
+               || pg_tzeq_semantic(session_timezone, gmt_timezone))
+               ret |= COERCE_EXEMPT_NOCHANGE;
+ 
+       PG_RETURN_INT32(ret);
+ }
+ 
  /* timestamptz_timestamp()
   * Convert timestamp at GMT to local timestamp
   */
*** a/src/include/catalog/catversion.h
--- b/src/include/catalog/catversion.h
***************
*** 53,58 ****
   */
  
  /*                                                    yyyymmddN */
! #define CATALOG_VERSION_NO    201101101
  
  #endif
--- 53,58 ----
   */
  
  /*                                                    yyyymmddN */
! #define CATALOG_VERSION_NO    201101102
  
  #endif
*** a/src/include/catalog/pg_cast.h
--- b/src/include/catalog/pg_cast.h
***************
*** 255,265 **** DATA(insert ( 1083 1266 2047 0 i f ));
  DATA(insert ( 1114    702 2030 0 a f ));
  DATA(insert ( 1114 1082 2029 0 a f ));
  DATA(insert ( 1114 1083 1316 0 a f ));
! DATA(insert ( 1114 1184 2028 0 i f ));
  DATA(insert ( 1184    702 1180 0 a f ));
  DATA(insert ( 1184 1082 1178 0 a f ));
  DATA(insert ( 1184 1083 2019 0 a f ));
! DATA(insert ( 1184 1114 2027 0 a f ));
  DATA(insert ( 1184 1266 1388 0 a f ));
  DATA(insert ( 1186    703 1194 0 a f ));
  DATA(insert ( 1186 1083 1419 0 a f ));
--- 255,265 ----
  DATA(insert ( 1114    702 2030 0 a f ));
  DATA(insert ( 1114 1082 2029 0 a f ));
  DATA(insert ( 1114 1083 1316 0 a f ));
! DATA(insert ( 1114 1184 2028 3544 i f ));
  DATA(insert ( 1184    702 1180 0 a f ));
  DATA(insert ( 1184 1082 1178 0 a f ));
  DATA(insert ( 1184 1083 2019 0 a f ));
! DATA(insert ( 1184 1114 2027 3544 a f ));
  DATA(insert ( 1184 1266 1388 0 a f ));
  DATA(insert ( 1186    703 1194 0 a f ));
  DATA(insert ( 1186 1083 1419 0 a f ));
***************
*** 350,360 **** DATA(insert ( 1042     142 2896 3831 e f ));
   */
  DATA(insert ( 1042 1042  668 0 i f ));
  DATA(insert ( 1043 1043  669 3829 i f ));
! DATA(insert ( 1083 1083 1968 0 i f ));
! DATA(insert ( 1114 1114 1961 0 i f ));
! DATA(insert ( 1184 1184 1967 0 i f ));
! DATA(insert ( 1186 1186 1200 0 i f ));
! DATA(insert ( 1266 1266 1969 0 i f ));
  DATA(insert ( 1560 1560 1685 0 i f ));
  DATA(insert ( 1562 1562 1687 0 i f ));
  DATA(insert ( 1700 1700 1703 0 i f ));
--- 350,360 ----
   */
  DATA(insert ( 1042 1042  668 0 i f ));
  DATA(insert ( 1043 1043  669 3829 i f ));
! DATA(insert ( 1083 1083 1968 3541 i f ));
! DATA(insert ( 1114 1114 1961 3542 i f ));
! DATA(insert ( 1184 1184 1967 3542 i f ));
! DATA(insert ( 1186 1186 1200 3543 i f ));
! DATA(insert ( 1266 1266 1969 3541 i f ));
  DATA(insert ( 1560 1560 1685 0 i f ));
  DATA(insert ( 1562 1562 1687 0 i f ));
  DATA(insert ( 1700 1700 1703 0 i f ));
*** a/src/include/catalog/pg_proc.h
--- b/src/include/catalog/pg_proc.h
***************
*** 1552,1557 **** DESCR("date difference preserving months and years");
--- 1552,1559 ----
  
  /* OIDS 1200 - 1299 */
  
+ DATA(insert OID = 3543 (  interval_exemptor PGNSP PGUID 12 1 0 0 f f f t f i 
3 0 23 "23 23 16" _null_ _null_ _null_ _null_ interval_exemptor _null_ _null_ 
_null_ ));
+ DESCR("interval_scale cast exemptor");
  DATA(insert OID = 1200 (  interval                    PGNSP PGUID 12 1 0 0 f 
f f t f i 2 0 1186 "1186 23" _null_ _null_ _null_ _null_ interval_scale _null_ 
_null_ _null_ ));
  DESCR("adjust interval precision");
  
***************
*** 3213,3218 **** DESCR("not equal");
--- 3215,3222 ----
  DATA(insert OID = 1954 (  byteacmp               PGNSP PGUID 12 1 0 0 f f f t 
f i 2 0 23 "17 17" _null_ _null_ _null_ _null_ byteacmp _null_ _null_ _null_ ));
  DESCR("less-equal-greater");
  
+ DATA(insert OID = 3542 (  timestamp_exemptor PGNSP PGUID 12 1 0 0 f f f t f i 
3 0 23 "23 23 16" _null_ _null_ _null_ _null_ timestamp_exemptor _null_ _null_ 
_null_ ));
+ DESCR("timestamp_scale cast exemptor");
  DATA(insert OID = 1961 (  timestamp              PGNSP PGUID 12 1 0 0 f f f t 
f i 2 0 1114 "1114 23" _null_ _null_ _null_ _null_ timestamp_scale _null_ 
_null_ _null_ ));
  DESCR("adjust timestamp precision");
  
***************
*** 3223,3228 **** DESCR("smaller of two");
--- 3227,3234 ----
  
  DATA(insert OID = 1967 (  timestamptz    PGNSP PGUID 12 1 0 0 f f f t f i 2 0 
1184 "1184 23" _null_ _null_ _null_ _null_ timestamptz_scale _null_ _null_ 
_null_ ));
  DESCR("adjust timestamptz precision");
+ DATA(insert OID = 3541 (  time_exemptor          PGNSP PGUID 12 1 0 0 f f f t 
f i 3 0 23 "23 23 16" _null_ _null_ _null_ _null_ time_exemptor _null_ _null_ 
_null_ ));
+ DESCR("time_scale cast exemptor");
  DATA(insert OID = 1968 (  time                           PGNSP PGUID 12 1 0 0 
f f f t f i 2 0 1083 "1083 23" _null_ _null_ _null_ _null_ time_scale _null_ 
_null_ _null_ ));
  DESCR("adjust time precision");
  DATA(insert OID = 1969 (  timetz                 PGNSP PGUID 12 1 0 0 f f f t 
f i 2 0 1266 "1266 23" _null_ _null_ _null_ _null_ timetz_scale _null_ _null_ 
_null_ ));
***************
*** 3272,3277 **** DATA(insert OID = 2024 (  timestamp                  PGNSP 
PGUID 12 1 0 0 f f f t f i 1 0 1114
--- 3278,3285 ----
  DESCR("convert date to timestamp");
  DATA(insert OID = 2025 (  timestamp                   PGNSP PGUID 12 1 0 0 f 
f f t f i 2 0 1114 "1082 1083" _null_ _null_ _null_ _null_       
datetime_timestamp _null_ _null_ _null_ ));
  DESCR("convert date and time to timestamp");
+ DATA(insert OID = 3544 (  timestamp_tz_exemptor PGNSP PGUID 12 1 0 0 f f f t 
f s 3 0 23 "23 23 16" _null_ _null_ _null_ _null_ timestamp_tz_exemptor _null_ 
_null_ _null_ ));
+ DESCR("timestamptz_timestamp cast exemptor");
  DATA(insert OID = 2027 (  timestamp                   PGNSP PGUID 12 1 0 0 f 
f f t f s 1 0 1114 "1184" _null_ _null_ _null_ _null_ timestamptz_timestamp 
_null_ _null_ _null_ ));
  DESCR("convert timestamp with time zone to timestamp");
  DATA(insert OID = 2028 (  timestamptz         PGNSP PGUID 12 1 0 0 f f f t f 
s 1 0 1184 "1114" _null_ _null_ _null_ _null_ timestamp_timestamptz _null_ 
_null_ _null_ ));
*** a/src/include/pgtime.h
--- b/src/include/pgtime.h
***************
*** 58,63 **** extern pg_tz *pg_tzset(const char *tzname);
--- 58,64 ----
  extern bool tz_acceptable(pg_tz *tz);
  extern bool pg_get_timezone_offset(const pg_tz *tz, long int *gmtoff);
  extern const char *pg_get_timezone_name(pg_tz *tz);
+ extern bool pg_tzeq_semantic(const pg_tz *a, const pg_tz *b);
  
  extern pg_tzenum *pg_tzenumerate_start(void);
  extern pg_tz *pg_tzenumerate_next(pg_tzenum *dir);
*** a/src/include/port.h
--- b/src/include/port.h
***************
*** 366,371 **** extern long lrand48(void);
--- 366,375 ----
  extern void srand48(long seed);
  #endif
  
+ #ifndef HAVE_FLS
+ extern int fls(int mask);
+ #endif
+ 
  #ifndef HAVE_FSEEKO
  #define fseeko(a, b, c) fseek(a, b, c)
  #define ftello(a)             ftell(a)
*** a/src/include/utils/date.h
--- b/src/include/utils/date.h
***************
*** 153,158 **** extern Datum time_recv(PG_FUNCTION_ARGS);
--- 153,159 ----
  extern Datum time_send(PG_FUNCTION_ARGS);
  extern Datum timetypmodin(PG_FUNCTION_ARGS);
  extern Datum timetypmodout(PG_FUNCTION_ARGS);
+ extern Datum time_exemptor(PG_FUNCTION_ARGS);
  extern Datum time_scale(PG_FUNCTION_ARGS);
  extern Datum time_eq(PG_FUNCTION_ARGS);
  extern Datum time_ne(PG_FUNCTION_ARGS);
*** a/src/include/utils/datetime.h
--- b/src/include/utils/datetime.h
***************
*** 316,321 **** extern int     DecodeUnits(int field, char *lowtoken, int 
*val);
--- 316,323 ----
  
  extern int    j2day(int jd);
  
+ extern int32 TemporalExemptor(int32 max_precis, int32 old_precis, int32 
new_precis);
+ 
  extern bool CheckDateTokenTables(void);
  extern void InstallTimeZoneAbbrevs(tzEntry *abbrevs, int n);
  
*** a/src/include/utils/timestamp.h
--- b/src/include/utils/timestamp.h
***************
*** 208,213 **** extern Datum timestamp_recv(PG_FUNCTION_ARGS);
--- 208,214 ----
  extern Datum timestamp_send(PG_FUNCTION_ARGS);
  extern Datum timestamptypmodin(PG_FUNCTION_ARGS);
  extern Datum timestamptypmodout(PG_FUNCTION_ARGS);
+ extern Datum timestamp_exemptor(PG_FUNCTION_ARGS);
  extern Datum timestamp_scale(PG_FUNCTION_ARGS);
  extern Datum timestamp_eq(PG_FUNCTION_ARGS);
  extern Datum timestamp_ne(PG_FUNCTION_ARGS);
***************
*** 243,248 **** extern Datum interval_recv(PG_FUNCTION_ARGS);
--- 244,250 ----
  extern Datum interval_send(PG_FUNCTION_ARGS);
  extern Datum intervaltypmodin(PG_FUNCTION_ARGS);
  extern Datum intervaltypmodout(PG_FUNCTION_ARGS);
+ extern Datum interval_exemptor(PG_FUNCTION_ARGS);
  extern Datum interval_scale(PG_FUNCTION_ARGS);
  extern Datum interval_eq(PG_FUNCTION_ARGS);
  extern Datum interval_ne(PG_FUNCTION_ARGS);
***************
*** 274,279 **** extern Datum timestamptz_send(PG_FUNCTION_ARGS);
--- 276,282 ----
  extern Datum timestamptztypmodin(PG_FUNCTION_ARGS);
  extern Datum timestamptztypmodout(PG_FUNCTION_ARGS);
  extern Datum timestamptz_scale(PG_FUNCTION_ARGS);
+ extern Datum timestamp_tz_exemptor(PG_FUNCTION_ARGS);
  extern Datum timestamptz_timestamp(PG_FUNCTION_ARGS);
  extern Datum timestamptz_zone(PG_FUNCTION_ARGS);
  extern Datum timestamptz_izone(PG_FUNCTION_ARGS);
*** /dev/null
--- b/src/port/fls.c
***************
*** 0 ****
--- 1,51 ----
+ /*
+  * src/port/fls.c
+  *
+  *    $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/lib/libc/string/fls.c,v 
1.3 2007/01/09 00:28:12 imp Exp $
+  */
+ 
+ /*-
+  * Copyright (c) 1990, 1993
+  *    The Regents of the University of California.  All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 4. Neither the name of the University nor the names of its contributors
+  *    may be used to endorse or promote products derived from this software
+  *    without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  */
+ 
+ #include "c.h"
+ 
+ /*
+  * Find Last Set bit
+  */
+ int
+ fls(int mask)
+ {
+       int bit;
+ 
+       if (mask == 0)
+               return (0);
+       for (bit = 1; mask != 1; bit++)
+               mask = (unsigned int)mask >> 1;
+       return (bit);
+ }
*** a/src/test/regress/expected/alter_table.out
--- b/src/test/regress/expected/alter_table.out
***************
*** 2220,2241 **** DEBUG:  Rebuilding index "t_string_idx1"
  DEBUG:  Rebuilding index "t_string_idx"
  DEBUG:  Rebuilding index "t_daytimetz_key"
  ALTER TABLE t ALTER daytimetz TYPE timetz(2);                                 
        -- noop
- DEBUG:  Rewriting table "t"
- DEBUG:  Rebuilding index "t_daytime_key"
- DEBUG:  Rebuilding index "t_stamptz_key"
- DEBUG:  Rebuilding index "t_stamp_key"
- DEBUG:  Rebuilding index "t_timegap_key"
- DEBUG:  Rebuilding index "t_bits_key"
- DEBUG:  Rebuilding index "t_network_key"
- DEBUG:  Rebuilding index "t_strarr_idx"
- DEBUG:  Rebuilding index "t_square_idx"
- DEBUG:  Rebuilding index "t_touchy_f_idx"
- DEBUG:  Rebuilding index "t_expr_idx"
- DEBUG:  Rebuilding index "t_constraint4_key"
- DEBUG:  Rebuilding index "t_integral_key"
- DEBUG:  Rebuilding index "t_rational_key"
- DEBUG:  Rebuilding index "t_string_idx1"
- DEBUG:  Rebuilding index "t_string_idx"
  DEBUG:  Rebuilding index "t_daytimetz_key"
  ALTER TABLE t ALTER daytimetz TYPE time;                                      
                -- rewrite
  DEBUG:  Rewriting table "t"
--- 2220,2225 ----
***************
*** 2292,2313 **** DEBUG:  Rebuilding index "t_string_idx"
  DEBUG:  Rebuilding index "t_daytimetz_key"
  DEBUG:  Rebuilding index "t_daytime_key"
  ALTER TABLE t ALTER daytime TYPE time(2);                                     
                -- noop
- DEBUG:  Rewriting table "t"
- DEBUG:  Rebuilding index "t_stamptz_key"
- DEBUG:  Rebuilding index "t_stamp_key"
- DEBUG:  Rebuilding index "t_timegap_key"
- DEBUG:  Rebuilding index "t_bits_key"
- DEBUG:  Rebuilding index "t_network_key"
- DEBUG:  Rebuilding index "t_strarr_idx"
- DEBUG:  Rebuilding index "t_square_idx"
- DEBUG:  Rebuilding index "t_touchy_f_idx"
- DEBUG:  Rebuilding index "t_expr_idx"
- DEBUG:  Rebuilding index "t_constraint4_key"
- DEBUG:  Rebuilding index "t_integral_key"
- DEBUG:  Rebuilding index "t_rational_key"
- DEBUG:  Rebuilding index "t_string_idx1"
- DEBUG:  Rebuilding index "t_string_idx"
- DEBUG:  Rebuilding index "t_daytimetz_key"
  DEBUG:  Rebuilding index "t_daytime_key"
  ALTER TABLE t ALTER daytime TYPE timetz;                                      
                -- rewrite
  DEBUG:  Rewriting table "t"
--- 2276,2281 ----
***************
*** 2364,2403 **** DEBUG:  Rebuilding index "t_daytimetz_key"
  DEBUG:  Rebuilding index "t_daytime_key"
  DEBUG:  Rebuilding index "t_stamptz_key"
  ALTER TABLE t ALTER stamptz TYPE timestamptz(2);                              
        -- noop
- DEBUG:  Rewriting table "t"
- DEBUG:  Rebuilding index "t_stamp_key"
- DEBUG:  Rebuilding index "t_timegap_key"
- DEBUG:  Rebuilding index "t_bits_key"
- DEBUG:  Rebuilding index "t_network_key"
- DEBUG:  Rebuilding index "t_strarr_idx"
- DEBUG:  Rebuilding index "t_square_idx"
- DEBUG:  Rebuilding index "t_touchy_f_idx"
- DEBUG:  Rebuilding index "t_expr_idx"
- DEBUG:  Rebuilding index "t_constraint4_key"
- DEBUG:  Rebuilding index "t_integral_key"
- DEBUG:  Rebuilding index "t_rational_key"
- DEBUG:  Rebuilding index "t_string_idx1"
- DEBUG:  Rebuilding index "t_string_idx"
- DEBUG:  Rebuilding index "t_daytimetz_key"
- DEBUG:  Rebuilding index "t_daytime_key"
  DEBUG:  Rebuilding index "t_stamptz_key"
  ALTER TABLE t ALTER stamptz TYPE timestamp;                                   
                -- noop
- DEBUG:  Rewriting table "t"
- DEBUG:  Rebuilding index "t_stamp_key"
- DEBUG:  Rebuilding index "t_timegap_key"
- DEBUG:  Rebuilding index "t_bits_key"
- DEBUG:  Rebuilding index "t_network_key"
- DEBUG:  Rebuilding index "t_strarr_idx"
- DEBUG:  Rebuilding index "t_square_idx"
- DEBUG:  Rebuilding index "t_touchy_f_idx"
- DEBUG:  Rebuilding index "t_expr_idx"
- DEBUG:  Rebuilding index "t_constraint4_key"
- DEBUG:  Rebuilding index "t_integral_key"
- DEBUG:  Rebuilding index "t_rational_key"
- DEBUG:  Rebuilding index "t_string_idx1"
- DEBUG:  Rebuilding index "t_string_idx"
- DEBUG:  Rebuilding index "t_daytimetz_key"
- DEBUG:  Rebuilding index "t_daytime_key"
  DEBUG:  Rebuilding index "t_stamptz_key"
  SET timezone = 'Asia/Jakarta';
  ALTER TABLE t ALTER stamptz TYPE timestamptz;                                 
        -- rewrite
--- 2332,2339 ----
***************
*** 2456,2495 **** DEBUG:  Rebuilding index "t_daytime_key"
  DEBUG:  Rebuilding index "t_stamptz_key"
  DEBUG:  Rebuilding index "t_stamp_key"
  ALTER TABLE t ALTER stamp TYPE timestamp(2);                                  
        -- noop
- DEBUG:  Rewriting table "t"
- DEBUG:  Rebuilding index "t_timegap_key"
- DEBUG:  Rebuilding index "t_bits_key"
- DEBUG:  Rebuilding index "t_network_key"
- DEBUG:  Rebuilding index "t_strarr_idx"
- DEBUG:  Rebuilding index "t_square_idx"
- DEBUG:  Rebuilding index "t_touchy_f_idx"
- DEBUG:  Rebuilding index "t_expr_idx"
- DEBUG:  Rebuilding index "t_constraint4_key"
- DEBUG:  Rebuilding index "t_integral_key"
- DEBUG:  Rebuilding index "t_rational_key"
- DEBUG:  Rebuilding index "t_string_idx1"
- DEBUG:  Rebuilding index "t_string_idx"
- DEBUG:  Rebuilding index "t_daytimetz_key"
- DEBUG:  Rebuilding index "t_daytime_key"
- DEBUG:  Rebuilding index "t_stamptz_key"
  DEBUG:  Rebuilding index "t_stamp_key"
  ALTER TABLE t ALTER stamp TYPE timestamptz;                                   
                -- noop
- DEBUG:  Rewriting table "t"
- DEBUG:  Rebuilding index "t_timegap_key"
- DEBUG:  Rebuilding index "t_bits_key"
- DEBUG:  Rebuilding index "t_network_key"
- DEBUG:  Rebuilding index "t_strarr_idx"
- DEBUG:  Rebuilding index "t_square_idx"
- DEBUG:  Rebuilding index "t_touchy_f_idx"
- DEBUG:  Rebuilding index "t_expr_idx"
- DEBUG:  Rebuilding index "t_constraint4_key"
- DEBUG:  Rebuilding index "t_integral_key"
- DEBUG:  Rebuilding index "t_rational_key"
- DEBUG:  Rebuilding index "t_string_idx1"
- DEBUG:  Rebuilding index "t_string_idx"
- DEBUG:  Rebuilding index "t_daytimetz_key"
- DEBUG:  Rebuilding index "t_daytime_key"
- DEBUG:  Rebuilding index "t_stamptz_key"
  DEBUG:  Rebuilding index "t_stamp_key"
  SET timezone = 'Asia/Jakarta';
  ALTER TABLE t ALTER stamp TYPE timestamp;                                     
                -- rewrite
--- 2392,2399 ----
***************
*** 2548,2569 **** DEBUG:  Rebuilding index "t_stamptz_key"
  DEBUG:  Rebuilding index "t_stamp_key"
  DEBUG:  Rebuilding index "t_timegap_key"
  ALTER TABLE t ALTER timegap TYPE interval(2);                                 
        -- noop
- DEBUG:  Rewriting table "t"
- DEBUG:  Rebuilding index "t_bits_key"
- DEBUG:  Rebuilding index "t_network_key"
- DEBUG:  Rebuilding index "t_strarr_idx"
- DEBUG:  Rebuilding index "t_square_idx"
- DEBUG:  Rebuilding index "t_touchy_f_idx"
- DEBUG:  Rebuilding index "t_expr_idx"
- DEBUG:  Rebuilding index "t_constraint4_key"
- DEBUG:  Rebuilding index "t_integral_key"
- DEBUG:  Rebuilding index "t_rational_key"
- DEBUG:  Rebuilding index "t_string_idx1"
- DEBUG:  Rebuilding index "t_string_idx"
- DEBUG:  Rebuilding index "t_daytimetz_key"
- DEBUG:  Rebuilding index "t_daytime_key"
- DEBUG:  Rebuilding index "t_stamptz_key"
- DEBUG:  Rebuilding index "t_stamp_key"
  DEBUG:  Rebuilding index "t_timegap_key"
  ALTER TABLE t ALTER bits TYPE bit(6);                                         
                -- verify
  DEBUG:  Rewriting table "t"
--- 2452,2457 ----
*** a/src/timezone/pgtz.c
--- b/src/timezone/pgtz.c
***************
*** 1267,1273 **** struct pg_tz *
  pg_tzset(const char *name)
  {
        pg_tz_cache *tzp;
!       struct state tzstate;
        char            uppername[TZ_STRLEN_MAX + 1];
        char            canonname[TZ_STRLEN_MAX + 1];
        char       *p;
--- 1267,1273 ----
  pg_tzset(const char *name)
  {
        pg_tz_cache *tzp;
!       struct state tzstate = {};
        char            uppername[TZ_STRLEN_MAX + 1];
        char            canonname[TZ_STRLEN_MAX + 1];
        char       *p;
***************
*** 1470,1475 **** pg_timezone_initialize(void)
--- 1470,1487 ----
  
  
  /*
+  * Do these time zones have equivalent semantics?  Only the name (tz->TZname 
and
+  * tz->state.chars) may differ.
+  */
+ bool
+ pg_tzeq_semantic(const pg_tz *a, const pg_tz *b)
+ {
+       return memcmp(&a->state, &b->state, offsetof(struct state, chars)) == 0
+               && memcmp(&a->state.lsis, &b->state.lsis, 
sizeof(a->state.lsis)) == 0;
+ }
+ 
+ 
+ /*
   * Functions to enumerate available timezones
   *
   * Note that pg_tzenumerate_next() will return a pointer into the pg_tzenum
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to