Commit b6aa17e0 authored by Tom Lane's avatar Tom Lane

De-support floating-point timestamps.

Per discussion, the time has come to do this.  The handwriting has been
on the wall at least since 9.0 that this would happen someday, whenever
it got to be too much of a burden to support the float-timestamp option.
The triggering factor now is the discovery that there are multiple bugs
in the code that attempts to implement use of integer timestamps in the
replication protocol even when the server is built for float timestamps.
The internal float timestamps leak into the protocol fields in places.
While we could fix the identified bugs, there's a very high risk of
introducing more.  Trying to build a wall that would positively prevent
mixing integer and float timestamps is more complexity than we want to
undertake to maintain a long-deprecated option.  The fact that these
bugs weren't found through testing also indicates a lack of interest
in float timestamps.

This commit disables configure's --disable-integer-datetimes switch
(it'll still accept --enable-integer-datetimes, though), removes direct
references to USE_INTEGER_DATETIMES, and removes discussion of float
timestamps from the user documentation.  A considerable amount of code is
rendered dead by this, but removing that will occur as separate mop-up.

Discussion: https://postgr.es/m/26788.1487455319@sss.pgh.pa.us
parent c3368f91
...@@ -1473,7 +1473,7 @@ Optional Features: ...@@ -1473,7 +1473,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-integer-datetimes --disable-integer-datetimes
disable 64-bit integer date/time support obsolete option, no longer supported
--enable-nls[=LANGUAGES] --enable-nls[=LANGUAGES]
enable Native Language Support enable Native Language Support
--disable-rpath do not embed shared library search path in --disable-rpath do not embed shared library search path in
...@@ -2984,10 +2984,10 @@ fi ...@@ -2984,10 +2984,10 @@ fi
# #
# 64-bit integer date/time storage: enabled by default. # 64-bit integer date/time storage is now the only option, but to avoid
# unnecessary breakage of build scripts, continue to accept an explicit
# "--enable-integer-datetimes" switch.
# #
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build with 64-bit integer date/time support" >&5
$as_echo_n "checking whether to build with 64-bit integer date/time support... " >&6; }
# Check whether --enable-integer-datetimes was given. # Check whether --enable-integer-datetimes was given.
...@@ -2995,12 +2995,10 @@ if test "${enable_integer_datetimes+set}" = set; then : ...@@ -2995,12 +2995,10 @@ if test "${enable_integer_datetimes+set}" = set; then :
enableval=$enable_integer_datetimes; enableval=$enable_integer_datetimes;
case $enableval in case $enableval in
yes) yes)
:
$as_echo "#define USE_INTEGER_DATETIMES 1" >>confdefs.h
;; ;;
no) no)
: as_fn_error $? "--disable-integer-datetimes is no longer supported" "$LINENO" 5
;; ;;
*) *)
as_fn_error $? "no argument expected for --enable-integer-datetimes option" "$LINENO" 5 as_fn_error $? "no argument expected for --enable-integer-datetimes option" "$LINENO" 5
...@@ -3010,13 +3008,9 @@ $as_echo "#define USE_INTEGER_DATETIMES 1" >>confdefs.h ...@@ -3010,13 +3008,9 @@ $as_echo "#define USE_INTEGER_DATETIMES 1" >>confdefs.h
else else
enable_integer_datetimes=yes enable_integer_datetimes=yes
$as_echo "#define USE_INTEGER_DATETIMES 1" >>confdefs.h
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_integer_datetimes" >&5
$as_echo "$enable_integer_datetimes" >&6; }
# #
......
...@@ -122,13 +122,13 @@ PGAC_ARG_REQ(with, libs, [DIRS], [alternative spelling of --with-libraries] ...@@ -122,13 +122,13 @@ PGAC_ARG_REQ(with, libs, [DIRS], [alternative spelling of --with-libraries]
# #
# 64-bit integer date/time storage: enabled by default. # 64-bit integer date/time storage is now the only option, but to avoid
# unnecessary breakage of build scripts, continue to accept an explicit
# "--enable-integer-datetimes" switch.
# #
AC_MSG_CHECKING([whether to build with 64-bit integer date/time support]) PGAC_ARG_BOOL(enable, integer-datetimes, yes, [obsolete option, no longer supported],
PGAC_ARG_BOOL(enable, integer-datetimes, yes, [disable 64-bit integer date/time support], [],
[AC_DEFINE([USE_INTEGER_DATETIMES], 1, [AC_MSG_ERROR([--disable-integer-datetimes is no longer supported])])
[Define to 1 if you want 64-bit integer timestamp and interval support. (--enable-integer-datetimes)])])
AC_MSG_RESULT([$enable_integer_datetimes])
# #
......
...@@ -7695,11 +7695,9 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' ...@@ -7695,11 +7695,9 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
</term> </term>
<listitem> <listitem>
<para> <para>
Reports whether <productname>PostgreSQL</> was built with Reports whether <productname>PostgreSQL</> was built with support for
support for 64-bit-integer dates and times. This can be 64-bit-integer dates and times. As of <productname>PostgreSQL</> 10,
disabled by configuring with <literal>--disable-integer-datetimes</> this is always <literal>on</literal>.
when building <productname>PostgreSQL</>. The default value is
<literal>on</literal>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -1580,7 +1580,7 @@ SELECT E'\\xDEADBEEF'; ...@@ -1580,7 +1580,7 @@ SELECT E'\\xDEADBEEF';
<entry>both date and time (no time zone)</entry> <entry>both date and time (no time zone)</entry>
<entry>4713 BC</entry> <entry>4713 BC</entry>
<entry>294276 AD</entry> <entry>294276 AD</entry>
<entry>1 microsecond / 14 digits</entry> <entry>1 microsecond</entry>
</row> </row>
<row> <row>
<entry><type>timestamp [ (<replaceable>p</replaceable>) ] with time zone</type></entry> <entry><type>timestamp [ (<replaceable>p</replaceable>) ] with time zone</type></entry>
...@@ -1588,7 +1588,7 @@ SELECT E'\\xDEADBEEF'; ...@@ -1588,7 +1588,7 @@ SELECT E'\\xDEADBEEF';
<entry>both date and time, with time zone</entry> <entry>both date and time, with time zone</entry>
<entry>4713 BC</entry> <entry>4713 BC</entry>
<entry>294276 AD</entry> <entry>294276 AD</entry>
<entry>1 microsecond / 14 digits</entry> <entry>1 microsecond</entry>
</row> </row>
<row> <row>
<entry><type>date</type></entry> <entry><type>date</type></entry>
...@@ -1604,15 +1604,15 @@ SELECT E'\\xDEADBEEF'; ...@@ -1604,15 +1604,15 @@ SELECT E'\\xDEADBEEF';
<entry>time of day (no date)</entry> <entry>time of day (no date)</entry>
<entry>00:00:00</entry> <entry>00:00:00</entry>
<entry>24:00:00</entry> <entry>24:00:00</entry>
<entry>1 microsecond / 14 digits</entry> <entry>1 microsecond</entry>
</row> </row>
<row> <row>
<entry><type>time [ (<replaceable>p</replaceable>) ] with time zone</type></entry> <entry><type>time [ (<replaceable>p</replaceable>) ] with time zone</type></entry>
<entry>12 bytes</entry> <entry>12 bytes</entry>
<entry>times of day only, with time zone</entry> <entry>time of day (no date), with time zone</entry>
<entry>00:00:00+1459</entry> <entry>00:00:00+1459</entry>
<entry>24:00:00-1459</entry> <entry>24:00:00-1459</entry>
<entry>1 microsecond / 14 digits</entry> <entry>1 microsecond</entry>
</row> </row>
<row> <row>
<entry><type>interval [ <replaceable>fields</replaceable> ] [ (<replaceable>p</replaceable>) ]</type></entry> <entry><type>interval [ <replaceable>fields</replaceable> ] [ (<replaceable>p</replaceable>) ]</type></entry>
...@@ -1620,7 +1620,7 @@ SELECT E'\\xDEADBEEF'; ...@@ -1620,7 +1620,7 @@ SELECT E'\\xDEADBEEF';
<entry>time interval</entry> <entry>time interval</entry>
<entry>-178000000 years</entry> <entry>-178000000 years</entry>
<entry>178000000 years</entry> <entry>178000000 years</entry>
<entry>1 microsecond / 14 digits</entry> <entry>1 microsecond</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
...@@ -1643,41 +1643,7 @@ SELECT E'\\xDEADBEEF'; ...@@ -1643,41 +1643,7 @@ SELECT E'\\xDEADBEEF';
<replaceable>p</replaceable> which specifies the number of <replaceable>p</replaceable> which specifies the number of
fractional digits retained in the seconds field. By default, there fractional digits retained in the seconds field. By default, there
is no explicit bound on precision. The allowed range of is no explicit bound on precision. The allowed range of
<replaceable>p</replaceable> is from 0 to 6 for the <replaceable>p</replaceable> is from 0 to 6.
<type>timestamp</type> and <type>interval</type> types.
</para>
<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. In this case, the internal representation
is the number of microseconds before or after midnight 2000-01-01.
When <type>timestamp</> values are stored as double precision
floating-point numbers (a deprecated compile-time option), the
internal representation is the number of seconds before or after
midnight 2000-01-01. With this representation, the effective limit
of precision might be less than 6; in practice,
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>
<para>
For the <type>time</type> types, the allowed range of
<replaceable>p</replaceable> is from 0 to 6 when eight-byte integer
storage is used, or from 0 to 10 when floating-point storage is used.
</para> </para>
<para> <para>
...@@ -1760,9 +1726,10 @@ MINUTE TO SECOND ...@@ -1760,9 +1726,10 @@ MINUTE TO SECOND
specification giving the number of specification giving the number of
fractional digits in the seconds field. Precision can be fractional digits in the seconds field. Precision can be
specified for <type>time</type>, <type>timestamp</type>, and specified for <type>time</type>, <type>timestamp</type>, and
<type>interval</type> types. The allowed values are mentioned <type>interval</type> types, and can range from 0 to 6.
above. If no precision is specified in a constant specification, If no precision is specified in a constant specification,
it defaults to the precision of the literal value. it defaults to the precision of the literal value (but not
more than 6 digits).
</para> </para>
<sect3> <sect3>
......
...@@ -955,28 +955,6 @@ su - postgres ...@@ -955,28 +955,6 @@ su - postgres
</listitem> </listitem>
</varlistentry> </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.4, 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>
<varlistentry> <varlistentry>
<term><option>--disable-float4-byval</option></term> <term><option>--disable-float4-byval</option></term>
<listitem> <listitem>
......
...@@ -340,10 +340,11 @@ typedef unsigned PG_INT128_TYPE uint128; ...@@ -340,10 +340,11 @@ typedef unsigned PG_INT128_TYPE uint128;
#define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF) #define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF)
#define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF) #define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF)
/* Select timestamp representation (float8 or int64) */ /*
#ifdef USE_INTEGER_DATETIMES * We now always use int64 timestamps, but keep this symbol defined for the
* benefit of external code that might test it.
*/
#define HAVE_INT64_TIMESTAMP #define HAVE_INT64_TIMESTAMP
#endif
/* /*
* Size * Size
......
...@@ -831,10 +831,6 @@ ...@@ -831,10 +831,6 @@
(--enable-float8-byval) */ (--enable-float8-byval) */
#undef USE_FLOAT8_BYVAL #undef USE_FLOAT8_BYVAL
/* Define to 1 if you want 64-bit integer timestamp and interval support.
(--enable-integer-datetimes) */
#undef USE_INTEGER_DATETIMES
/* Define to 1 to build with LDAP support. (--with-ldap) */ /* Define to 1 to build with LDAP support. (--with-ldap) */
#undef USE_LDAP #undef USE_LDAP
......
...@@ -625,10 +625,6 @@ ...@@ -625,10 +625,6 @@
/* Define to use /dev/urandom for random number generation */ /* Define to use /dev/urandom for random number generation */
/* #undef USE_DEV_URANDOM */ /* #undef USE_DEV_URANDOM */
/* Define to 1 if you want 64-bit integer timestamp and interval support.
(--enable-integer-datetimes) */
/* #undef USE_INTEGER_DATETIMES */
/* Define to 1 to build with LDAP support. (--with-ldap) */ /* Define to 1 to build with LDAP support. (--with-ldap) */
/* #undef USE_LDAP */ /* #undef USE_LDAP */
......
...@@ -10,10 +10,6 @@ ...@@ -10,10 +10,6 @@
/* Define to 1 if `long long int' works and is 64 bits. */ /* Define to 1 if `long long int' works and is 64 bits. */
#undef HAVE_LONG_LONG_INT_64 #undef HAVE_LONG_LONG_INT_64
/* Define to 1 if you want 64-bit integer timestamp and interval support.
(--enable-integer-datetimes) */
#undef USE_INTEGER_DATETIMES
/* Define to 1 to build client libraries as thread-safe code. /* Define to 1 to build client libraries as thread-safe code.
* (--enable-thread-safety) */ * (--enable-thread-safety) */
#undef ENABLE_THREAD_SAFETY #undef ENABLE_THREAD_SAFETY
...@@ -20,9 +20,7 @@ typedef long long int int64; ...@@ -20,9 +20,7 @@ typedef long long int int64;
#error must have a working 64-bit integer datatype #error must have a working 64-bit integer datatype
#endif #endif
#ifdef USE_INTEGER_DATETIMES
#define HAVE_INT64_TIMESTAMP #define HAVE_INT64_TIMESTAMP
#endif
#endif /* C_H */ #endif /* C_H */
typedef struct typedef struct
......
...@@ -145,10 +145,8 @@ main(void) ...@@ -145,10 +145,8 @@ main(void)
sprintf(t, "%s %s", dates[i], times[j]); sprintf(t, "%s %s", dates[i], times[j]);
ts1 = PGTYPEStimestamp_from_asc(t, NULL); ts1 = PGTYPEStimestamp_from_asc(t, NULL);
text = PGTYPEStimestamp_to_asc(ts1); text = PGTYPEStimestamp_to_asc(ts1);
/* skip outputs sensitive to USE_INTEGER_DATETIMES */ printf("TS[%d,%d]: %s\n",
if (i != 19 || (j != 3 && j != 4)) i, j, errno ? "-" : text);
printf("TS[%d,%d]: %s\n",
i, j, errno ? "-" : text);
free(text); free(text);
free(t); free(t);
} }
......
...@@ -103,6 +103,8 @@ Date[19]: 0099-01-08 BC (N - F) ...@@ -103,6 +103,8 @@ Date[19]: 0099-01-08 BC (N - F)
TS[19,0]: 0099-01-08 00:04:00 BC TS[19,0]: 0099-01-08 00:04:00 BC
TS[19,1]: 0099-01-08 01:59:00 BC TS[19,1]: 0099-01-08 01:59:00 BC
TS[19,2]: 0099-01-08 13:24:40 BC TS[19,2]: 0099-01-08 13:24:40 BC
TS[19,3]: 0099-01-08 13:24:40.495 BC
TS[19,4]: 0099-01-08 13:24:40.123456 BC
Date[20]: - (N - T) Date[20]: - (N - T)
Date[21]: - (N - T) Date[21]: - (N - T)
interval[0]: @ 1 min interval[0]: @ 1 min
......
...@@ -110,10 +110,8 @@ main(void) ...@@ -110,10 +110,8 @@ main(void)
sprintf(t, "%s %s", dates[i], times[j]); sprintf(t, "%s %s", dates[i], times[j]);
ts1 = PGTYPEStimestamp_from_asc(t, NULL); ts1 = PGTYPEStimestamp_from_asc(t, NULL);
text = PGTYPEStimestamp_to_asc(ts1); text = PGTYPEStimestamp_to_asc(ts1);
/* skip outputs sensitive to USE_INTEGER_DATETIMES */ printf("TS[%d,%d]: %s\n",
if (i != 19 || (j != 3 && j != 4)) i, j, errno ? "-" : text);
printf("TS[%d,%d]: %s\n",
i, j, errno ? "-" : text);
free(text); free(text);
free(t); free(t);
} }
......
...@@ -28,9 +28,6 @@ sub _new ...@@ -28,9 +28,6 @@ sub _new
$self->DeterminePlatform(); $self->DeterminePlatform();
my $bits = $self->{platform} eq 'Win32' ? 32 : 64; my $bits = $self->{platform} eq 'Win32' ? 32 : 64;
# integer_datetimes is now the default
$options->{integer_datetimes} = 1
unless exists $options->{integer_datetimes};
$options->{float4byval} = 1 $options->{float4byval} = 1
unless exists $options->{float4byval}; unless exists $options->{float4byval};
$options->{float8byval} = ($bits == 64) $options->{float8byval} = ($bits == 64)
...@@ -169,8 +166,6 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY ...@@ -169,8 +166,6 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY
print O "#ifndef IGNORE_CONFIGURED_SETTINGS\n"; print O "#ifndef IGNORE_CONFIGURED_SETTINGS\n";
print O "#define USE_ASSERT_CHECKING 1\n" print O "#define USE_ASSERT_CHECKING 1\n"
if ($self->{options}->{asserts}); if ($self->{options}->{asserts});
print O "#define USE_INTEGER_DATETIMES 1\n"
if ($self->{options}->{integer_datetimes});
print O "#define USE_LDAP 1\n" if ($self->{options}->{ldap}); print O "#define USE_LDAP 1\n" if ($self->{options}->{ldap});
print O "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib}); print O "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib});
print O "#define USE_OPENSSL 1\n" if ($self->{options}->{openssl}); print O "#define USE_OPENSSL 1\n" if ($self->{options}->{openssl});
...@@ -427,8 +422,6 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY ...@@ -427,8 +422,6 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY
#define HAVE_LONG_LONG_INT_64 #define HAVE_LONG_LONG_INT_64
#define ENABLE_THREAD_SAFETY 1 #define ENABLE_THREAD_SAFETY 1
EOF EOF
print O "#define USE_INTEGER_DATETIMES 1\n"
if ($self->{options}->{integer_datetimes});
print O "#endif\n"; print O "#endif\n";
close(O); close(O);
} }
...@@ -661,8 +654,6 @@ sub GetFakeConfigure ...@@ -661,8 +654,6 @@ sub GetFakeConfigure
my $cfg = '--enable-thread-safety'; my $cfg = '--enable-thread-safety';
$cfg .= ' --enable-cassert' if ($self->{options}->{asserts}); $cfg .= ' --enable-cassert' if ($self->{options}->{asserts});
$cfg .= ' --enable-integer-datetimes'
if ($self->{options}->{integer_datetimes});
$cfg .= ' --enable-nls' if ($self->{options}->{nls}); $cfg .= ' --enable-nls' if ($self->{options}->{nls});
$cfg .= ' --enable-tap-tests' if ($self->{options}->{tap_tests}); $cfg .= ' --enable-tap-tests' if ($self->{options}->{tap_tests});
$cfg .= ' --with-ldap' if ($self->{options}->{ldap}); $cfg .= ' --with-ldap' if ($self->{options}->{ldap});
......
...@@ -4,7 +4,6 @@ use warnings; ...@@ -4,7 +4,6 @@ use warnings;
our $config = { our $config = {
asserts => 0, # --enable-cassert asserts => 0, # --enable-cassert
# integer_datetimes=>1, # --enable-integer-datetimes - on is now default
# float4byval=>1, # --disable-float4-byval, on by default # float4byval=>1, # --disable-float4-byval, on by default
# float8byval=> $platformbits == 64, # --disable-float8-byval, # float8byval=> $platformbits == 64, # --disable-float8-byval,
......
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