add test cases and change code according to review comments

Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/0c50d95f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/0c50d95f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/0c50d95f

Branch: refs/heads/master
Commit: 0c50d95f04ed235c371e86c80191c8925fbc12fc
Parents: 17ea935
Author: Liu Ming <lium...@apache.org>
Authored: Fri Sep 16 13:30:52 2016 +0000
Committer: Liu Ming <lium...@apache.org>
Committed: Fri Sep 16 13:30:52 2016 +0000

----------------------------------------------------------------------
 core/sql/exp/exp_conv.cpp            |  6 ++++-
 core/sql/regress/seabase/EXPECTED003 | 42 +++++++++++++++++++++++++++++++
 core/sql/regress/seabase/TEST003     |  3 +++
 3 files changed, 50 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/0c50d95f/core/sql/exp/exp_conv.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_conv.cpp b/core/sql/exp/exp_conv.cpp
index a368654..18f527b 100644
--- a/core/sql/exp/exp_conv.cpp
+++ b/core/sql/exp/exp_conv.cpp
@@ -2109,6 +2109,10 @@ ex_expr::exp_return_type convAsciiToInt64(Int64 &target,
       target = (Int64)tempTgt;
       return ex_expr::EXPR_OK;
     }
+  /* remove below code according to discussion in github
+   * https://github.com/apache/incubator-trafodion/pull/706
+   * with above validation, below checking is no longer needed
+   * comment out
   
   if (-(Int64)tempTgt < LLONG_MIN)
     {
@@ -2118,7 +2122,7 @@ ex_expr::exp_return_type convAsciiToInt64(Int64 &target,
                             REC_BIN64_SIGNED, flags);
       return ex_expr::EXPR_ERROR;
     }
-
+  */
   target = - (Int64)tempTgt;
 
   return ex_expr::EXPR_OK;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/0c50d95f/core/sql/regress/seabase/EXPECTED003
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED003 
b/core/sql/regress/seabase/EXPECTED003
index 9afa030..268cf66 100644
--- a/core/sql/regress/seabase/EXPECTED003
+++ b/core/sql/regress/seabase/EXPECTED003
@@ -1160,6 +1160,20 @@ A                     (EXPR)
 
 --- 2 row(s) selected.
 >>
+>>select cast('-9223372036854775808' as largeint) from (values(1)) x(a);
+
+(EXPR)
+----------
+
+-9223372036854775808
+
+--- 1 row(s) selected.
+>>select cast('-9223372036854775809' as largeint) from (values(1)) x(a);
+
+*** ERROR[8411] A numeric overflow occurred during an arithmetic computation 
or data conversion. Conversion of Source Type:CHAR(REC_BYTE_F_ASCII,20 
BYTES,ISO88591) Source Value:-9223372036854775809 to Target 
Type:LARGEINT(REC_BIN64_SIGNED).
+
+--- 0 row(s) selected.
+>>
 >>select a+10 from t003t2 where a = 1 or a = -1;
 
 (EXPR)              
@@ -1504,6 +1518,20 @@ A                     (EXPR)
 
 --- 2 row(s) selected.
 >>
+>>select cast('-9223372036854775808' as largeint) from (values(1)) x(a);
+
+(EXPR)
+----------
+
+-9223372036854775808
+
+--- 1 row(s) selected.
+>>select cast('-9223372036854775809' as largeint) from (values(1)) x(a);
+
+*** ERROR[8411] A numeric overflow occurred during an arithmetic computation 
or data conversion. Conversion of Source Type:CHAR(REC_BYTE_F_ASCII,20 
BYTES,ISO88591) Source Value:-9223372036854775809 to Target 
Type:LARGEINT(REC_BIN64_SIGNED).
+
+--- 0 row(s) selected.
+>>
 >>select a+10 from t003t2 where a = 1 or a = -1;
 
 (EXPR)              
@@ -1851,6 +1879,20 @@ A                      (EXPR)
 
 --- 2 row(s) selected.
 >>
+>>select cast('-9223372036854775808' as largeint) from (values(1)) x(a);
+
+(EXPR)
+----------
+
+-9223372036854775808
+
+--- 1 row(s) selected.
+>>select cast('-9223372036854775809' as largeint) from (values(1)) x(a);
+
+*** ERROR[8411] A numeric overflow occurred during an arithmetic computation 
or data conversion. Conversion of Source Type:CHAR(REC_BYTE_F_ASCII,20 
BYTES,ISO88591) Source Value:-9223372036854775809 to Target 
Type:LARGEINT(REC_BIN64_SIGNED).
+
+--- 0 row(s) selected.
+>>
 >>select a+10 from t003t2 where a = 1 or a = -1;
 
 (EXPR)              

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/0c50d95f/core/sql/regress/seabase/TEST003
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST003 b/core/sql/regress/seabase/TEST003
index 2497f28..5a39599 100644
--- a/core/sql/regress/seabase/TEST003
+++ b/core/sql/regress/seabase/TEST003
@@ -221,6 +221,9 @@ select * from t003t2 where b = 18446744073709551615;
 
 select a, cast(cast(a as varchar(40)) as largeint unsigned) from t003t2;
 
+select cast('-9223372036854775808' as largeint) from (values(1)) x(a);
+select cast('-9223372036854775809' as largeint) from (values(1)) x(a);
+
 select a+10 from t003t2 where a = 1 or a = -1;
 
 select cast(100 as largeint unsigned) from (values(1)) x(a);

Reply via email to