trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ansha...@apache.org
Subject [01/11] incubator-trafodion git commit: support for largeint unsigned: commit #1
Date Fri, 01 Jul 2016 14:46:19 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 6ad816e31 -> 5f77bd291


support for largeint unsigned: commit #1


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

Branch: refs/heads/master
Commit: ef98b7d8dcad6cf2041f33a016985b2db889ba4b
Parents: e014f8e
Author: Anoop Sharma <anoop.sharma@esgyn.com>
Authored: Sat Jun 18 23:22:13 2016 +0000
Committer: Anoop Sharma <anoop.sharma@esgyn.com>
Committed: Sat Jun 18 23:22:13 2016 +0000

----------------------------------------------------------------------
 core/sql/cli/Cli.cpp                |   1 +
 core/sql/cli/Descriptor.cpp         |   8 +
 core/sql/cli/sqlcli.h               |   1 +
 core/sql/common/BaseTypes.cpp       |  25 +
 core/sql/common/ComSmallDefs.h      |   4 +
 core/sql/common/ComSysUtils.h       |  21 +
 core/sql/common/Int64.cpp           |  20 +
 core/sql/common/Int64.h             |  12 +
 core/sql/common/NAType.cpp          |   4 +
 core/sql/common/NAType.h            |   5 +
 core/sql/common/NumericType.cpp     |  39 +-
 core/sql/common/NumericType.h       |  15 +-
 core/sql/common/SQLTypeDefs.h       |   1 +
 core/sql/common/dfs2rec.h           |   3 +-
 core/sql/exp/exp_attrs.cpp          |   1 +
 core/sql/exp/exp_clause_derived.h   |  23 +-
 core/sql/exp/exp_conv.cpp           | 931 ++++++++++++++++++++++++++++++-
 core/sql/exp/exp_fixup.cpp          |  22 +-
 core/sql/exp/exp_function.cpp       |  13 +
 core/sql/generator/GenPreCode.cpp   |  30 +-
 core/sql/optimizer/EncodedValue.cpp |   6 +
 core/sql/optimizer/ItemExpr.cpp     |   1 +
 core/sql/optimizer/NAColumn.cpp     |  17 +
 core/sql/optimizer/NATable.cpp      |  17 +
 core/sql/parser/StmtDDLCreate.cpp   |   1 +
 core/sql/parser/sqlparser.y         |   9 +-
 core/sql/sqlci/Formatter.cpp        |   5 +
 core/sql/sqlci/Param.cpp            |   1 +
 28 files changed, 1183 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/cli/Cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Cli.cpp b/core/sql/cli/Cli.cpp
index ecfe072..7ea31c4 100644
--- a/core/sql/cli/Cli.cpp
+++ b/core/sql/cli/Cli.cpp
@@ -660,6 +660,7 @@ static Lng32 getNumericHostVarInfo(Descriptor *desc,
           ind_length = 4;
           break;
         case REC_BIN64_SIGNED:
+        case REC_BIN64_UNSIGNED:
           ind_length = 8;
           break;
         default:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/cli/Descriptor.cpp
----------------------------------------------------------------------
diff --git a/core/sql/cli/Descriptor.cpp b/core/sql/cli/Descriptor.cpp
index 5af9568..da76a0c 100644
--- a/core/sql/cli/Descriptor.cpp
+++ b/core/sql/cli/Descriptor.cpp
@@ -95,6 +95,7 @@ Lng32 Descriptor::setIndLength(desc_struct &descItem)
       descItem.ind_length = 4;
       break;
     case REC_BIN64_SIGNED:
+    case REC_BIN64_UNSIGNED:
       descItem.ind_length = 8;
       break;
     default:
@@ -117,6 +118,7 @@ Lng32 Descriptor::setVarLength(desc_struct &descItem)
       descItem.length = 4;
       break;
     case REC_BIN64_SIGNED:
+    case REC_BIN64_UNSIGNED:
     case REC_FLOAT64:
       descItem.length = 8;
       break;
@@ -1361,6 +1363,7 @@ short Descriptor::isIntegralFSType(Lng32 datatype)
    case REC_BIN32_SIGNED:
    case REC_BIN32_UNSIGNED:
    case REC_BIN64_SIGNED:
+   case REC_BIN64_UNSIGNED:
       return TRUE;
 
    default:
@@ -2047,12 +2050,15 @@ RETCODE Descriptor::processNumericDatatypeWithPrecision(desc_struct &descItem,
 	}
       else if ((descItem.datatype == REC_BIN16_UNSIGNED) ||
 	       (descItem.datatype == REC_BIN32_UNSIGNED) ||
+	       (descItem.datatype == REC_BIN64_UNSIGNED) ||
 	       (descItem.datatype == REC_NUM_BIG_UNSIGNED))
 	{
 	  if (((descItem.datatype == REC_BIN16_UNSIGNED) &&
 	       (descItem.precision > 4)) ||
 	      ((descItem.datatype == REC_BIN32_UNSIGNED) &&
 	       (descItem.precision > 9)) ||
+	      ((descItem.datatype == REC_BIN64_UNSIGNED) &&
+	       (descItem.precision > 18)) ||
 	      ((descItem.datatype == REC_NUM_BIG_UNSIGNED) &&
 	       (descItem.precision > 128)))
 	    {
@@ -2061,6 +2067,8 @@ RETCODE Descriptor::processNumericDatatypeWithPrecision(desc_struct &descItem,
 		maxPrec = 4;
 	      else if (descItem.datatype == REC_BIN32_UNSIGNED)
 		maxPrec = 9;
+	      else if (descItem.datatype == REC_BIN64_UNSIGNED)
+		maxPrec = 18;
 	      else
 		maxPrec = 128;
 	      diags << DgSqlCode(-3008) 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/cli/sqlcli.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/sqlcli.h b/core/sql/cli/sqlcli.h
index 6a05797..04ec0e8 100644
--- a/core/sql/cli/sqlcli.h
+++ b/core/sql/cli/sqlcli.h
@@ -348,6 +348,7 @@ enum SQLTYPE_CODE {
     /* INTEGER/INT Tandem extensions */
     SQLTYPECODE_INTEGER_UNSIGNED       = -401,
     SQLTYPECODE_LARGEINT               = -402,
+    SQLTYPECODE_LARGEINT_UNSIGNED      = -405,
 
     /* TINYINT */
     SQLTYPECODE_TINYINT                = -403,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/BaseTypes.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/BaseTypes.cpp b/core/sql/common/BaseTypes.cpp
index 8db8f5b..fa154d9 100644
--- a/core/sql/common/BaseTypes.cpp
+++ b/core/sql/common/BaseTypes.cpp
@@ -378,6 +378,19 @@ short convertTypeToText_basic(char * text,	   // OUTPUT
 	}
       break;
 
+    case REC_BIN64_UNSIGNED:
+      if ((!precision) && (scale == 0))
+	str_sprintf(text, "LARGEINT UNSIGNED");
+      else
+	{
+	  if (! precision)
+	    str_sprintf(text, "NUMERIC(%d, %d) UNSIGNED",
+			18/*MAX_NUMERIC_PRECISION*/, scale);
+	  else
+	    str_sprintf(text, "NUMERIC(%d, %d) UNSIGNED", precision, scale);
+	}
+      break;
+
     case REC_BIN32_SIGNED:
       if (!precision)
 	str_sprintf(text, "INT");
@@ -702,6 +715,10 @@ Lng32 getAnsiTypeFromFSType(Lng32 datatype)
       numeric_value = SQLTYPECODE_LARGEINT;
       break;
 
+   case REC_BIN64_UNSIGNED:
+      numeric_value = SQLTYPECODE_LARGEINT_UNSIGNED;
+      break;
+
    case REC_FLOAT32:
       numeric_value = SQLTYPECODE_IEEE_REAL;
       break;
@@ -811,6 +828,10 @@ const char * getAnsiTypeStrFromFSType(Lng32 datatype)
      return COM_LARGEINT_SIGNED_SDT_LIT;
      break;
 
+   case REC_BIN64_UNSIGNED:
+     return COM_LARGEINT_UNSIGNED_SDT_LIT;
+     break;
+
    case REC_FLOAT32:
      return COM_REAL_SDT_LIT;
       break;
@@ -1058,6 +1079,10 @@ Lng32 getFSTypeFromANSIType(Lng32 ansitype)
       datatype = REC_BIN64_SIGNED;
       break;
 
+   case SQLTYPECODE_LARGEINT_UNSIGNED:
+      datatype = REC_BIN64_UNSIGNED;
+      break;
+
    case SQLTYPECODE_NUMERIC :
        datatype = REC_BIN32_SIGNED;
        break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 19c7dde..3101b2b 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -1000,6 +1000,7 @@ enum ComODBCDataType { COM_UNKNOWN_ODT
                      , COM_INTEGER_SIGNED_ODT
                      , COM_INTEGER_UNSIGNED_ODT
                      , COM_LARGEINT_SIGNED_ODT
+                     , COM_LARGEINT_UNSIGNED_ODT
                      , COM_BIGINT_SIGNED_ODT
                      , COM_FLOAT_ODT
                      , COM_REAL_ODT
@@ -1030,6 +1031,7 @@ enum ComODBCDataType { COM_UNKNOWN_ODT
 #define COM_INTEGER_SIGNED_ODT_LIT             "SIGNED INTEGER    "
 #define COM_INTEGER_UNSIGNED_ODT_LIT           "UNSIGNED INTEGER  "
 #define COM_LARGEINT_SIGNED_ODT_LIT            "SIGNED LARGEINT   "
+#define COM_LARGEINT_UNSIGNED_ODT_LIT          "UNSIGNED LARGEINT "
 #define COM_BIGINT_SIGNED_ODT_LIT              "SIGNED BIGINT     "
 #define COM_FLOAT_ODT_LIT                      "FLOAT             "
 #define COM_REAL_ODT_LIT                       "REAL              "
@@ -1559,6 +1561,7 @@ enum ComSQLDataType { COM_UNKNOWN_SDT
                     , COM_INTEGER_SIGNED_SDT
                     , COM_INTEGER_UNSIGNED_SDT
                     , COM_LARGEINT_SIGNED_SDT
+                    , COM_LARGEINT_UNSIGNED_SDT
                     , COM_FLOAT_SDT
                     , COM_REAL_SDT
                     , COM_DOUBLE_SDT
@@ -1589,6 +1592,7 @@ enum ComSQLDataType { COM_UNKNOWN_SDT
 #define COM_INTEGER_UNSIGNED_SDT_LIT           "UNSIGNED INTEGER  "
 #define COM_BPINT_UNSIGNED_SDT_LIT             "UNSIGNED BP INT   "
 #define COM_LARGEINT_SIGNED_SDT_LIT            "SIGNED LARGEINT   "
+#define COM_LARGEINT_UNSIGNED_SDT_LIT          "UNSIGNED LARGEINT "
 #define COM_FLOAT_SDT_LIT                      "FLOAT             "
 #define COM_REAL_SDT_LIT                       "REAL              "
 #define COM_DOUBLE_SDT_LIT                     "DOUBLE            "

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/ComSysUtils.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSysUtils.h b/core/sql/common/ComSysUtils.h
index 9d5a939..866a553 100644
--- a/core/sql/common/ComSysUtils.h
+++ b/core/sql/common/ComSysUtils.h
@@ -129,6 +129,27 @@ inline Int64 reversebytes( Int64 xx )
 
     return sink.xx;
 }
+
+inline UInt64 reversebytes( UInt64 xx )
+{
+    union {
+        UInt64 xx;
+        char c[8];
+    } source;
+
+    union {
+        UInt64 xx;
+        char c[8];
+    } sink;
+
+    source.xx = xx;
+
+    for (Int32 i=0; i<8; i++)
+        sink.c[i] = source.c[7-i];
+
+    return sink.xx;
+}
+
 #ifdef NA_64BIT /* Needed when _int64 and Int64 don't resolve to same basic type */
 /*inline _int64 reversebytes( _int64 sometexianendian )
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/Int64.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/Int64.cpp b/core/sql/common/Int64.cpp
index 42eaa77..fe7adb9 100644
--- a/core/sql/common/Int64.cpp
+++ b/core/sql/common/Int64.cpp
@@ -61,6 +61,10 @@ double convertInt64ToDouble(const Int64 &src)
   return (double) src;
 }
 
+double convertUInt64ToDouble(const UInt64 &src)
+{
+  return (double) src;
+}
 
 Int64 uint32ArrayToInt64(const UInt32 array[2])
 {
@@ -136,6 +140,22 @@ void convertInt64ToAscii(const Int64 &src, char* tgt)
   strcpy(tgt, s);
 }
 
+void convertUInt64ToAscii(const UInt64 &src, char* tgt)
+{
+  UInt64 temp = src;  // (src >= 0) ? src : - src;
+  char buffer[21];
+  char *s = &buffer[21];
+  *--s = '\0';
+  do {
+    char c = (char) (temp % 10);
+    if (c < 0)
+      c = -c;
+    *--s = (char)(c + '0');
+    temp /= 10;
+  } while (temp != 0);
+  strcpy(tgt, s);
+}
+
 void convertInt64ToUInt32Array(const Int64 &src, UInt32 *tgt)
 {
   Lng32 *tPtr = (Lng32 *) &src;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/Int64.h
----------------------------------------------------------------------
diff --git a/core/sql/common/Int64.h b/core/sql/common/Int64.h
index f29447d..e388afe 100644
--- a/core/sql/common/Int64.h
+++ b/core/sql/common/Int64.h
@@ -109,9 +109,21 @@ NA_EIDPROC
 void convertInt64ToAscii(const Int64 &src, char* tgt);
 
 // -----------------------------------------------------------------------
+// Convert the unsigned integer to ascii.
+// -----------------------------------------------------------------------
+NA_EIDPROC
+void convertUInt64ToAscii(const UInt64 &src, char* tgt);
+
+// -----------------------------------------------------------------------
 // Convert the integer to double.
 // -----------------------------------------------------------------------
 NA_EIDPROC
 double convertInt64ToDouble(const Int64 &src);
 
+// -----------------------------------------------------------------------
+// Convert the integer to double.
+// -----------------------------------------------------------------------
+NA_EIDPROC
+double convertUInt64ToDouble(const UInt64 &src);
+
 #endif /* INT64_H */

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/NAType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/NAType.cpp b/core/sql/common/NAType.cpp
index 3553888..6e09949 100644
--- a/core/sql/common/NAType.cpp
+++ b/core/sql/common/NAType.cpp
@@ -520,6 +520,10 @@ Lng32 NAType::getDisplayLength(Lng32 datatype,
       d_len = SQL_LARGE_DISPLAY_SIZE + scale_len;
       break;
 
+    case REC_BIN64_UNSIGNED:
+      d_len = SQL_ULARGE_DISPLAY_SIZE + scale_len;
+      break;
+
     case REC_BYTE_F_ASCII:
       d_len = length;
       break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/NAType.h
----------------------------------------------------------------------
diff --git a/core/sql/common/NAType.h b/core/sql/common/NAType.h
index ea4c64d..a50df3d 100644
--- a/core/sql/common/NAType.h
+++ b/core/sql/common/NAType.h
@@ -581,6 +581,11 @@ public:
 
   virtual NABoolean roundTripConversionToDouble() const { return FALSE; };
 
+  // used during expr generation to indicate if conversion to/from otherFsType
+  // is supported by expr evaluator.
+  virtual NABoolean expConvSupported
+  (const NAType &otherNAType) const { return TRUE; }
+
 protected:
 
   // ---------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/NumericType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/NumericType.cpp b/core/sql/common/NumericType.cpp
index 47d30ba..d2a5081 100644
--- a/core/sql/common/NumericType.cpp
+++ b/core/sql/common/NumericType.cpp
@@ -1341,7 +1341,6 @@ SQLLargeInt::SQLLargeInt(NABoolean allowNegValues, NABoolean allowSQLnull,
 		  ,heap
           )
 {
-  assert(allowNegValues);
 }   // SQLLargeInt()
 
 SQLLargeInt::SQLLargeInt(Lng32 scale,
@@ -1360,19 +1359,28 @@ SQLLargeInt::SQLLargeInt(Lng32 scale,
 		  ,heap
           )
 {
-  assert(allowNegValues);
 }   // SQLLargeInt()
 
 
 double SQLLargeInt::encode (void* bufPtr) const
 {
   Int64 tempValue;
+  UInt64 usTempValue;
+
   char * valPtr = (char *)bufPtr;
   if (supportsSQLnull())
     valPtr += getSQLnullHdrSize();
 
-  str_cpy_all ((char *)&tempValue, valPtr, getNominalSize());
-  return (convertInt64ToDouble(tempValue) * pow(10.0, -1 * getScale()));
+  if (isUnsigned())
+  {
+    str_cpy_all ((char *)&usTempValue, valPtr, getNominalSize());
+    return (convertUInt64ToDouble(tempValue) * pow(10.0, -1 * getScale()));
+  }
+  else
+  {
+    str_cpy_all ((char *)&tempValue, valPtr, getNominalSize());
+    return (convertInt64ToDouble(tempValue) * pow(10.0, -1 * getScale()));
+  }
 }
 
 void SQLLargeInt::minRepresentableValue
@@ -1438,12 +1446,31 @@ NAString* SQLLargeInt::convertToString(double v, CollHeap* h) const
 {
    char nameBuf[NAME_BUF_LEN];   // a reasonably large buffer
 
-   Int64 temp = Int64(v);
-   convertInt64ToAscii(temp, nameBuf);
+   if (NumericType::isUnsigned()) {
+     UInt64 temp = (UInt64)v;
+     convertUInt64ToAscii(temp, nameBuf);
+   } else {
+     Int64 temp = Int64(v);
+     convertInt64ToAscii(temp, nameBuf);
+   }
 
    return new (h) NAString(nameBuf, h);
 }
 
+NABoolean SQLLargeInt::expConvSupported
+(const NAType &otherNAType) const
+{
+  if (NOT isUnsigned())
+    return TRUE;
+
+  if ((otherNAType.getFSDatatype() == REC_BIN64_SIGNED) ||
+      (otherNAType.getFSDatatype() == REC_BIN64_UNSIGNED) ||
+      (DFS2REC::isAnyCharacter(otherNAType.getFSDatatype())))
+    return TRUE;
+
+  return FALSE;
+}
+
 // -----------------------------------------------------------------------
 //  Methods for SQLBigInt
 // -----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/NumericType.h
----------------------------------------------------------------------
diff --git a/core/sql/common/NumericType.h b/core/sql/common/NumericType.h
index 448d8bf..b561d9b 100644
--- a/core/sql/common/NumericType.h
+++ b/core/sql/common/NumericType.h
@@ -120,9 +120,7 @@ public:
   NABoolean isBigNum() const { return qualifier_ == SQLBigNum_TYPE;}
   NABoolean isInternalType() const { return (isBigNum()); }
  
-  NABoolean supportsSign () const  {return (isExact () &&
-					    SQLLarge_TYPE != qualifier_ );
-  }
+  NABoolean supportsSign () const  {return TRUE;}
 
   // ---------------------------------------------------------------------
   // Accessor functions for the precision, magnitude, scale and unsigned
@@ -745,7 +743,10 @@ public:
 
   short getFSDatatype() const
     {
-      return REC_BIN64_SIGNED;
+      if (isUnsigned())
+        return REC_BIN64_UNSIGNED;
+      else
+        return REC_BIN64_SIGNED;
     }
 
   virtual Lng32 getMagnitude() const { return 189; }
@@ -812,6 +813,9 @@ public:
   virtual double getNormalizedValue(void* buf) const 
   { return (double) *(Int64 *)buf; }
 
+  virtual NABoolean expConvSupported
+  (const NAType &otherNAType) const;
+
 private:
 
   NAString clientDataType_; // added the protected string to distinguish 
@@ -907,7 +911,8 @@ public:
 	  else
 	    if (getNominalSize() == sizeof(Lng32))
 	      return REC_BIN32_UNSIGNED;
-	    else return REC_BIN64_SIGNED;
+	    else 
+              return REC_BIN64_UNSIGNED;
 	}
       else
 	{

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/SQLTypeDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/SQLTypeDefs.h b/core/sql/common/SQLTypeDefs.h
index 61b3258..e1a73a0 100644
--- a/core/sql/common/SQLTypeDefs.h
+++ b/core/sql/common/SQLTypeDefs.h
@@ -85,6 +85,7 @@
 #define SQL_INT_DISPLAY_SIZE 11
 #define SQL_UINT_DISPLAY_SIZE 10
 #define SQL_LARGE_DISPLAY_SIZE 20
+#define SQL_ULARGE_DISPLAY_SIZE 20
 #define SQL_REAL_DISPLAY_SIZE 15
 #define SQL_REAL_MIN_DISPLAY_SIZE 9
 #define SQL_REAL_FRAG_DIGITS 7

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/common/dfs2rec.h
----------------------------------------------------------------------
diff --git a/core/sql/common/dfs2rec.h b/core/sql/common/dfs2rec.h
index 88852fc..7036eba 100644
--- a/core/sql/common/dfs2rec.h
+++ b/core/sql/common/dfs2rec.h
@@ -60,7 +60,8 @@
 #define REC_BPINT_UNSIGNED 135	// Bit Precision Integer
 #define REC_BIN8_SIGNED 136     // tinyint signed
 #define REC_BIN8_UNSIGNED 137   // tinyint unsigned
-#define REC_MAX_BINARY 137
+#define REC_BIN64_UNSIGNED 138
+#define REC_MAX_BINARY 138
 
 #define REC_MIN_FLOAT   142
 #define REC_IEEE_FLOAT32 142

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/exp/exp_attrs.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_attrs.cpp b/core/sql/exp/exp_attrs.cpp
index b9d3b09..9259481 100644
--- a/core/sql/exp/exp_attrs.cpp
+++ b/core/sql/exp/exp_attrs.cpp
@@ -227,6 +227,7 @@ switch (datatype)
   case REC_BIN32_SIGNED: return extFormat? (char *)"INTEGER SIGNED":(char *)"REC_BIN32_SIGNED";
   case REC_BIN32_UNSIGNED: return extFormat? (char *)"INTEGER UNSIGNED":(char *)"REC_BIN32_UNSIGNED";
   case REC_BIN64_SIGNED: return extFormat? (char *)"LARGEINT":(char *)"REC_BIN64_SIGNED";
+  case REC_BIN64_UNSIGNED: return extFormat? (char *)"LARGEINT UNSIGNED":(char *)"REC_BIN64_UNSIGNED";
   case REC_BPINT_UNSIGNED: return extFormat? (char *)"BIT PRECISION INTEGER":(char *)"REC_BPINT_UNSIGNED";
 
   case REC_IEEE_FLOAT32: return extFormat? (char *)"IEEE FLOAT":(char *)"REC_IEEE_FLOAT32";

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/exp/exp_clause_derived.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_clause_derived.h b/core/sql/exp/exp_clause_derived.h
index 5301ada..2718606 100644
--- a/core/sql/exp/exp_clause_derived.h
+++ b/core/sql/exp/exp_clause_derived.h
@@ -1559,7 +1559,28 @@ enum conv_case_index {
   CONV_BIN16S_BIN8U                    =261,
   CONV_BIN8U_BIN16S                    =262,
   CONV_ASCII_BIN8S                     =263,
-  CONV_ASCII_BIN8U                     =264
+  CONV_ASCII_BIN8U                     =264,
+
+  // unsigned largeint related conversions
+  CONV_BIN16S_BIN64U                   =265,   
+  CONV_BIN16U_BIN64U                   =266,   
+  CONV_BIN32S_BIN64U                   =267,   
+  CONV_BIN32U_BIN64U                   =268,   
+  CONV_BIN64S_BIN64U                   =269,
+  CONV_BIN64U_BIN64U                   =270,
+  CONV_FLOAT32_BIN64U                  =271, 
+  CONV_FLOAT64_BIN64U                  =272,
+
+  CONV_BIN64U_BIN16S                   =273,
+  CONV_BIN64U_BIN16U                   =274,   
+  CONV_BIN64U_BIN32S                   =275,
+  CONV_BIN64U_BIN32U                   =276,
+  CONV_BIN64U_BIN64S                   =277,
+  CONV_BIN64U_FLOAT32                  =278,
+  CONV_BIN64U_FLOAT64                  =279,
+  CONV_BIN64U_ASCII                    =280,
+  CONV_ASCII_BIN64U                    =281
+
 };
 
 class SQLEXP_LIB_FUNC  ex_conv_clause : public ex_clause {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/exp/exp_conv.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_conv.cpp b/core/sql/exp/exp_conv.cpp
index 1057ff2..e510288 100644
--- a/core/sql/exp/exp_conv.cpp
+++ b/core/sql/exp/exp_conv.cpp
@@ -88,7 +88,7 @@ NA_EIDPROC
 Int64 getMaxDecValue(Lng32 targetLen);
 
 NA_EIDPROC
-Lng32 getDigitCount(Int64 value);
+Lng32 getDigitCount(UInt64 value);
 
 NA_EIDPROC
 void setVCLength(char * VCLen, Lng32 VCLenSize, ULng32 value);
@@ -569,12 +569,13 @@ ex_expr::exp_return_type convInt64ToAscii(char *target,
 					  char filler,
 					  NABoolean leadingSign,
                                           NABoolean leftPad,
+                                          NABoolean srcIsUInt64,
 					  CollHeap *heap,
 					  ComDiagsArea** diagsArea) {
 
   Lng32 digitCnt = 0;
   ULng32 flags = 0;
-  NABoolean negative = (source < 0);
+  NABoolean negative = (srcIsUInt64 ? FALSE : (source < 0));
   NABoolean fixRightMost  = FALSE;  // True if need to fix the rightmost digit.
   
   Int16 trgType;
@@ -591,7 +592,7 @@ ex_expr::exp_return_type convInt64ToAscii(char *target,
   Lng32 sign = 0;
 
   //  Int64 newSource = (negative ? -source : source);
-  Int64 newSource = 0;
+  UInt64 newSource = 0;
 
   if (targetPrecision)
     {
@@ -602,8 +603,7 @@ ex_expr::exp_return_type convInt64ToAscii(char *target,
       assert(targetLen >= targetPrecision);
     }
 
-//SQ_LINUX #ifndef NA_HSC
-if ((negative) && (source == 0x8000000000000000LL)) // = -2 ** 63
+  if ((negative) && (source == 0x8000000000000000LL)) // = -2 ** 63
     {
       newSource = 0x7fffffffffffffffLL;
       //             123456789012345
@@ -612,7 +612,7 @@ if ((negative) && (source == 0x8000000000000000LL)) // = -2 ** 63
     }
   else
     {
-      newSource = (negative ? -source : source);
+      newSource = (UInt64) (negative ? -source : source);
       digitCnt = getDigitCount(newSource);
     }
 
@@ -877,7 +877,7 @@ short convFloat64ToAscii(char *target,
     convInt64ToAscii(tempTarget, digits+3, 0, targetScale,
                      (neg ? -intMantissa : intMantissa),
 		     digits, NULL, 0, ' ',
-		     neg, TRUE, NULL, NULL);
+		     neg, TRUE, FALSE, NULL, NULL);
   if (error)
     return -1;
 
@@ -896,7 +896,7 @@ short convFloat64ToAscii(char *target,
     convInt64ToAscii(&tempTarget[digits+4], 4, 0, targetScale,
                      (expPos ? expon : -expon), 
 		     0, NULL, 0, '0',
-		     TRUE, TRUE, NULL, NULL);
+		     TRUE, TRUE, FALSE, NULL, NULL);
   if (error)
     return -1;
 
@@ -1753,6 +1753,293 @@ ex_expr::exp_return_type convAsciiToFloat64(char * target,
   return ex_expr::EXPR_OK;
 };
 
+NABoolean isNegative(char *source, Lng32 sourceLen, Lng32 &currPos)
+{
+  // skip leading blanks and look for leading sign
+  NABoolean done = FALSE;
+  NABoolean negative = FALSE;
+  while ((NOT done) && (currPos < sourceLen))
+    {
+      if ((source[currPos] == '+') || (source[currPos] == '-'))
+        {
+          negative = (source[currPos] == '-');
+          done = TRUE;
+          currPos++; // skip pass sign
+        }
+      else if (source[currPos] == ' ')
+        currPos++;
+      else
+        done = TRUE;
+    }
+
+  return negative;
+}
+
+ex_expr::exp_return_type convAsciiToUInt64base(UInt64 &target,
+                                           Lng32 targetScale,
+                                           char *source,
+                                           Lng32 sourceLen,
+                                           CollHeap *heap,
+                                           ComDiagsArea** diagsArea,
+                                           ULng32 flags)
+{
+  NABoolean SignFound = FALSE;   // did we find a sign (+/-)
+  NABoolean DigitsAllowed = TRUE;
+  NABoolean negative = FALSE;    // default is a positive value
+  NABoolean pointFound = FALSE;  // did we find a decimal point
+  Lng32 currPos = 0;              // current position in the string
+  short digitCnt = 0;            // digits found so far
+  Lng32 sourceScale = 0;          // default is a scale of 0
+
+  target = 0;
+  while (currPos < sourceLen)
+    {
+    if ((source[currPos] >= '0') && (source[currPos] <= '9'))
+      { // process digits
+      if (!DigitsAllowed)
+        {
+	// syntax error in the input
+        ExRaiseSqlError(heap, diagsArea, EXE_CONVERT_STRING_ERROR);
+	return ex_expr::EXPR_ERROR;
+        }
+      digitCnt++;
+
+      // if we've read enough source characters to achieve the needed 
+      // targetScale, then stop appending digits to the target value.
+      //   They would only be thrown away later.
+      if ( !pointFound || sourceScale < targetScale )
+	{           // this digit needs to be processed.
+
+        // if we found a decimal point before, another digit increases
+        // the source scale
+        if (pointFound)
+	  sourceScale++;
+
+        Int32 thisDigit = source[currPos] - '0';
+        if (digitCnt > 18)
+          {
+          // check overflow/underflow
+          if (target > (ULLONG_MAX / 10))
+            { // next power of 10 causes an overflow
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, REC_BYTE_F_ASCII,
+                                    SQLCHARSETCODE_ISO88591,
+                                    REC_BIN64_SIGNED, flags);
+              return ex_expr::EXPR_ERROR;
+            }
+          target *= 10;
+          Int64 tempMax = ULLONG_MAX;
+          tempMax -= thisDigit; 
+          // if (target > (LLONG_MAX - thisDigit));
+          if (target > tempMax)
+            { // adding this digit causes an overflow
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, REC_BYTE_F_ASCII,
+                                    SQLCHARSETCODE_ISO88591,
+                                    REC_BIN64_SIGNED, flags);
+              return ex_expr::EXPR_ERROR;
+            }
+          target = target + (Int64)thisDigit;
+          }   // if digitCnt > 18, check overflow or underflow
+        else
+          {
+          // at this point we never consider overflow
+          // and target is alway potitive or absolute value
+          target = target * 10 + thisDigit;
+          }
+        }   // fi ( sourceScale < targetScale )
+      }
+    else if (source[currPos] == ' ')
+      { // process blanks
+      if (digitCnt || pointFound)	
+	// we found already some digits or a decimal point. A blank now 
+        // means, that from now on we should not see any digits anymore.
+	DigitsAllowed = FALSE;
+      }
+    else if ((source[currPos] == '+') || (source[currPos] == '-'))
+      { // process sign
+	// we found already a sign or we found already digits
+        // or we found a point already.
+        // A sign is an error now!
+	ExRaiseSqlError(heap, diagsArea, EXE_CONVERT_STRING_ERROR);
+	return ex_expr::EXPR_ERROR;
+      }
+    else if (source[currPos] == '.')
+      { // process decimal point
+      if (pointFound || !DigitsAllowed)    
+        {
+	// we found a second decimal point. This is an error
+        // we are already not allowing anymore digits because of illegal
+        // blank space(s)
+	ExRaiseSqlError(heap, diagsArea, EXE_CONVERT_STRING_ERROR);
+	return ex_expr::EXPR_ERROR;
+        }
+      pointFound = TRUE;
+      }
+    else
+      { // process illegal characters
+      // if the illegal character is a 'E' or 'e', the input
+      // might be a float value. Try to convert the input
+      // to double and then to Int64
+      if ((source[currPos] == 'E') || (source[currPos] == 'e'))
+        {
+	  if (currPos == 0)
+	    {
+	      // 'E' alone is not a valid numeric.
+	      ExRaiseSqlError(heap, diagsArea, EXE_CONVERT_STRING_ERROR);
+	      return ex_expr::EXPR_ERROR;
+	    }
+
+	  double intermediate;
+	  if (convAsciiToFloat64((char*)&intermediate,
+				 source,
+				 sourceLen,
+				 heap,
+				 diagsArea,
+                                 flags | CONV_INTERMEDIATE_CONVERSION) != ex_expr::EXPR_OK)
+	    return ex_expr::EXPR_ERROR;
+
+	  // scale the intermediate
+	  for (Lng32 i = 0; i < targetScale; i++)
+	    intermediate *= 10.0;
+
+	  target = (UInt64) intermediate;
+
+	  return ex_expr::EXPR_OK;
+	}
+      else
+        {
+	  // illegal character in this input string
+	  ExRaiseSqlError(heap, diagsArea, EXE_CONVERT_STRING_ERROR);
+	  return ex_expr::EXPR_ERROR;
+        }
+      }
+    currPos++;
+    }
+
+  // if we didn't find any digits, it is an error
+  if (!digitCnt)
+    {
+      if ((flags & CONV_TREAT_ALL_SPACES_AS_ZERO) &&
+	  (NOT (pointFound || SignFound)))
+	{
+	  target = 0;
+	  return ex_expr::EXPR_OK;
+	}
+      
+      ExRaiseSqlError(heap, diagsArea, EXE_CONVERT_STRING_ERROR);
+      return ex_expr::EXPR_ERROR;
+    }
+
+  // up- or downscale
+  if (sourceScale < targetScale)
+    {
+    for (Int32 i = 0; i < (targetScale - sourceScale); i++)
+      {
+        if (target > (ULLONG_MAX / 10))
+          { // next power of 10 causes an overflow
+            ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW, source,
+                                  sourceLen, REC_BYTE_F_ASCII,
+                                  SQLCHARSETCODE_ISO88591,REC_BIN64_SIGNED,
+                                  flags);
+            return ex_expr::EXPR_ERROR;
+          }
+        target *= 10;
+      }
+    }
+  else
+    {
+    for (Int32 i = 0; i < sourceScale - targetScale; i++)
+      target /= 10;
+    }
+  
+  return ex_expr::EXPR_OK;
+  }
+
+///////////////////////////////////////////////////////////////////
+// function to convert an ASCII string to Int64
+// The function assumes that source is at least
+// sourceLen long. Trailing '\0' is not recongnized
+///////////////////////////////////////////////////////////////////
+ex_expr::exp_return_type convAsciiToUInt64(UInt64 &target,
+                                           Lng32 targetScale,
+                                           char *source,
+                                           Lng32 sourceLen,
+                                           CollHeap *heap,
+                                           ComDiagsArea** diagsArea,
+                                           ULng32 flags)
+{
+  NABoolean negative = FALSE;    // default is a positive value
+  Lng32 currPos = 0;              // current position in the string
+
+  negative = isNegative(source, sourceLen, currPos);
+  if (negative)
+    {
+      ExRaiseSqlError(heap, diagsArea, EXE_UNSIGNED_OVERFLOW);
+      return ex_expr::EXPR_ERROR;
+    }
+
+  ex_expr::exp_return_type ert = 
+    convAsciiToUInt64base(target, targetScale, &source[currPos], 
+                          sourceLen - currPos,
+                          heap, diagsArea, flags);
+  if (ert == ex_expr::EXPR_ERROR)
+    return ert;
+
+  return ex_expr::EXPR_OK;
+}
+
+ex_expr::exp_return_type convAsciiToInt64(Int64 &target,
+					  Lng32 targetScale,
+					  char *source,
+					  Lng32 sourceLen,
+					  CollHeap *heap,
+					  ComDiagsArea** diagsArea,
+                                          ULng32 flags)
+{
+  Lng32 currPos = 0;              // current position in the string
+
+  NABoolean negative = FALSE;    // default is a positive value
+  negative = isNegative(source, sourceLen, currPos);
+
+  UInt64 tempTgt = 0;
+  ex_expr::exp_return_type ert = 
+    convAsciiToUInt64base(tempTgt, targetScale, &source[currPos], 
+                          sourceLen - currPos,
+                          heap, diagsArea, flags);
+  if (ert == ex_expr::EXPR_ERROR)
+    return ert;
+
+  if (tempTgt > LLONG_MAX)
+    {
+      ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                            source, sourceLen, REC_BYTE_F_ASCII,
+                            SQLCHARSETCODE_ISO88591,
+                            REC_BIN64_SIGNED, flags);
+      return ex_expr::EXPR_ERROR;
+    }
+
+  if (NOT negative)
+    {
+      target = (Int64)tempTgt;
+      return ex_expr::EXPR_OK;
+    }
+  
+  if (-(Int64)tempTgt < LLONG_MIN)
+    {
+      ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                            source, sourceLen, REC_BYTE_F_ASCII,
+                            SQLCHARSETCODE_ISO88591,
+                            REC_BIN64_SIGNED, flags);
+      return ex_expr::EXPR_ERROR;
+    }
+
+  target = - (Int64)tempTgt;
+
+  return ex_expr::EXPR_OK;
+}
+
+#ifdef __ignore
 ///////////////////////////////////////////////////////////////////
 // function to convert an ASCII string to Int64
 // The function assumes that source is at least
@@ -1805,7 +2092,6 @@ ex_expr::exp_return_type convAsciiToInt64(Int64 &target,
           // check overflow/underflow
           if (negative)
             {
-        	  // LCOV_EXCL_START
             if (digitCnt == 19)
               target = -target; // target is alway positive before
 
@@ -2006,7 +2292,7 @@ ex_expr::exp_return_type convAsciiToInt64(Int64 &target,
   
   return ex_expr::EXPR_OK;
   }
-
+#endif
 
 //////////////////////////////////////////////////////////////////
 // function to convert an Int64  to Decimal
@@ -2878,6 +3164,7 @@ ex_expr::exp_return_type convIntervalToAscii(char *source,
                          '0', // filler character
 			 FALSE,
                          TRUE, // leftPad
+                         FALSE,
 			 heap,
                          diagsArea) != ex_expr::EXPR_OK)
 	return ex_expr::EXPR_ERROR;
@@ -2908,6 +3195,7 @@ ex_expr::exp_return_type convIntervalToAscii(char *source,
                          '0', // filler character
 			 FALSE,
                          TRUE, // leftPad
+                         FALSE,
 			 heap,
                          diagsArea) != ex_expr::EXPR_OK)
       return ex_expr::EXPR_ERROR;
@@ -2928,6 +3216,7 @@ ex_expr::exp_return_type convIntervalToAscii(char *source,
                        ' ', // filler character
 		       FALSE,
                        TRUE, // leftPad
+                       FALSE,
 		       heap,
                        diagsArea) != ex_expr::EXPR_OK)
     return ex_expr::EXPR_ERROR;
@@ -3692,9 +3981,9 @@ Int64 getMinIntervalValue(Lng32 targetPrecision,
 ///////////////////////////////////////////////////////////////////
 
 NA_EIDPROC
-Lng32 getDigitCount(Int64 value)
+Lng32 getDigitCount(UInt64 value)
   {
-    static const Int64 decValue[] = {0,
+    static const UInt64 decValue[] = {0,
                                9,
                                99,
                                999,
@@ -3704,16 +3993,16 @@ Lng32 getDigitCount(Int64 value)
                                9999999,
                                99999999,
                                999999999,
-//SQ_LINUX #ifndef NA_HSC
-                               9999999999LL,
-                               99999999999LL,
-                               999999999999LL,
-                               9999999999999LL,
-                               99999999999999LL,
-                               999999999999999LL,
-                               9999999999999999LL,
-                               99999999999999999LL,
-                               999999999999999999LL};
+                               9999999999ULL,
+                               99999999999ULL,
+                               999999999999ULL,
+                               9999999999999ULL,
+                               99999999999999ULL,
+                               999999999999999ULL,
+                               9999999999999999ULL,
+                               99999999999999999ULL,
+                               999999999999999999ULL,
+                               9999999999999999999ULL};
 
     for (Int32 i = 4; i <= 16; i += 4)
       if (value <= decValue[i]) {
@@ -3729,7 +4018,9 @@ Lng32 getDigitCount(Int64 value)
       return 17;
     if (value <= decValue[18])
       return 18;
-    return 19;
+    if (value <= decValue[19])
+      return 19;
+    return 20;
   }
 
 //////////////////////////////////////////////////////////////////
@@ -5174,6 +5465,7 @@ convDoIt(char * source,
 			 ' ', // filler character
 			 FALSE,
 			 leftPad,
+                         FALSE,
 			 heap,
 			 diagsArea) != ex_expr::EXPR_OK)
       return ex_expr::EXPR_ERROR;
@@ -5192,6 +5484,7 @@ convDoIt(char * source,
 			 ' ', // filler character
 			 FALSE,
 			 leftPad,
+                         FALSE,
 			 heap,
 			 diagsArea) != ex_expr::EXPR_OK)
       return ex_expr::EXPR_ERROR;
@@ -5308,6 +5601,12 @@ convDoIt(char * source,
     }
   break;
  
+  case CONV_BIN16S_BIN64U: 
+    {
+      *(UInt64 *)target = *(short *)source;
+    }
+  break;
+ 
   case CONV_BIN16S_DECU:
   case CONV_BIN16S_DECS:
     {
@@ -5370,6 +5669,7 @@ convDoIt(char * source,
 			 ' ', // filler character
 			 FALSE,
 			 leftPad,
+                         FALSE,
 			 heap,
 			 diagsArea) != ex_expr::EXPR_OK)
       return ex_expr::EXPR_ERROR;
@@ -5503,6 +5803,11 @@ convDoIt(char * source,
   };
   break;
 
+  case CONV_BIN16U_BIN64U: {
+    *(UInt64 *)target = *(unsigned short *)source;
+  };
+  break;
+
   case CONV_BIN16U_DECS:
     // covers conversion to DECS and DECU (see exp_fixup.cpp)
     {
@@ -5554,6 +5859,7 @@ convDoIt(char * source,
 			 ' ', // filler character
 			 FALSE,
 			 leftPad,
+                         FALSE,
 			 heap,
 			 diagsArea) != ex_expr::EXPR_OK)
       return ex_expr::EXPR_ERROR;
@@ -5807,6 +6113,12 @@ convDoIt(char * source,
     }
   break;
 
+  case CONV_BIN32S_BIN64U: 
+    {
+      *(UInt64 *)target = *(Lng32 *)source;
+    }
+  break;
+
   case CONV_BIN32S_DECU:
   case CONV_BIN32S_DECS:
     {
@@ -5865,6 +6177,7 @@ convDoIt(char * source,
 			 ' ', // filler character
 			 FALSE,
 			 leftPad,
+                         FALSE,
 			 heap,
 		         diagsArea) != ex_expr::EXPR_OK)
       return ex_expr::EXPR_ERROR;
@@ -6080,6 +6393,12 @@ convDoIt(char * source,
     }
   break;
 
+  case CONV_BIN32U_BIN64U: 
+    {
+      *(UInt64 *)target = (UInt64)(*(ULng32 *)source);
+    }
+  break;
+
   case CONV_BIN32U_DECS:
   // covers conversion to DECS and DECU (see exp_fixup.cpp)
      {
@@ -6132,6 +6451,7 @@ convDoIt(char * source,
 			 ' ', // filler character
 			 FALSE,
 			 leftPad,
+                         FALSE,
 			 heap,
 			 diagsArea) != ex_expr::EXPR_OK)
       return ex_expr::EXPR_ERROR;
@@ -6451,14 +6771,360 @@ convDoIt(char * source,
     }
   break;
 
-  case CONV_BIN64S_DECU:
-  case CONV_BIN64S_DECS:
+  case CONV_BIN64S_BIN64U:
     {
-      if (convExactToDec(target,
-                         targetLen,
-                         targetType,
-		         *(Int64 *)source,
-		         heap,
+      if (*(Int64 *)source < 0) 
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(UInt64 *)target = 0;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_UP_TO_MIN;
+            }
+          else
+            {
+              ExRaiseSqlError(heap, diagsArea, EXE_UNSIGNED_OVERFLOW);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else
+        {
+          if (dataConversionErrorFlag != 0)
+            {
+              *(UInt64 *)target = *(Int64 *)source;
+            }
+          else
+            {
+              if (checkPrecision(*(Int64 *)source,
+				 sourceLen,
+		                 sourceType,
+		                 sourcePrecision,
+                                 sourceScale,
+		                 targetType,
+		                 targetPrecision,
+                                 targetScale,
+		                 heap,
+		                 diagsArea,
+                                 tempFlags) == ex_expr::EXPR_OK)
+                {
+                  *(UInt64 *)target = *(Int64 *)source;
+                }
+              else
+                {
+                  return ex_expr::EXPR_ERROR;
+                }
+            }
+        }
+    }
+  break;
+
+  case CONV_BIN64U_BIN16S:
+    {
+      if (*(UInt64 *)source < SHRT_MIN)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(short *)target = SHRT_MIN;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_UP_TO_MIN;
+            }
+          else
+            {
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, sourceType, sourceScale,
+                                    targetType, tempFlags);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else if (*(UInt64 *)source > SHRT_MAX)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(short *)target = SHRT_MAX;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_DOWN_TO_MAX;
+            }
+          else
+            {
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, sourceType, sourceScale,
+                                    targetType, tempFlags);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else
+        {
+          if (dataConversionErrorFlag != 0)
+            { // Set the target value.
+              *(short *)target = (short) *(UInt64 *)source;
+            }
+          else
+            { // Check target precision. Then set target value.
+              if (checkPrecision(*(Int64 *)source,                 
+				 sourceLen,
+                                 sourceType,
+		                 sourcePrecision,
+                                 sourceScale,
+		                 targetType,
+		                 targetPrecision,
+                                 targetScale,
+		                 heap,
+                                 diagsArea,
+                                 tempFlags) == ex_expr::EXPR_OK)
+                {
+                  *(short *)target = (short) *(UInt64 *)source;
+                }
+              else
+                {
+                  return ex_expr::EXPR_ERROR;
+                }
+            }
+        }
+    }
+  break;
+
+  case CONV_BIN64U_BIN16U:
+    {
+      if (*(UInt64 *)source > USHRT_MAX)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(unsigned short *)target = USHRT_MAX;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_DOWN_TO_MAX;
+            }
+          else
+            {
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, sourceType, sourceScale,
+                                    targetType, tempFlags);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else
+        {
+          if (dataConversionErrorFlag != 0)
+            { // Set the target value.
+              *(unsigned short *)target = (unsigned short) *(UInt64 *)source;
+            }
+          else
+            { // Check target precision. Then set target value.
+              if (checkPrecision(*(Int64 *)source,
+				 sourceLen,
+                                 sourceType,
+                                 sourcePrecision,
+                                 sourceScale,
+                                 targetType,
+                                 targetPrecision,
+                                 targetScale,
+                                 heap,
+                                 diagsArea,
+                                 tempFlags) == ex_expr::EXPR_OK)
+                {
+                  *(unsigned short *)target = (unsigned short) *(UInt64 *)source;
+                }
+              else
+                {
+                  return ex_expr::EXPR_ERROR;
+                }
+            }
+        }
+    }
+  break;
+
+  case CONV_BIN64U_BIN32S:
+    {
+      if (*(UInt64 *)source < INT_MIN)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(Lng32 *)target = INT_MIN;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_UP_TO_MIN;
+            }
+          else
+            {
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, sourceType, sourceScale,
+                                    targetType, tempFlags);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else if (*(UInt64 *)source > INT_MAX)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(Lng32 *)target = INT_MAX;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_DOWN_TO_MAX;
+            }
+          else
+            {
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, sourceType, sourceScale,
+                                    targetType, tempFlags);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else
+        {
+          if (dataConversionErrorFlag != 0)
+            { // Set the target value.
+              *(Lng32 *)target = (Lng32) *(UInt64 *)source;
+            }
+          else
+            { // Check target precision. Then set target value.
+              if (checkPrecision(*(Int64 *)source,
+				 sourceLen,
+		                 sourceType,
+		                 sourcePrecision,
+                                 sourceScale,
+		                 targetType,
+		                 targetPrecision,
+                                 targetScale,
+		                 heap,
+		                 diagsArea,
+                                 tempFlags) == ex_expr::EXPR_OK)
+                {
+                  *(Lng32 *)target = (Lng32) *(UInt64 *)source;
+                }
+              else
+                {
+                  return ex_expr::EXPR_ERROR;
+                }
+            }
+        }
+    }
+  break;
+
+  case CONV_BIN64U_BIN32U:
+    {
+      if (*(UInt64 *)source > UINT_MAX)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(ULng32 *)target = UINT_MAX;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_DOWN_TO_MAX;
+            }
+          else
+            {
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, sourceType, sourceScale,
+                                    targetType, tempFlags);
+              return ex_expr::EXPR_ERROR; 
+            }
+        }
+      else
+        {
+          if (dataConversionErrorFlag != 0)
+            { // Set the target value.
+              *(ULng32 *)target = (ULng32) *(UInt64 *)source;
+            }
+          else
+            { // Check target precision. Then set target value.
+              if (checkPrecision(*(Int64 *)source,
+				 sourceLen,
+		                 sourceType,
+		                 sourcePrecision,
+                                 sourceScale,
+		                 targetType,
+		                 targetPrecision,
+                                 targetScale,
+		                 heap,
+		                 diagsArea,
+                                 tempFlags) == ex_expr::EXPR_OK)
+                {
+                  *(ULng32 *)target = (ULng32) *(UInt64 *)source;
+                }
+              else
+                {
+                  return ex_expr::EXPR_ERROR;
+                }
+            }
+        }
+    }
+  break;
+
+  case CONV_BIN64U_BIN64U:
+    {
+      if (dataConversionErrorFlag != 0)
+        {
+          *(UInt64 *)target = *(UInt64 *)source;
+        }
+      else
+        {
+          if (checkPrecision((Int64)*(UInt64 *)source,
+			     sourceLen,
+                             sourceType,
+                             sourcePrecision,
+                             sourceScale,
+                             targetType,
+                             targetPrecision,
+                             targetScale,
+                             heap,
+                             diagsArea,
+                             tempFlags) == ex_expr::EXPR_OK)
+            {
+              *(UInt64 *)target = *(UInt64 *)source;
+            }
+          else
+            {
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+    }
+  break;
+
+  case CONV_BIN64U_BIN64S:
+    {
+      if (*(UInt64 *)source > LLONG_MAX)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(Int64 *)target = LLONG_MAX;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_DOWN_TO_MAX;
+            }
+          else
+            {
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, sourceType, sourceScale,
+                                    targetType, tempFlags);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else
+        {
+          if (dataConversionErrorFlag != 0)
+            { // Set the target value.
+              *(Int64 *)target = *(UInt64 *)source;
+            }
+          else
+            { // Check target precision. Then set target value.
+              if (checkPrecision((Int64)*(UInt64 *)source,
+				 sourceLen,
+		                 sourceType,
+		                 sourcePrecision,
+                                 sourceScale,
+		                 targetType,
+		                 targetPrecision,
+                                 targetScale,
+		                 heap,
+		                 diagsArea,
+                                 tempFlags) == ex_expr::EXPR_OK)
+                {
+                  *(Int64 *)target = *(UInt64 *)source;
+                }
+              else
+                {
+                  return ex_expr::EXPR_ERROR;
+                }
+            }
+        }
+    }
+  break;
+
+  case CONV_BIN64S_DECU:
+  case CONV_BIN64S_DECS:
+    {
+      if (convExactToDec(target,
+                         targetLen,
+                         targetType,
+		         *(Int64 *)source,
+		         heap,
 		         diagsArea,
                          dataConversionErrorFlag,
                          tempFlags) != ex_expr::EXPR_OK)
@@ -6478,6 +7144,16 @@ convDoIt(char * source,
   };
   break;
 
+  case CONV_BIN64U_FLOAT32: {
+    *floatTgtPtr = (float) *(UInt64 *)source;
+  };
+  break;
+
+  case CONV_BIN64U_FLOAT64: {
+    *doubleTgtPtr = (double) *(UInt64 *)source;
+  };
+  break;
+
   case CONV_BIN64S_BIGNUMU: {
     if (*(Int64 *)source < 0) {
       ExRaiseSqlError(heap, diagsArea, EXE_UNSIGNED_OVERFLOW);
@@ -6509,6 +7185,26 @@ convDoIt(char * source,
 			 ' ', // filler character
 			 FALSE,
 			 leftPad,
+                         FALSE,
+			 heap,
+			 diagsArea) != ex_expr::EXPR_OK)
+      return ex_expr::EXPR_ERROR;
+  };
+  break;
+
+  case CONV_BIN64U_ASCII: {
+    if (convInt64ToAscii(target,
+			 targetLen,
+                         targetPrecision,
+                         targetScale,
+			 *(Int64 *)source,
+			 sourceScale,
+			 varCharLen,
+			 varCharLenSize,
+			 ' ', // filler character
+			 FALSE,
+			 leftPad,
+                         TRUE,
 			 heap,
 			 diagsArea) != ex_expr::EXPR_OK)
       return ex_expr::EXPR_ERROR;
@@ -6693,6 +7389,7 @@ convDoIt(char * source,
 			 ((targetType == REC_DECIMAL_LS) ? '0' : ' '),
 			 (targetType == REC_DECIMAL_LS),
 			 ((targetType == REC_DECIMAL_LS) ? TRUE : leftPad),
+                         FALSE,
 			 heap,
 			 diagsArea) != ex_expr::EXPR_OK)
       return ex_expr::EXPR_ERROR;
@@ -7170,6 +7867,79 @@ convDoIt(char * source,
     }
   break;
 
+  case CONV_FLOAT32_BIN64U:
+    {
+      float floatsource = *floatSrcPtr;
+      if (floatsource < 0)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(UInt64 *)target = 0;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_UP_TO_MIN;
+            }
+          else
+            {
+              ExRaiseSqlError(heap, diagsArea, EXE_UNSIGNED_OVERFLOW);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else if (floatsource > ULLONG_MAX)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(UInt64 *)target = ULLONG_MAX;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_DOWN_TO_MAX;
+            }
+          else
+            {
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, sourceType, sourceScale,
+                                    targetType, tempFlags);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else
+        {
+          UInt64 int64source = (UInt64) floatsource;
+          if (dataConversionErrorFlag != 0)
+            {
+              // Convert back and check for a value change.
+              float floatsource2 = int64source;
+              if (floatsource2 > floatsource)
+                {
+                  *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_UP;
+                }
+              else
+                {
+                  if (floatsource2 < floatsource)
+                    {
+                      *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_DOWN;
+                    }
+                }
+            }
+          if ((dataConversionErrorFlag != 0) ||
+                checkPrecision(int64source,
+			       sourceLen,
+                               sourceType,
+                               sourcePrecision,
+                               sourceScale,
+                               targetType,
+                               targetPrecision,
+                               targetScale,
+                               heap,
+                               diagsArea,
+                               tempFlags) == ex_expr::EXPR_OK)
+            { // Set the target value.
+              *(UInt64 *)target = (UInt64) int64source;
+            }
+          else
+            {
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+    }
+  break;
+
   case CONV_FLOAT32_DECU:
   case CONV_FLOAT32_DECS:
     {
@@ -7755,6 +8525,79 @@ convDoIt(char * source,
     }
   break;
 
+  case CONV_FLOAT64_BIN64U:
+    {
+      double doublesource = *doubleSrcPtr;
+      if (doublesource < 0)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(UInt64 *)target = 0;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_UP_TO_MIN;
+            }
+          else
+            {
+              ExRaiseSqlError(heap, diagsArea, EXE_UNSIGNED_OVERFLOW);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else if (doublesource > ULLONG_MAX)
+        {
+          if (dataConversionErrorFlag != 0)  // Capture error in variable?
+            {
+              *(UInt64 *)target = ULLONG_MAX;
+              *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_DOWN_TO_MAX;
+            }
+          else
+            {
+              ExRaiseDetailSqlError(heap, diagsArea, EXE_NUMERIC_OVERFLOW,
+                                    source, sourceLen, sourceType, sourceScale,
+                                    targetType, tempFlags);
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+      else
+        {
+          UInt64 int64source = (UInt64) doublesource;
+          if (dataConversionErrorFlag != 0)
+            {
+              // Convert back and check for a value change.
+              double doublesource2 = int64source;
+              if (doublesource2 > doublesource)
+                {
+                  *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_UP;
+                }
+              else
+                {
+                  if (doublesource2 < doublesource)
+                    {
+                      *dataConversionErrorFlag = ex_conv_clause::CONV_RESULT_ROUNDED_DOWN;
+                    }
+                }
+            }
+          if ((dataConversionErrorFlag != 0) ||
+                checkPrecision(int64source,
+			       sourceLen,
+                               sourceType,
+                               sourcePrecision,
+                               sourceScale,
+                               targetType,
+                               targetPrecision,
+                               targetScale,
+                               heap,
+                               diagsArea,
+                               tempFlags) == ex_expr::EXPR_OK)
+            { // Set the target value.
+              *(UInt64 *)target = (UInt64) int64source;
+            }
+          else
+            {
+              return ex_expr::EXPR_ERROR;
+            }
+        }
+    }
+  break;
+
   case CONV_FLOAT64_DECS:
   case CONV_FLOAT64_DECU:
     {
@@ -9454,6 +10297,34 @@ convDoIt(char * source,
     };
     break;
 
+  case CONV_ASCII_BIN64U: {
+    UInt64 intermediate;
+    if (convAsciiToUInt64(intermediate,
+			 targetScale,
+			 source,
+			 sourceLen,
+			 heap,
+			 diagsArea,
+                         tempFlags) != ex_expr::EXPR_OK)
+      return ex_expr::EXPR_ERROR;
+
+    if (checkPrecision(intermediate,
+		       8,
+                       REC_BIN64_SIGNED,
+                       sourcePrecision,
+                       sourceScale,
+                       targetType,
+	               targetPrecision,
+                       targetScale,
+		       heap,
+		       diagsArea,
+                       tempFlags) != ex_expr::EXPR_OK)
+      return ex_expr::EXPR_ERROR;
+
+    *(UInt64 *)target = intermediate;
+    };
+    break;
+
   case CONV_ASCII_DEC: {
     // if the source is REC_DECIMAL_LS, we use the same conversion as for ASCII,
     // but we ignore the targetScale

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/exp/exp_fixup.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_fixup.cpp b/core/sql/exp/exp_fixup.cpp
index c58f04e..b90c7d8 100644
--- a/core/sql/exp/exp_fixup.cpp
+++ b/core/sql/exp/exp_fixup.cpp
@@ -1148,6 +1148,7 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_BIN16_SIGNED,  REC_BIN32_SIGNED,           CONV_BIN16S_BIN32S},
     {REC_BIN16_SIGNED,  REC_BIN32_UNSIGNED,         CONV_BIN16S_BIN32U},
     {REC_BIN16_SIGNED,  REC_BIN64_SIGNED,           CONV_BIN16S_BIN64S},
+    {REC_BIN16_SIGNED,  REC_BIN64_UNSIGNED,         CONV_BIN16S_BIN64U},
     {REC_BIN16_SIGNED,  REC_DECIMAL_LSE,            CONV_BIN16S_DECS},
     {REC_BIN16_SIGNED,  REC_DECIMAL_UNSIGNED,       CONV_BIN16S_DECU},
     {REC_BIN16_SIGNED,  REC_FLOAT32,                CONV_BIN16S_FLOAT32},
@@ -1169,6 +1170,7 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_BIN16_UNSIGNED,  REC_BIN32_SIGNED,           CONV_BIN16U_BIN32S},
     {REC_BIN16_UNSIGNED,  REC_BIN32_UNSIGNED,         CONV_BIN16U_BIN32U},
     {REC_BIN16_UNSIGNED,  REC_BIN64_SIGNED,           CONV_BIN16U_BIN64S},
+    {REC_BIN16_UNSIGNED,  REC_BIN64_UNSIGNED,         CONV_BIN16U_BIN64U},
     {REC_BIN16_UNSIGNED,  REC_DECIMAL_LSE,            CONV_BIN16U_DECS},
     {REC_BIN16_UNSIGNED,  REC_DECIMAL_UNSIGNED,       CONV_BIN16U_DECS},
     {REC_BIN16_UNSIGNED,  REC_FLOAT32,                CONV_BIN16U_FLOAT32},
@@ -1190,6 +1192,7 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_BIN32_SIGNED,   REC_BIN32_SIGNED,           CONV_BIN32S_BIN32S},
     {REC_BIN32_SIGNED,   REC_BIN32_UNSIGNED,         CONV_BIN32S_BIN32U},
     {REC_BIN32_SIGNED,   REC_BIN64_SIGNED,           CONV_BIN32S_BIN64S},
+    {REC_BIN32_SIGNED,   REC_BIN64_UNSIGNED,         CONV_BIN32S_BIN64U},
     {REC_BIN32_SIGNED,   REC_DECIMAL_LSE,            CONV_BIN32S_DECS},
     {REC_BIN32_SIGNED,   REC_DECIMAL_UNSIGNED,       CONV_BIN32S_DECU},
     {REC_BIN32_SIGNED,   REC_FLOAT32,                CONV_BIN32S_FLOAT32},
@@ -1208,6 +1211,7 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_BIN32_UNSIGNED,  REC_BIN32_SIGNED,           CONV_BIN32U_BIN32S},
     {REC_BIN32_UNSIGNED,  REC_BIN32_UNSIGNED,         CONV_BIN32U_BIN32U},
     {REC_BIN32_UNSIGNED,  REC_BIN64_SIGNED,           CONV_BIN32U_BIN64S},
+    {REC_BIN32_UNSIGNED,  REC_BIN64_UNSIGNED,         CONV_BIN32U_BIN64U},
     {REC_BIN32_UNSIGNED,  REC_DECIMAL_LSE,            CONV_BIN32U_DECS},
     {REC_BIN32_UNSIGNED,  REC_DECIMAL_UNSIGNED,       CONV_BIN32U_DECS},
     {REC_BIN32_UNSIGNED,  REC_FLOAT32,                CONV_BIN32U_FLOAT32},
@@ -1226,6 +1230,7 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_BIN64_SIGNED,   REC_BIN32_SIGNED,           CONV_BIN64S_BIN32S},
     {REC_BIN64_SIGNED,   REC_BIN32_UNSIGNED,         CONV_BIN64S_BIN32U},
     {REC_BIN64_SIGNED,   REC_BIN64_SIGNED,           CONV_BIN64S_BIN64S},
+    {REC_BIN64_SIGNED,   REC_BIN64_UNSIGNED,         CONV_BIN64S_BIN64U},
     {REC_BIN64_SIGNED,   REC_DECIMAL_LSE,            CONV_BIN64S_DECS},
     {REC_BIN64_SIGNED,   REC_DECIMAL_UNSIGNED,       CONV_BIN64S_DECU},
     {REC_BIN64_SIGNED,   REC_FLOAT32,                CONV_BIN64S_FLOAT32},
@@ -1238,7 +1243,18 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_BIN64_SIGNED,   REC_NCHAR_F_UNICODE,        CONV_BIN64S_UNICODE},
     {REC_BIN64_SIGNED,   REC_NCHAR_V_UNICODE,        CONV_BIN64S_UNICODE},
     {REC_BIN64_SIGNED,   REC_DATETIME,               CONV_BIN64S_DATETIME},
-    
+
+    {REC_BIN64_UNSIGNED,   REC_BIN16_SIGNED,           CONV_BIN64U_BIN16S},
+    {REC_BIN64_UNSIGNED,   REC_BIN16_UNSIGNED,         CONV_BIN64U_BIN16U},
+    {REC_BIN64_UNSIGNED,   REC_BIN32_SIGNED,           CONV_BIN64U_BIN32S},
+    {REC_BIN64_UNSIGNED,   REC_BIN32_UNSIGNED,         CONV_BIN64U_BIN32U},
+    {REC_BIN64_UNSIGNED,   REC_BIN64_SIGNED,           CONV_BIN64U_BIN64S},
+    {REC_BIN64_UNSIGNED,   REC_BIN64_UNSIGNED,         CONV_BIN64U_BIN64U},
+    {REC_BIN64_UNSIGNED,   REC_FLOAT32,                CONV_BIN64U_FLOAT32},
+    {REC_BIN64_UNSIGNED,   REC_FLOAT64,                CONV_BIN64U_FLOAT64},
+    {REC_BIN64_UNSIGNED,   REC_BYTE_F_ASCII,           CONV_BIN64U_ASCII},
+    {REC_BIN64_UNSIGNED,   REC_BYTE_V_ASCII,           CONV_BIN64U_ASCII},
+      
     {REC_DECIMAL_UNSIGNED,   REC_BPINT_UNSIGNED,         CONV_DECS_BIN32U},
     {REC_DECIMAL_UNSIGNED,   REC_BIN16_UNSIGNED,         CONV_DECS_BIN32U},
     {REC_DECIMAL_UNSIGNED,   REC_BIN16_SIGNED,           CONV_DECS_BIN32S},
@@ -1282,6 +1298,7 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_FLOAT32,            REC_BIN32_SIGNED,       CONV_FLOAT32_BIN32S},
     {REC_FLOAT32,            REC_BIN32_UNSIGNED,     CONV_FLOAT32_BIN32U},
     {REC_FLOAT32,            REC_BIN64_SIGNED,       CONV_FLOAT32_BIN64S},
+    {REC_FLOAT32,            REC_BIN64_UNSIGNED,     CONV_FLOAT32_BIN64U},
     {REC_FLOAT32,            REC_DECIMAL_LSE,        CONV_FLOAT32_DECS},
     {REC_FLOAT32,            REC_DECIMAL_UNSIGNED,   CONV_FLOAT32_DECU},
     {REC_FLOAT32,            REC_FLOAT32,            CONV_FLOAT32_FLOAT32},
@@ -1298,6 +1315,7 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_FLOAT64,            REC_BIN32_SIGNED,       CONV_FLOAT64_BIN32S},
     {REC_FLOAT64,            REC_BIN32_UNSIGNED,     CONV_FLOAT64_BIN32U},
     {REC_FLOAT64,            REC_BIN64_SIGNED,       CONV_FLOAT64_BIN64S},
+    {REC_FLOAT64,            REC_BIN64_UNSIGNED,     CONV_FLOAT64_BIN64U},
     {REC_FLOAT64,            REC_DECIMAL_LSE,        CONV_FLOAT64_DECS},
     {REC_FLOAT64,            REC_DECIMAL_UNSIGNED,   CONV_FLOAT64_DECU},
     {REC_FLOAT64,            REC_FLOAT32,            CONV_FLOAT64_FLOAT32},
@@ -1399,6 +1417,7 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_BYTE_F_ASCII,       REC_BIN32_SIGNED,           CONV_ASCII_BIN32S},
     {REC_BYTE_F_ASCII,       REC_BIN32_UNSIGNED,         CONV_ASCII_BIN32U},
     {REC_BYTE_F_ASCII,       REC_BIN64_SIGNED,           CONV_ASCII_BIN64S},
+    {REC_BYTE_F_ASCII,       REC_BIN64_UNSIGNED,         CONV_ASCII_BIN64U},
     {REC_BYTE_F_ASCII,       REC_DECIMAL_LSE,            CONV_ASCII_DEC},
     {REC_BYTE_F_ASCII,       REC_DECIMAL_UNSIGNED,       CONV_ASCII_DEC},
 
@@ -1479,6 +1498,7 @@ conv_case_index ex_conv_clause::find_case_index(short sourceType, Lng32 sourceLe
     {REC_BYTE_V_ASCII,       REC_BIN32_SIGNED,           CONV_ASCII_BIN32S},
     {REC_BYTE_V_ASCII,       REC_BIN32_UNSIGNED,         CONV_ASCII_BIN32U},
     {REC_BYTE_V_ASCII,       REC_BIN64_SIGNED,           CONV_ASCII_BIN64S},
+    {REC_BYTE_V_ASCII,       REC_BIN64_UNSIGNED,         CONV_ASCII_BIN64U},
     {REC_BYTE_V_ASCII,       REC_DECIMAL_LSE,            CONV_ASCII_DEC},
     {REC_BYTE_V_ASCII,       REC_DECIMAL_UNSIGNED,       CONV_ASCII_DEC},
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/exp/exp_function.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_function.cpp b/core/sql/exp/exp_function.cpp
index fd5a74b..883046d 100644
--- a/core/sql/exp/exp_function.cpp
+++ b/core/sql/exp/exp_function.cpp
@@ -3223,6 +3223,10 @@ void ex_function_encode::encodeKeyValue(Attributes * attr,
     target[0] ^= 0200;
     break;
 
+  case REC_BIN64_UNSIGNED:
+    *((UInt64 *) target) = reversebytes( *((UInt64 *) source) );
+    break;
+
   case REC_INT_YEAR:
   case REC_INT_MONTH:
   case REC_INT_YEAR_MONTH:
@@ -4685,6 +4689,7 @@ ex_expr::exp_return_type ExHDPHash::eval(char *op_data[],
       flags = SWAP_FOUR;
       break;
     case REC_BIN64_SIGNED:
+    case REC_BIN64_UNSIGNED:
     case REC_IEEE_FLOAT64:
       flags = SWAP_EIGHT;
       break;
@@ -7162,6 +7167,10 @@ short ex_function_encode::decodeKeyValue(Attributes * attr,
     target[sizeof(_int64)-1] ^= 0200;
     break;
 
+  case REC_BIN64_UNSIGNED:
+    *((UInt64 *) target) = reversebytes( *((UInt64 *) source) );
+    break;
+
   case REC_INT_YEAR:
   case REC_INT_MONTH:
   case REC_INT_YEAR_MONTH:
@@ -7526,6 +7535,10 @@ static Lng32 convAsciiLength(Attributes * attr)
       d_len = SQL_LARGE_DISPLAY_SIZE + scale_len;
       break;
 
+    case REC_BIN64_UNSIGNED:
+      d_len = SQL_ULARGE_DISPLAY_SIZE + scale_len;
+      break;
+
    case REC_NUM_BIG_UNSIGNED:
    case REC_NUM_BIG_SIGNED:
       d_len = precision + 1 + scale_len; // Precision + sign + decimal point

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/generator/GenPreCode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/generator/GenPreCode.cpp b/core/sql/generator/GenPreCode.cpp
index 723be31..37ab353 100644
--- a/core/sql/generator/GenPreCode.cpp
+++ b/core/sql/generator/GenPreCode.cpp
@@ -8635,7 +8635,35 @@ ItemExpr * Cast::preCodeGen(Generator * generator)
              SQLSmall(TRUE,
                       srcNAType.supportsSQLnull()));
       ((Cast*)newChild)->setFlags(getFlags());
-      //      ((Cast*)newChild)->setSrcIsVarcharPtr(srcIsVarcharPtr());
+      setSrcIsVarcharPtr(FALSE);
+      newChild = newChild->bindNode(generator->getBindWA());
+      newChild = newChild->preCodeGen(generator);
+      if (! newChild)
+        return NULL;
+      
+      setChild(0, newChild);
+      srcFsType = child(0)->getValueId().getType().getFSDatatype();
+    }
+
+  if ((srcNAType.getTypeName() == LiteralLargeInt) ||
+      (tgtNAType.getTypeName() == LiteralLargeInt))
+    {
+      Lng32 ij = 1;
+    }
+ 
+  if (((srcNAType.getTypeName() == LiteralLargeInt) &&
+       (NOT srcNAType.expConvSupported(tgtNAType))) ||
+      ((tgtNAType.getTypeName() == LiteralLargeInt) &&
+       (NOT tgtNAType.expConvSupported(srcNAType))))
+    {
+      // add a Cast node to convert to sqllargeint signed.
+      ItemExpr * newChild =
+        new (generator->wHeap())
+        Cast(child(0),
+             new (generator->wHeap())
+             SQLLargeInt(TRUE,
+                         srcNAType.supportsSQLnull()));
+      ((Cast*)newChild)->setFlags(getFlags());
       setSrcIsVarcharPtr(FALSE);
       newChild = newChild->bindNode(generator->getBindWA());
       newChild = newChild->preCodeGen(generator);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/optimizer/EncodedValue.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/EncodedValue.cpp b/core/sql/optimizer/EncodedValue.cpp
index 829105b..d05e061 100644
--- a/core/sql/optimizer/EncodedValue.cpp
+++ b/core/sql/optimizer/EncodedValue.cpp
@@ -529,9 +529,15 @@ EncodedValue::outputToBufferToComputeRTHash(
            { Int32 y = (Int32)x; memcpy(data, &y, len); }
            break;
         case REC_BIN64_SIGNED:
+           len = 8;
            flags =ExHDPHash::SWAP_EIGHT;
            { Int64 y = (Int64)x; len = 8; memcpy(data, &y, len); }
            break;
+        case REC_BIN64_UNSIGNED:
+           len = 8;
+           flags =ExHDPHash::SWAP_EIGHT;
+           { UInt64 y = (UInt64)x; len = 8; memcpy(data, &y, len); }
+           break;
         default:
           len = 0; // For column types not supported by SB, we just
                    // skip the column value here.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index bdc9ea1..2574b61 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -11153,6 +11153,7 @@ UInt32 ConstValue::computeHashValue(const NAType& columnType)
            flags = ExHDPHash::SWAP_FOUR;
            break;
          case REC_BIN64_SIGNED:
+         case REC_BIN64_UNSIGNED:
          case REC_IEEE_FLOAT64:
            flags = ExHDPHash::SWAP_EIGHT;
            break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/optimizer/NAColumn.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAColumn.cpp b/core/sql/optimizer/NAColumn.cpp
index 54c53fd..b0b68a6 100644
--- a/core/sql/optimizer/NAColumn.cpp
+++ b/core/sql/optimizer/NAColumn.cpp
@@ -335,6 +335,23 @@ NABoolean NAColumn::createNAType(columns_desc_struct *column_desc	/*IN*/,
                     heap
 		    );
       break;
+    case REC_BIN64_UNSIGNED:
+      if (column_desc->precision > 0)
+	type = new (heap)
+	SQLNumeric(column_desc->length,
+		   column_desc->precision,
+		   column_desc->scale,
+		   FALSE,
+		   column_desc->null_flag,
+                   heap
+		   );
+      else
+	type = new (heap)
+        SQLLargeInt(FALSE,
+		    column_desc->null_flag,
+                    heap
+		    );
+      break;
     case REC_DECIMAL_UNSIGNED:
       type = new (heap)
 	SQLDecimal(column_desc->length,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index 0d45133..50c9a5f 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -3082,6 +3082,23 @@ NABoolean createNAType(columns_desc_struct *column_desc	/*IN*/,
                     heap
 		    );
       break;
+    case REC_BIN64_UNSIGNED:
+      if (column_desc->precision > 0)
+	type = new (heap)
+	SQLNumeric(column_desc->length,
+		   column_desc->precision,
+		   column_desc->scale,
+		   FALSE,
+		   column_desc->null_flag,
+                   heap
+		   );
+      else
+	type = new (heap)
+          SQLLargeInt(FALSE,
+		    column_desc->null_flag,
+                    heap
+		    );
+      break;
     case REC_DECIMAL_UNSIGNED:
       type = new (heap)
 	SQLDecimal(column_desc->length,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/parser/StmtDDLCreate.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCreate.cpp b/core/sql/parser/StmtDDLCreate.cpp
index 1ff6542..86813e8 100644
--- a/core/sql/parser/StmtDDLCreate.cpp
+++ b/core/sql/parser/StmtDDLCreate.cpp
@@ -4320,6 +4320,7 @@ StmtDDLCreateTable::synthesize()
 		REC_BIN16_UNSIGNED,
 		REC_BIN32_SIGNED,
 		REC_BIN32_UNSIGNED,
+		REC_BIN64_UNSIGNED,
 		REC_BIN64_SIGNED
 	      };
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index 2b9d145..eba5c94 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -10567,14 +10567,7 @@ int_type : TOK_INTEGER signed_option
              }
 	 | TOK_LARGEINT signed_option
              {
-                if (!$2) {
-                  // UNSIGNED specified. Error. Largeint must be signed. 
-                  *SqlParser_Diags << DgSqlCode(-3130);
-                  // YYABORT;
-                  yyerror(""); 
-                  YYERROR;
-                }
-		$$ = new (PARSERHEAP()) SQLLargeInt( $2, TRUE);
+               $$ = new (PARSERHEAP()) SQLLargeInt( $2, TRUE);
              }
          | TOK_BIGINT signed_option
              {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/sqlci/Formatter.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlci/Formatter.cpp b/core/sql/sqlci/Formatter.cpp
index 216e9eb..7ffbee8 100644
--- a/core/sql/sqlci/Formatter.cpp
+++ b/core/sql/sqlci/Formatter.cpp
@@ -145,6 +145,10 @@ Lng32 Formatter::display_length(Lng32 datatype,
       d_len = d_buflen = SQL_LARGE_DISPLAY_SIZE + scale_len;
       break;
        
+    case REC_BIN64_UNSIGNED:
+      d_len = d_buflen = SQL_ULARGE_DISPLAY_SIZE + scale_len;
+      break;
+       
     case REC_BYTE_F_ASCII:
 // 12/9/97: added for Unicode case
     case REC_NCHAR_F_UNICODE:
@@ -324,6 +328,7 @@ Int32 Formatter::buffer_it(SqlciEnv * sqlci_env, char *data,
 
   case REC_BPINT_UNSIGNED:
   case REC_BIN64_SIGNED:
+  case REC_BIN64_UNSIGNED:
   case REC_BIN32_SIGNED:
   case REC_BIN32_UNSIGNED:
   case REC_BIN16_SIGNED:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ef98b7d8/core/sql/sqlci/Param.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlci/Param.cpp b/core/sql/sqlci/Param.cpp
index 512d577..869d6fa 100644
--- a/core/sql/sqlci/Param.cpp
+++ b/core/sql/sqlci/Param.cpp
@@ -335,6 +335,7 @@ short Param::convertValue(SqlciEnv * sqlci_env, short targetType,
   case REC_BIN32_SIGNED:
   case REC_BIN32_UNSIGNED:
   case REC_BIN64_SIGNED:
+  case REC_BIN64_UNSIGNED:
   case REC_DECIMAL_UNSIGNED:
   case REC_DECIMAL_LSE:
   case REC_FLOAT32:


Mime
View raw message