Attached is a patch that enables integer datetimes by default, per
recent discussion on -hackers. It makes "--enable-integer-datetimes" the
default, and documents the "--disable-integer-datetimes" configure
option as a means to get the previous default behavior.

Barring any objections, I'll apply this to HEAD tomorrow.

-Neil

Index: configure
===================================================================
RCS file: /home/neilc/postgres/cvs_root/pgsql/configure,v
retrieving revision 1.547
diff -c -p -r1.547 configure
*** configure	4 May 2007 15:20:50 -0000	1.547
--- configure	6 May 2007 03:10:08 -0000
*************** if test -n "$ac_init_help"; then
*** 859,865 ****
  Optional Features:
    --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
    --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
!   --enable-integer-datetimes  enable 64-bit integer date/time support
    --enable-nls[=LANGUAGES]  enable Native Language Support
    --disable-shared        do not build shared libraries
    --disable-rpath         do not embed shared library search path in executables
--- 859,865 ----
  Optional Features:
    --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
    --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
!   --disable-integer-datetimes  disable 64-bit integer date/time support
    --enable-nls[=LANGUAGES]  enable Native Language Support
    --disable-shared        do not build shared libraries
    --disable-rpath         do not embed shared library search path in executables
*************** fi;
*** 1699,1705 ****
  
  
  #
! # 64-bit integer date/time storage (--enable-integer-datetimes)
  #
  echo "$as_me:$LINENO: checking whether to build with 64-bit integer date/time support" >&5
  echo $ECHO_N "checking whether to build with 64-bit integer date/time support... $ECHO_C" >&6
--- 1699,1705 ----
  
  
  #
! # 64-bit integer date/time storage: enabled by default.
  #
  echo "$as_me:$LINENO: checking whether to build with 64-bit integer date/time support" >&5
  echo $ECHO_N "checking whether to build with 64-bit integer date/time support... $ECHO_C" >&6
*************** echo "$as_me: error: no argument expecte
*** 1729,1735 ****
    esac
  
  else
!   enable_integer_datetimes=no
  
  fi;
  
--- 1729,1739 ----
    esac
  
  else
!   enable_integer_datetimes=yes
! 
! cat >>confdefs.h <<\_ACEOF
! #define USE_INTEGER_DATETIMES 1
! _ACEOF
  
  fi;
  
*************** fi
*** 22277,22282 ****
--- 22281,22306 ----
  
  
  
+ # If the user did not disable integer datetimes, check that
+ # there is a working 64-bit integral type to use.
+ if test x"$USE_INTEGER_DATETIMES" = x"yes" &&
+    test x"$HAVE_LONG_INT_64" = x"no" &&
+    test x"$HAVE_LONG_LONG_INT_64" = x"no" &&
+    test x"$HAVE_INT64" = x"no" ; then
+   { { echo "$as_me:$LINENO: error:
+ Integer-based datetime support requires a 64-bit integer type,
+ but no such type could be found. The --disable-integer-datetimes
+ configure option can be used to disable integer-based storage
+ of datetime values." >&5
+ echo "$as_me: error:
+ Integer-based datetime support requires a 64-bit integer type,
+ but no such type could be found. The --disable-integer-datetimes
+ configure option can be used to disable integer-based storage
+ of datetime values." >&2;}
+    { (exit 1); exit 1; }; }
+ fi
+ 
+ 
  if test "$PORTNAME" != "win32"
  then
  echo "$as_me:$LINENO: checking for POSIX signal interface" >&5
Index: configure.in
===================================================================
RCS file: /home/neilc/postgres/cvs_root/pgsql/configure.in,v
retrieving revision 1.514
diff -c -p -r1.514 configure.in
*** configure.in	4 May 2007 15:20:52 -0000	1.514
--- configure.in	6 May 2007 03:08:04 -0000
*************** PGAC_ARG_REQ(with, libs,      [  --with-
*** 137,146 ****
  
  
  #
! # 64-bit integer date/time storage (--enable-integer-datetimes)
  #
  AC_MSG_CHECKING([whether to build with 64-bit integer date/time support])
! PGAC_ARG_BOOL(enable, integer-datetimes, no, [  --enable-integer-datetimes  enable 64-bit integer date/time support],
                [AC_DEFINE([USE_INTEGER_DATETIMES], 1,
                           [Define to 1 if you want 64-bit integer timestamp and interval support. (--enable-integer-datetimes)])])
  AC_MSG_RESULT([$enable_integer_datetimes])
--- 137,146 ----
  
  
  #
! # 64-bit integer date/time storage: enabled by default.
  #
  AC_MSG_CHECKING([whether to build with 64-bit integer date/time support])
! PGAC_ARG_BOOL(enable, integer-datetimes, yes, [  --disable-integer-datetimes  disable 64-bit integer date/time support],
                [AC_DEFINE([USE_INTEGER_DATETIMES], 1,
                           [Define to 1 if you want 64-bit integer timestamp and interval support. (--enable-integer-datetimes)])])
  AC_MSG_RESULT([$enable_integer_datetimes])
*************** AC_CHECK_TYPES([int8, uint8, int64, uint
*** 1362,1367 ****
--- 1362,1381 ----
  AC_CHECK_TYPES(sig_atomic_t, [], [], [#include <signal.h>])
  
  
+ # If the user did not disable integer datetimes, check that
+ # there is a working 64-bit integral type to use.
+ if test x"$USE_INTEGER_DATETIMES" = x"yes" &&
+    test x"$HAVE_LONG_INT_64" = x"no" &&
+    test x"$HAVE_LONG_LONG_INT_64" = x"no" &&
+    test x"$HAVE_INT64" = x"no" ; then
+   AC_MSG_ERROR([
+ Integer-based datetime support requires a 64-bit integer type,
+ but no such type could be found. The --disable-integer-datetimes
+ configure option can be used to disable integer-based storage
+ of datetime values.])
+ fi
+ 
+ 
  if test "$PORTNAME" != "win32"
  then
  PGAC_FUNC_POSIX_SIGNALS
Index: doc/src/sgml/config.sgml
===================================================================
RCS file: /home/neilc/postgres/cvs_root/pgsql/doc/src/sgml/config.sgml,v
retrieving revision 1.122
diff -c -p -r1.122 config.sgml
*** doc/src/sgml/config.sgml	20 Apr 2007 02:37:37 -0000	1.122
--- doc/src/sgml/config.sgml	6 May 2007 02:44:02 -0000
*************** dynamic_library_path = 'C:\tools\postgre
*** 4384,4394 ****
        </indexterm>
        <listitem>
         <para>
!         Reports whether <productname>PostgreSQL</productname> was built
!         with support for 64-bit-integer dates and times.  It is set by
!         configuring with <literal>--enable-integer-datetimes</literal>
!         when building <productname>PostgreSQL</productname>.  The
!         default value is <literal>off</literal>.
         </para>
        </listitem>
       </varlistentry>
--- 4384,4394 ----
        </indexterm>
        <listitem>
         <para>
!         Reports whether <productname>PostgreSQL</> was built with
!         support for 64-bit-integer dates and times.  This can be
!         disabled by configuring with <literal>--disable-integer-datetimes</>
!         when building <productname>PostgreSQL</>.  The default value is
!         <literal>on</literal>.
         </para>
        </listitem>
       </varlistentry>
Index: doc/src/sgml/datatype.sgml
===================================================================
RCS file: /home/neilc/postgres/cvs_root/pgsql/doc/src/sgml/datatype.sgml,v
retrieving revision 1.199
diff -c -p -r1.199 datatype.sgml
*** doc/src/sgml/datatype.sgml	3 May 2007 15:05:56 -0000	1.199
--- doc/src/sgml/datatype.sgml	6 May 2007 02:52:35 -0000
*************** SELECT b, char_length(b) FROM test2;
*** 1376,1382 ****
          <entry>8 bytes</entry>
          <entry>both date and time</entry>
          <entry>4713 BC</entry>
!         <entry>5874897 AD</entry>
          <entry>1 microsecond / 14 digits</entry>
         </row>
         <row>
--- 1376,1382 ----
          <entry>8 bytes</entry>
          <entry>both date and time</entry>
          <entry>4713 BC</entry>
!         <entry>294276 AD</entry>
          <entry>1 microsecond / 14 digits</entry>
         </row>
         <row>
*************** SELECT b, char_length(b) FROM test2;
*** 1384,1390 ****
          <entry>8 bytes</entry>
          <entry>both date and time, with time zone</entry>
          <entry>4713 BC</entry>
!         <entry>5874897 AD</entry>
          <entry>1 microsecond / 14 digits</entry>
         </row>
         <row>
--- 1384,1390 ----
          <entry>8 bytes</entry>
          <entry>both date and time, with time zone</entry>
          <entry>4713 BC</entry>
!         <entry>294276 AD</entry>
          <entry>1 microsecond / 14 digits</entry>
         </row>
         <row>
*************** SELECT b, char_length(b) FROM test2;
*** 1443,1462 ****
  
     <note>
     <para>
!     When <type>timestamp</> values are stored as double precision floating-point
!     numbers (currently the default), the effective limit of precision
!     might be less than 6. <type>timestamp</type> values are stored as seconds
!     before or after midnight 2000-01-01.  Microsecond precision is achieved for
!     dates within a few years of 2000-01-01, but the precision degrades for
!     dates further away.  When <type>timestamp</type> values are stored as
!     eight-byte integers (a compile-time
!     option), microsecond precision is available over the full range of
!     values. However eight-byte integer timestamps have a more limited range of
!     dates than shown above: from 4713 BC up to 294276 AD.  The same
!     compile-time option also determines whether <type>time</type> and
!     <type>interval</type> values are stored as floating-point or eight-byte
!     integers.  In the floating-point case, large <type>interval</type> values
!     degrade in precision as the size of the interval increases.
     </para>
     </note>
  
--- 1443,1469 ----
  
     <note>
     <para>
!     When <type>timestamp</> values are stored as eight-byte integers
!     (currently the default), microsecond precision is available over
!     the full range of values. When <type>timestamp</> values are
!     stored as double precision floating-point numbers instead (a
!     deprecated compile-time option), the effective limit of precision
!     might be less than 6. <type>timestamp</type> values are stored as
!     seconds before or after midnight 2000-01-01.  When
!     <type>timestamp</type> values are implemented using floating-point
!     numbers, microsecond precision is achieved for dates within a few
!     years of 2000-01-01, but the precision degrades for dates further
!     away. Note that using floating-point datetimes allows a larger
!     range of <type>timestamp</type> values to be represented than
!     shown above: from 4713 BC up to 5874897 AD.
!    </para>
! 
!    <para>
!     The same compile-time option also determines whether
!     <type>time</type> and <type>interval</type> values are stored as
!     floating-point numbers or eight-byte integers.  In the
!     floating-point case, large <type>interval</type> values degrade in
!     precision as the size of the interval increases.
     </para>
     </note>
  
Index: doc/src/sgml/installation.sgml
===================================================================
RCS file: /home/neilc/postgres/cvs_root/pgsql/doc/src/sgml/installation.sgml,v
retrieving revision 1.289
diff -c -p -r1.289 installation.sgml
*** doc/src/sgml/installation.sgml	25 Apr 2007 13:01:41 -0000	1.289
--- doc/src/sgml/installation.sgml	6 May 2007 03:09:56 -0000
*************** su - postgres
*** 958,973 ****
        </varlistentry>
  
        <varlistentry>
!        <term><option>--enable-integer-datetimes</option></term>
         <listitem>
          <para>
!          Use 64-bit integer storage for datetimes and intervals, rather
!          than the default floating-point storage.  This reduces the range
!          of representable values but guarantees microsecond precision across
!          the full range (see
           <![%standalone-include[the documentation about datetime datatypes]]>
           <![%standalone-ignore[<xref linkend="datatype-datetime">]]>
!          for more information).
          </para>
         </listitem>
        </varlistentry>
--- 958,980 ----
        </varlistentry>
  
        <varlistentry>
!        <term><option>--disable-integer-datetimes</option></term>
         <listitem>
          <para>
!          Disable support for 64-bit integer storage for timestamps and
!          intervals, and store datetime values as floating-point
!          numbers instead. Floating-point datetime storage was the
!          default in <productname>PostgreSQL</productname> releases
!          prior to 8.3, but it is now deprecated, because it does not
!          support microsecond precision for the full range of
!          <type>timestamp</type> values. However, integer-based
!          datetime storage requires a 64-bit integer type. Therefore,
!          this option can be used when no such type is available, or
!          for compatibility with applications written for prior
!          versions of <productname>PostgreSQL</productname>. See
           <![%standalone-include[the documentation about datetime datatypes]]>
           <![%standalone-ignore[<xref linkend="datatype-datetime">]]>
!          for more information.
          </para>
         </listitem>
        </varlistentry>
---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to