Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0AB2B200CF0 for ; Thu, 7 Sep 2017 16:05:19 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 09EDA16186B; Thu, 7 Sep 2017 14:05:19 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4E39416185B for ; Thu, 7 Sep 2017 16:05:18 +0200 (CEST) Received: (qmail 47537 invoked by uid 500); 7 Sep 2017 14:05:17 -0000 Mailing-List: contact reviews-help@impala.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@impala.incubator.apache.org Received: (qmail 47526 invoked by uid 99); 7 Sep 2017 14:05:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Sep 2017 14:05:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 958E31A0EFA for ; Thu, 7 Sep 2017 14:05:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.363 X-Spam-Level: X-Spam-Status: No, score=0.363 tagged_above=-999 required=6.31 tests=[RDNS_DYNAMIC=0.363, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id BXL_KDIeoyAY for ; Thu, 7 Sep 2017 14:05:11 +0000 (UTC) Received: from ip-10-146-233-104.ec2.internal (ec2-75-101-130-251.compute-1.amazonaws.com [75.101.130.251]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 252C65FAC9 for ; Thu, 7 Sep 2017 14:05:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by ip-10-146-233-104.ec2.internal (8.14.4/8.14.4) with ESMTP id v87E57Z0022521; Thu, 7 Sep 2017 14:05:07 GMT Message-Id: <201709071405.v87E57Z0022521@ip-10-146-233-104.ec2.internal> Date: Thu, 7 Sep 2017 14:05:07 +0000 From: "Csaba Ringhofer (Code Review)" To: impala-cr@cloudera.com, reviews@impala.incubator.apache.org CC: Lars Volker Reply-To: csringhofer@cloudera.com X-Gerrit-MessageType: newpatchset Subject: =?UTF-8?Q?=5BImpala-ASF-CR=5D_IMPALA-5664=3A_Unix_time_to_timestamp_conversions_may_crash_Impala=0A?= X-Gerrit-Change-Id: I77b2f6284d3a597f57e61c17a67c959eff9e38ff X-Gerrit-ChangeURL: X-Gerrit-Commit: 33dfb6679ee8cae0619cae7873b20a35db6f2b69 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.12.7 archived-at: Thu, 07 Sep 2017 14:05:19 -0000 Csaba Ringhofer has uploaded a new patch set (#2). Change subject: IMPALA-5664: Unix time to timestamp conversions may crash Impala ...................................................................... IMPALA-5664: Unix time to timestamp conversions may crash Impala TimestampValue::FromSubsecondUnixTime() and UtcFromUnixTimeMicros() are incorrect only in case of the last second of 1399, because these sub-second values are rounded first towards 1400-01-01 00:00:00, which is accepted as a valid date, and the sub-second part is subtracted afterwards, leading to a date outside the valid interval. The maximum case, 9999-12-31 59:59:59 is a bit different, because as I understand, with nanosecond precision posix times, the maximum value is actually 10000-01-01. 00:00:00 minus 1 nanosec. TimestampValue::FromUnixTimeNanos() can create problematic TimestampValues both <1400 and 10000<=. These timestamps can cause problems, because most code assumes that if HasDate/HasTime is true, then it really is a valid timestamp. To fix this, the posix times are checked in the constructor of TimestampValue, and if it is outside the valid interval,both time_ and date_ are set to not_a_date_time. Test: select cast(-17987443200-0.1 as timestamp); This query no longer crashes, but returns NULL, similarly to other < 1400 timestamps. Change-Id: I77b2f6284d3a597f57e61c17a67c959eff9e38ff --- M be/src/runtime/timestamp-test.cc M be/src/runtime/timestamp-value.h 2 files changed, 34 insertions(+), 1 deletion(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/54/7954/2 -- To view, visit http://gerrit.cloudera.org:8080/7954 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I77b2f6284d3a597f57e61c17a67c959eff9e38ff Gerrit-PatchSet: 2 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Csaba Ringhofer Gerrit-Reviewer: Lars Volker