Skip to content

Commit

Permalink
IMPALA-5357: Patch boost time_duration bug
Browse files Browse the repository at this point in the history
Upstream boost issue:
https://svn.boost.org/trac/boost/ticket/4543

Backported from upstream date_time:
boostorg/date_time@818dea5

This fixes an issue in which time_duration was using an
int32 internally, limiting its year range from 1902-2038. With this
fix, time_duration supports years from 1677-2262. Note this
is still not as wide as Impala's supported timestamp range
(which is 1600-9999), but still enables Impala to use boost
in most common cases to address IMPALA-5357.

Change-Id: Idee1b84bd7d3515c98c482e691119d04dc71f929
  • Loading branch information
Matthew Jacobs committed Jun 2, 2017
1 parent f0105fd commit 6e726b4
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 3 deletions.
7 changes: 4 additions & 3 deletions buildall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ source ./init-compiler.sh
################################################################################
if (( BUILD_HISTORICAL )) ; then
BOOST_VERSION=1.57.0 $SOURCE_DIR/source/boost/build.sh
BOOST_VERSION=1.57.0-p1 $SOURCE_DIR/source/boost/build.sh
fi
BOOST_VERSION=1.57.0-p1 $SOURCE_DIR/source/boost/build.sh
BOOST_VERSION=1.57.0-p2 $SOURCE_DIR/source/boost/build.sh

################################################################################
# Build Python
Expand Down Expand Up @@ -120,7 +121,7 @@ ZLIB_VERSION=1.2.8 $SOURCE_DIR/source/zlib/build.sh
# Thrift
# * depends on boost, zlib and openssl
################################################################################
export BOOST_VERSION=1.57.0-p1
export BOOST_VERSION=1.57.0-p2
export ZLIB_VERSION=1.2.8
export OPENSSL_VERSION=1.0.1p

Expand Down Expand Up @@ -266,7 +267,7 @@ FLATBUFFERS_VERSION=1.6.0 $SOURCE_DIR/source/flatbuffers/build.sh
# Build Kudu
################################################################################
(
export BOOST_VERSION=1.57.0-p1
export BOOST_VERSION=1.57.0-p2
export KUDU_VERSION=795c435
if $SOURCE_DIR/source/kudu/build.sh is_supported_platform; then
$SOURCE_DIR/source/kudu/build.sh build
Expand Down
68 changes: 68 additions & 0 deletions source/boost/boost-1.57.0-patches/0002-IMPALA-5357.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
commit 48511bddf4ad90b0f04842949b7edd5617209e25
Author: James E. King, III <jim.king@simplivity.com>
Date: Tue Feb 21 16:37:53 2017 -0500

4543: fix ptime 2038 issue

(cherry picked from commit 818dea52f3f0c8b4f5172df13c5fa4f57340625f)

Conflicts:
include/boost/date_time/posix_time/conversion.hpp
include/boost/date_time/time_resolution_traits.hpp

diff --git a/boost/date_time/posix_time/conversion.hpp b/boost/date_time/posix_time/conversion.hpp
index 59e5cb7..7900775 100644
--- a/boost/date_time/posix_time/conversion.hpp
+++ b/boost/date_time/posix_time/conversion.hpp
@@ -10,6 +10,7 @@
*/

#include <cstring>
+#include <boost/cstdint.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <boost/date_time/posix_time/posix_time_duration.hpp>
#include <boost/date_time/filetime_functions.hpp>
@@ -21,13 +22,18 @@ namespace boost {

namespace posix_time {

-
//! Function that converts a time_t into a ptime.
inline
ptime from_time_t(std::time_t t)
{
- ptime start(gregorian::date(1970,1,1));
- return start + seconds(static_cast<long>(t));
+ return ptime(gregorian::date(1970,1,1)) + seconds(t);
+ }
+
+ //! Function that converts a ptime into a time_t
+ inline
+ std::time_t to_time_t(ptime pt)
+ {
+ return (pt - ptime(gregorian::date(1970,1,1))).total_seconds();
}

//! Convert a time to a tm structure truncating any fractional seconds
diff --git a/boost/date_time/time_resolution_traits.hpp b/boost/date_time/time_resolution_traits.hpp
index 37785d0..3df147b 100644
--- a/boost/date_time/time_resolution_traits.hpp
+++ b/boost/date_time/time_resolution_traits.hpp
@@ -9,7 +9,7 @@
* $Date$
*/

-
+#include <ctime>
#include <boost/cstdint.hpp>
#include <boost/date_time/time_defs.hpp>
#include <boost/date_time/int_adapter.hpp>
@@ -68,7 +68,7 @@ namespace date_time {
typename frac_sec_type::int_type resolution_adjust,
#endif
unsigned short frac_digits,
- typename v_type = boost::int32_t >
+ typename v_type = std::time_t >
class time_resolution_traits {
public:
typedef typename frac_sec_type::int_type fractional_seconds_type;

0 comments on commit 6e726b4

Please sign in to comment.