trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ansha...@apache.org
Subject [4/6] incubator-trafodion git commit: JIRA TRAFODION-2099 Add support for boolean datatype
Date Tue, 12 Jul 2016 22:55:44 GMT
JIRA TRAFODION-2099 Add support for boolean datatype

-- boolean datatype support in create, cast and params
  Ex:
   create table t (a boolean);
   insert into t values (true), (false);
   select * from t where a = true;

-- boolean datatype support for hive columns

-- unarith op support. Currently used for '!' operator that
   negates a boolean value.
   Ex: select * from t where !a = false;

-- support for more tinyint and largeint unsigned conversion/comparison
   operations in expressions and pcode

-- some code cleanup: removed reference to downrev compiler code genration

-- create table if not exists as select...   syntax support

-- regress/seabase/TEST003 updated with additional tests


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

Branch: refs/heads/master
Commit: d48a0c94353caf83a2036fd7c2727152814255e9
Parents: 8b1df54
Author: Anoop Sharma <anoop.sharma@esgyn.com>
Authored: Sun Jul 10 23:02:05 2016 +0000
Committer: Anoop Sharma <anoop.sharma@esgyn.com>
Committed: Sun Jul 10 23:02:05 2016 +0000

----------------------------------------------------------------------
 .../trafodion/jdbc/t4/InterfaceResultSet.java   |   9 +
 .../odbc/src/odbc/nsksrvrcore/sqlinterface.cpp  |  10 +
 core/sql/bin/SqlciErrors.txt                    |   2 +-
 core/sql/cli/sqlcli.h                           |   4 +
 core/sql/common/BaseTypes.cpp                   |  12 +
 core/sql/common/ComSmallDefs.h                  |   6 +
 core/sql/common/MiscType.cpp                    | 154 ++++-
 core/sql/common/MiscType.h                      | 112 +++-
 core/sql/common/NAType.cpp                      |   8 +
 core/sql/common/NumericType.cpp                 |  18 -
 core/sql/common/NumericType.h                   |  33 +-
 core/sql/common/SQLTypeDefs.h                   |   2 +
 core/sql/common/dfs2rec.h                       |  13 +-
 core/sql/common/str.cpp                         |  37 +-
 core/sql/common/str.h                           |  12 +-
 core/sql/exp/ExpErrorEnums.h                    |   1 +
 core/sql/exp/ExpPCode.cpp                       |  68 ++-
 core/sql/exp/ExpPCodeClauseGen.cpp              | 398 +++++++-----
 core/sql/exp/ExpPCodeExpGen.cpp                 |   5 +-
 core/sql/exp/ExpPCodeInstruction.h              |  41 +-
 core/sql/exp/ExpPCodeOptimizations.cpp          | 103 +++-
 core/sql/exp/ExpPCodeOptsConstProp.cpp          |   6 +
 core/sql/exp/exp_arith.cpp                      |   6 +-
 core/sql/exp/exp_attrs.cpp                      |   2 +
 core/sql/exp/exp_clause.cpp                     |   3 +-
 core/sql/exp/exp_clause_derived.h               |  77 ++-
 core/sql/exp/exp_comp.cpp                       |  61 ++
 core/sql/exp/exp_conv.cpp                       | 109 +++-
 core/sql/exp/exp_eval.cpp                       | 222 ++++++-
 core/sql/exp/exp_expr.cpp                       |   2 -
 core/sql/exp/exp_expr.h                         |  23 +-
 core/sql/exp/exp_fixup.cpp                      |  93 ++-
 core/sql/exp/exp_function.cpp                   |  30 +
 core/sql/exp/exp_math_func.cpp                  |  18 +-
 core/sql/generator/GenExpGenerator.cpp          |  97 ++-
 core/sql/generator/GenExpGenerator.h            |   3 +
 core/sql/generator/GenItemExpr.cpp              |  19 +
 core/sql/generator/GenPreCode.cpp               |  85 +--
 core/sql/generator/GenRelJoin.cpp               |   7 +-
 core/sql/generator/GenRelMisc.cpp               |   3 -
 core/sql/generator/Generator.cpp                |  17 +-
 core/sql/generator/Generator.h                  |  21 -
 core/sql/optimizer/BindItemExpr.cpp             |  25 +
 core/sql/optimizer/BindRelExpr.cpp              |  20 +
 core/sql/optimizer/ControlDB.cpp                |  10 +-
 core/sql/optimizer/EncodedValue.cpp             |   1 +
 core/sql/optimizer/ItemArith.h                  |  32 +
 core/sql/optimizer/ItemExpr.cpp                 |  27 +
 core/sql/optimizer/NAColumn.cpp                 |   4 +
 core/sql/optimizer/NATable.cpp                  |   9 +
 core/sql/optimizer/NormItemExpr.cpp             |   2 +-
 core/sql/optimizer/OptRange.cpp                 |  24 +-
 core/sql/optimizer/RelExeUtil.cpp               |   6 +
 core/sql/optimizer/SynthType.cpp                |  70 ++-
 core/sql/optimizer/UdfDllInteraction.cpp        |  23 +
 core/sql/optimizer/ValueDesc.cpp                |   9 +-
 core/sql/parser/ParKeyWords.cpp                 |   2 +-
 core/sql/parser/SqlParserAux.cpp                |   8 +-
 core/sql/parser/sqlparser.y                     |  41 +-
 core/sql/parser/ulexer.cpp                      |   3 +-
 core/sql/regress/compGeneral/EXPECTED071        |   4 +-
 core/sql/regress/core/EXPECTED037.SB            |   4 +-
 core/sql/regress/core/EXPECTED038.LINUX         |  22 +-
 core/sql/regress/core/TEST037                   |   2 +-
 core/sql/regress/executor/EXPECTED002.SB        |  68 +--
 core/sql/regress/executor/EXPECTED012           |  36 +-
 core/sql/regress/executor/EXPECTED022.SB        |  18 +-
 core/sql/regress/executor/TEST012               |  15 +-
 core/sql/regress/hive/EXPECTED005               |   4 +-
 core/sql/regress/hive/EXPECTED015               |  60 +-
 core/sql/regress/seabase/EXPECTED003            | 608 ++++++++++++++++++-
 core/sql/regress/seabase/EXPECTED010            | 378 ++++++------
 core/sql/regress/seabase/TEST003                | 134 +++-
 core/sql/regress/udr/EXPECTED001                |  30 +-
 core/sql/regress/udr/TEST001                    |   7 +
 core/sql/sqlci/Formatter.cpp                    |   5 +
 core/sql/sqlci/Param.cpp                        |   1 +
 core/sql/sqlci/SqlciEnv.cpp                     |   4 +
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp        |   9 +-
 core/sql/sqlcomp/CmpSeabaseDDLutil.cpp          |   2 +
 core/sql/sqlcomp/DefaultConstants.h             |   8 +
 core/sql/sqlcomp/nadefaults.cpp                 |   4 +
 82 files changed, 2853 insertions(+), 838 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
index c5c5814..7273338 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceResultSet.java
@@ -115,6 +115,9 @@ class InterfaceResultSet {
 	/* NCHAR VARYING -- VARCHAR(n) CHARACTER SET s -- s uses 2 bytes per char */
 	static final int SQLTYPECODE_VARCHAR_DBLBYTE = 17;
 
+        /* BOOLEAN TYPE */
+        static final int SQLTYPECODE_BOOLEAN = -701;
+
 	/* Date/Time/TimeStamp related constants */
 	static final int SQLDTCODE_DATE = 1;
 	static final int SQLDTCODE_TIME = 2;
@@ -271,6 +274,9 @@ class InterfaceResultSet {
 		case SQLTYPECODE_TINYINT:
 			retObj = new Byte(ibuffer[byteIndex]);
 			break;
+		case SQLTYPECODE_BOOLEAN:
+			retObj = new Byte(ibuffer[byteIndex]);
+			break;
 		case SQLTYPECODE_TINYINT_UNSIGNED:
                         short sValue1 = Bytes.extractUTiny(ibuffer, byteIndex, this.ic_.getByteSwap());
 			retObj = new Short(sValue1);
@@ -517,6 +523,9 @@ class InterfaceResultSet {
 				break;
 			}
 			break;
+		case SQLTYPECODE_BOOLEAN:
+			retObj = new Byte(values[noNullValue]);
+			break;
 		case SQLTYPECODE_TINYINT_UNSIGNED:
                         short sValue1 = Bytes.extractUTiny(values, noNullValue, swap);
                         retObj = new Short(sValue1);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/conn/odbc/src/odbc/nsksrvrcore/sqlinterface.cpp
----------------------------------------------------------------------
diff --git a/core/conn/odbc/src/odbc/nsksrvrcore/sqlinterface.cpp b/core/conn/odbc/src/odbc/nsksrvrcore/sqlinterface.cpp
index 0629e7a..783c953 100644
--- a/core/conn/odbc/src/odbc/nsksrvrcore/sqlinterface.cpp
+++ b/core/conn/odbc/src/odbc/nsksrvrcore/sqlinterface.cpp
@@ -90,6 +90,12 @@ SQLRETURN SRVR::GetODBCValues(Int32 DataType, Int32 DateTimeCode, Int32 &Length,
 
 	switch (DataType)
 	{
+                case SQLTYPECODE_BOOLEAN:
+			ODBCPrecision = 1;
+			ODBCDataType = SQL_CHAR;
+			SignType = FALSE;
+			totalMemLen += Length;
+			break;
 		case SQLTYPECODE_CHAR:
 			ODBCPrecision = Length;
 			ODBCDataType = SQL_CHAR;
@@ -708,6 +714,7 @@ SQLRETURN SRVR::SetDataPtr(SQLDESC_ID *pDesc, SQLItemDescList_def *SQLDesc, Int3
 			VarPtr = memPtr + memOffSet;
 			memOffSet += SQLItemDesc->maxLen + 3;
 			break;
+                case SQLTYPECODE_BOOLEAN:
                 case SQLTYPECODE_TINYINT:
                 case SQLTYPECODE_TINYINT_UNSIGNED:
 			VarPtr = memPtr + memOffSet;
@@ -1042,6 +1049,7 @@ SQLRETURN SRVR::AllocAssignValueBuffer(
 				memOffSet += SQLItemDesc->maxLen + 3;
 				AllocLength = SQLItemDesc->maxLen + 3;
 				break;
+                        case SQLTYPECODE_BOOLEAN:
                         case SQLTYPECODE_TINYINT:
                         case SQLTYPECODE_TINYINT_UNSIGNED:
 				VarPtr = memPtr + memOffSet; 
@@ -2519,6 +2527,7 @@ SQLRETURN SRVR::BuildSQLDesc2withRowsets( SQLDESC_ID          *pDesc
 			else
 				inputQuadList[i+1].var_layout = SqlDescInfo[i].Length + 1;
 			break;
+                case SQLTYPECODE_BOOLEAN:
                 case SQLTYPECODE_TINYINT:
                 case SQLTYPECODE_TINYINT_UNSIGNED:
 			VarPtr = memPtr + memOffSet;
@@ -7078,6 +7087,7 @@ SQLRETURN SRVR::SetIndandVarPtr(SQLDESC_ID *pDesc,
 			if (!bRWRS)
 				memOffSet += 1;
 			break;
+                case SQLTYPECODE_BOOLEAN:
                 case SQLTYPECODE_TINYINT:
                 case SQLTYPECODE_TINYINT_UNSIGNED:
 			VarPtr = memPtr + memOffSet;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index 6635d00..c32b394 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -1544,7 +1544,7 @@ $1~String1 --------------------------------
 8423 ZZZZZ 99999 BEGINNER MINOR LOGONLY The provided field number is not valid.
 8424 0A000 99999 BEGINNER MINOR LOGONLY Function $0~string0 is not yet supported.
 8425 ZZZZZ 99999 BEGINNER MINOR LOGONLY NULL cannot be assigned to a DEFAULT NULL NOT NULL column.
-8426 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU --- unused as of 03/30/04 ---
+8426 22007 99999 BEGINNER MINOR LOGONLY The provided value, $0~string0, is an invalid BOOLEAN value.
 8427 ZZZZZ 99999 BEGINNER INFRM LOGONLY $0~string0
 8428 ZZZZZ 99999 BEGINNER MINOR LOGONLY The argument to function $0~string0 is not valid.
 8429 ZZZZZ 99999 BEGINNER INFRM LOGONLY The preceding error actually occurred in function $0~string0.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/cli/sqlcli.h
----------------------------------------------------------------------
diff --git a/core/sql/cli/sqlcli.h b/core/sql/cli/sqlcli.h
index 04ec0e8..5ab95d9 100644
--- a/core/sql/cli/sqlcli.h
+++ b/core/sql/cli/sqlcli.h
@@ -417,6 +417,10 @@ enum SQLTYPE_CODE {
     /* BLOB TYPE */
     SQLTYPECODE_BLOB  = -602,
     SQLTYPECODE_CLOB  = -603,
+
+    /* BOOLEAN TYPE */
+    SQLTYPECODE_BOOLEAN = -701,
+
     /* no ANSI value 13 */
 
     /* BIT */

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/BaseTypes.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/BaseTypes.cpp b/core/sql/common/BaseTypes.cpp
index fa154d9..ae03ca8 100644
--- a/core/sql/common/BaseTypes.cpp
+++ b/core/sql/common/BaseTypes.cpp
@@ -640,6 +640,10 @@ short convertTypeToText_basic(char * text,	   // OUTPUT
        str_sprintf(text, "CLOB");
      break;
 
+   case REC_BOOLEAN:
+     str_sprintf(text, "BOOLEAN");
+     break;
+
     default:
       str_sprintf(text, "**ERROR (unknown type %d)", fs_datatype);
       return -1; // error case
@@ -769,6 +773,10 @@ Lng32 getAnsiTypeFromFSType(Lng32 datatype)
      numeric_value = SQLTYPECODE_CLOB;
      break;
 
+   case REC_BOOLEAN:
+     numeric_value = SQLTYPECODE_BOOLEAN;
+     break;
+
    case REC_INT_YEAR:
    case REC_INT_MONTH:
    case REC_INT_YEAR_MONTH:
@@ -886,6 +894,10 @@ const char * getAnsiTypeStrFromFSType(Lng32 datatype)
      return COM_CLOB_SDT_LIT;
      break;
 
+   case REC_BOOLEAN:
+     return COM_BOOLEAN_SDT_LIT;
+     break;
+
    case REC_INT_YEAR:
    case REC_INT_MONTH:
    case REC_INT_YEAR_MONTH:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 5b0442e..4b4e96d 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -812,6 +812,8 @@ enum ComFSDataType { COM_UNKNOWN_FSDT              = -1
 		   , COM_BLOB                      = REC_BLOB
 		   , COM_CLOB                      = REC_CLOB
 
+                   , COM_BOOLEAN                   = REC_BOOLEAN
+
                    , COM_DATETIME_FSDT             = REC_DATETIME
                    , COM_INTERVAL_MIN_FSDT         = REC_MIN_INTERVAL
                    , COM_INTERVAL_YEAR_YEAR_FSDT   = REC_INT_YEAR
@@ -1011,6 +1013,7 @@ enum ComODBCDataType { COM_UNKNOWN_ODT
                      , COM_LARGE_DECIMAL_UNSIGNED_ODT
 		     , COM_BLOB_ODT
 		     , COM_CLOB_ODT
+		     , COM_BOOLEAN_ODT
                      , COM_DATETIME_ODT
                      , COM_TIMESTAMP_ODT
                      , COM_DATE_ODT
@@ -1045,6 +1048,7 @@ enum ComODBCDataType { COM_UNKNOWN_ODT
 #define COM_INTERVAL_ODT_LIT                   "INTERVAL          "
 #define COM_BLOB_ODT_LIT                       "BLOB              "
 #define COM_CLOB_ODT_LIT                       "CLOB              "
+#define COM_BOOLEAN_ODT_LIT                    "BOOLEAN           "
 
 enum ComAccessPathType  { COM_UNKNOWN_ACCESS_PATH_TYPE
                         , COM_BASE_TABLE_TYPE
@@ -1571,6 +1575,7 @@ enum ComSQLDataType { COM_UNKNOWN_SDT
                     , COM_LARGE_DECIMAL_UNSIGNED_SDT
 		    , COM_BLOB_SDT
 		    , COM_CLOB_SDT
+		    , COM_BOOLEAN_SDT
                     , COM_DATETIME_SDT
                     , COM_TIMESTAMP_SDT
                     , COM_DATE_SDT
@@ -1605,6 +1610,7 @@ enum ComSQLDataType { COM_UNKNOWN_SDT
 #define COM_INTERVAL_SDT_LIT                   "INTERVAL          "
 #define COM_BLOB_SDT_LIT                       "BLOB              "
 #define COM_CLOB_SDT_LIT                       "CLOB              "
+#define COM_BOOLEAN_SDT_LIT                    "BOOLEAN           "
 
 enum ComViewCheckOption { COM_UNKNOWN_CHECK_OPTION
                         , COM_CASCADE_CHECK_OPTION

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/MiscType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/MiscType.cpp b/core/sql/common/MiscType.cpp
index 3941429..77b780d 100644
--- a/core/sql/common/MiscType.cpp
+++ b/core/sql/common/MiscType.cpp
@@ -40,41 +40,107 @@
 
 // ***********************************************************************
 //
-//  SQLBoolean : The boolean data type
+//  SQLBooleanBase : The boolean data type
 //
 // ***********************************************************************
-NAType * SQLBoolean::newCopy(CollHeap* h) const
-{
-  return new(h) SQLBoolean(unknownFlag_,h);
+SQLBooleanBase::SQLBooleanBase(NABoolean allowSQLnull,
+                       NABoolean isRelat,
+                       NAMemory * heap) :
+     NAType(LiteralBoolean,
+            NA_BOOLEAN_TYPE,
+            (isRelat ? 4 : 1),  // dataStorageSize
+            allowSQLnull,
+            (allowSQLnull ? SQL_NULL_HDR_SIZE : 0),
+            FALSE,              // variableLength
+            0,                  // lengthHeaderSize
+            (isRelat ? 4 : 1),  // dataAlignment
+            heap                
+            )
+{ 
 }
 
-short SQLBoolean::getFSDatatype() const 
+// ---------------------------------------------------------------------
+// A method which tells if a conversion error can occur when converting
+// a value of this type to the target type.
+// This method is a stub and so just returns true for now.
+// ---------------------------------------------------------------------
+NABoolean SQLBooleanBase::errorsCanOccur(const NAType& target, NABoolean lax) const
 {
-  return REC_BIN32_SIGNED;
+  return NAType::errorsCanOccur(target);
 }
 
-NABoolean SQLBoolean::canBeSQLUnknown() const
-{
-  return unknownFlag_;
+// ***********************************************************************
+//
+// Type synthesis for binary operators
+//
+// ***********************************************************************
+
+// ***********************************************************************
+//
+//  SQLBooleanRelat : The boolean data type
+//
+// ***********************************************************************
+SQLBooleanRelat::SQLBooleanRelat(NABoolean sqlUnknownFlag,
+                                 NAMemory * heap) :
+     SQLBooleanBase(FALSE, TRUE, heap),
+     sqlUnknownFlag_(sqlUnknownFlag)
+{ 
 }
 
-void SQLBoolean::setSQLUnknownFlag(NABoolean flag)
+NAType * SQLBooleanRelat::newCopy(CollHeap* h) const
 {
-  unknownFlag_ = flag;
+  return new(h) SQLBooleanRelat(sqlUnknownFlag_, h);
 }
 
-NAString SQLBoolean::getSimpleTypeName() const
+// ***********************************************************************
+//
+// Type synthesis for binary operators
+//
+// ***********************************************************************
+
+const NAType* SQLBooleanRelat::synthesizeType(enum NATypeSynthRuleEnum synthRule,
+                                         const NAType& operand1,
+					 const NAType& operand2,
+					 CollHeap* h,
+					 UInt32 *flags) const
 {
-  return "SQLBoolean";
-}
+  //
+  // If the second operand's type synthesis rules have higher precedence than
+  // this operand's rules, use the second operand's rules.
+  //
+  if (operand2.getSynthesisPrecedence() > getSynthesisPrecedence())
+    return operand2.synthesizeType(synthRule, operand1, operand2, h, flags);
+  //
+  // If either operand is not boolean, the expression is invalid.
+  //
+  if ((operand1.getTypeQualifier() != NA_BOOLEAN_TYPE) ||
+      (operand2.getTypeQualifier() != NA_BOOLEAN_TYPE))
+    return NULL;
+  //
+  // The generator can create CASE expressions that have boolean result
+  // expressions.
+  //
+  if (synthRule == SYNTH_RULE_UNION)
+    return new(h) SQLBooleanRelat();
 
-// -- The external name for the type (text representation)
+  return NULL;
+} // synthesizeType()
 
-NAString SQLBoolean::getTypeSQLname(NABoolean) const
+
+// ***********************************************************************
+//
+//  SQLBooleanNative : The boolean data type
+//
+// ***********************************************************************
+SQLBooleanNative::SQLBooleanNative(NABoolean allowSQLnull,
+                                 NAMemory * heap) :
+     SQLBooleanBase(allowSQLnull, FALSE, heap)
+{ 
+}
+
+NAType * SQLBooleanNative::newCopy(CollHeap* h) const
 {
-  if (unknownFlag_)
-    return "BOOLEAN ALLOWS UNKNOWN";
-  return "BOOLEAN NO UNKNOWNS";
+  return new(h) SQLBooleanNative(supportsSQLnull(), h);
 }
 
 // ***********************************************************************
@@ -83,7 +149,7 @@ NAString SQLBoolean::getTypeSQLname(NABoolean) const
 //
 // ***********************************************************************
 
-const NAType* SQLBoolean::synthesizeType(enum NATypeSynthRuleEnum synthRule,
+const NAType* SQLBooleanNative::synthesizeType(enum NATypeSynthRuleEnum synthRule,
                                          const NAType& operand1,
 					 const NAType& operand2,
 					 CollHeap* h,
@@ -106,21 +172,51 @@ const NAType* SQLBoolean::synthesizeType(enum NATypeSynthRuleEnum synthRule,
   // expressions.
   //
   if (synthRule == SYNTH_RULE_UNION)
-    return new(h) SQLBoolean();
+    return new(h) SQLBooleanNative
+      (operand1.supportsSQLnull() || operand2.supportsSQLnull());
+
   return NULL;
 } // synthesizeType()
 
+void SQLBooleanNative::minRepresentableValue(void* bufPtr, Lng32* bufLen,
+                                     NAString ** stringLiteral,
+				     CollHeap* h) const
+{
+  assert(*bufLen >= sizeof(Int8));
+  Lng32 valueBuf;
+  *bufLen = sizeof(Int8);
+  *((Int8*)bufPtr) = 0;
+  valueBuf = 0;
 
-// ---------------------------------------------------------------------
-// A method which tells if a conversion error can occur when converting
-// a value of this type to the target type.
-// This method is a stub and so just returns true for now.
-// ---------------------------------------------------------------------
-NABoolean SQLBoolean::errorsCanOccur(const NAType& target, NABoolean lax) const
+  if (stringLiteral != NULL)
+    {
+      // Generate a printable string for the minimum value
+      char nameBuf[10];
+      strcpy(nameBuf, "false");
+      *stringLiteral = new (h) NAString(nameBuf, h);
+    }
+
+} // SQLBooleanNative::minRepresentableValue()
+
+void SQLBooleanNative::maxRepresentableValue(void* bufPtr, Lng32* bufLen,
+                                     NAString ** stringLiteral,
+				     CollHeap* h) const
 {
-  return TRUE;
-}
+  assert(*bufLen >= sizeof(Int8));
+  Lng32 valueBuf;
+  *bufLen = sizeof(Int8);
+  *((Int8*)bufPtr) = 1;
+  valueBuf = 0;
+  
+  if (stringLiteral != NULL)
+    {
+      // Generate a printable string for the minimum value
+      char nameBuf[10];
+      strcpy(nameBuf, "true");
+      *stringLiteral = new (h) NAString(nameBuf, h);
+    }
 
+} // SQLBooleanNative::maxRepresentableValue()
 
 // ***********************************************************************
 //

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/MiscType.h
----------------------------------------------------------------------
diff --git a/core/sql/common/MiscType.h b/core/sql/common/MiscType.h
index 84aa904..e06d8f8 100644
--- a/core/sql/common/MiscType.h
+++ b/core/sql/common/MiscType.h
@@ -58,44 +58,56 @@ static NAString LiteralRowset("ROWSET");
 
 // ***********************************************************************
 //
-//  SQLBoolean : The boolean data type
+//  SQLBooleanBase : The boolean data type
 //
 // ***********************************************************************
-class SQLBoolean : public NAType
+class SQLBooleanBase : public NAType
 {
 public:
 
   // ---------------------------------------------------------------------
   // Constructor functions
   // ---------------------------------------------------------------------
-  SQLBoolean(NABoolean SQLUnknownFlag = TRUE,NAMemory * heap=0) :
-                 NAType(LiteralBoolean,
-                        NA_BOOLEAN_TYPE,
-                        4,                  // dataStorageSize
-                        FALSE,              // supportsSQLnull
-                        0,                  // SQLnullHdrSize
-                        FALSE,              // variableLength
-                        0,                  // lengthHeaderSize
-                        4,                  // dataAlignment
-						heap                
-                        ) { unknownFlag_ = SQLUnknownFlag; }
-  
+  SQLBooleanBase(NABoolean allowSQLnull,
+             NABoolean isRelat,
+             NAMemory * heap=0);
+
   // ---------------------------------------------------------------------
-  // A virtual function to return a copy of the type.
+  // A method which tells if a conversion error can occur when converting
+  // a value of this type to the target type.
   // ---------------------------------------------------------------------
-  virtual NAType *newCopy(NAMemory* h=0) const;
+  NABoolean errorsCanOccur (const NAType& target, NABoolean lax=TRUE) const;
+ 
+private:
+}; // class SQLBooleanBase
 
-  short getFSDatatype() const;
+// ***********************************************************************
+//
+//  SQLBooleanRelat : The boolean data type used in relational operators
+//
+// ***********************************************************************
+class SQLBooleanRelat : public SQLBooleanBase
+{
+public:
 
   // ---------------------------------------------------------------------
-  // Get a simpler textual description of the type.  
+  // Constructor functions
   // ---------------------------------------------------------------------
-  virtual NAString getSimpleTypeName() const;
+  SQLBooleanRelat(NABoolean sqlUnknownFlag = TRUE,
+                  NAMemory * heap=0);
+  
+  // ---------------------------------------------------------------------
+  // A virtual function to return a copy of the type.
+  // ---------------------------------------------------------------------
+  virtual NAType *newCopy(NAMemory* h=0) const;
+
+  virtual short getFSDatatype() const { return REC_BIN32_SIGNED; }
 
   // ---------------------------------------------------------------------
   // Get the external/SQL name of the Type.
   // ---------------------------------------------------------------------
-  virtual NAString getTypeSQLname(NABoolean terse = FALSE) const;
+  virtual NAString getTypeSQLname(NABoolean terse = FALSE) const
+  {return "BOOLEAN_RELAT";}
 
   // ---------------------------------------------------------------------
   // A virtual function for synthesizing the type of a binary operator.
@@ -106,25 +118,63 @@ public:
 				       CollHeap* h,
 				       UInt32 *flags = NULL) const;
   
+  // ---------------- Methods not inherited from NAType ----------------
+
+  NABoolean canBeSQLUnknown() const { return sqlUnknownFlag_;}
+
+  private:
+  NABoolean sqlUnknownFlag_;
+}; // class SQLBooleanRelat
+
+// ***********************************************************************
+//
+//  SQLBooleanNative : The boolean data type used as a column datatype
+//
+// ***********************************************************************
+class SQLBooleanNative : public SQLBooleanBase
+{
+public:
+
   // ---------------------------------------------------------------------
-  // A method which tells if a conversion error can occur when converting
-  // a value of this type to the target type.
+  // Constructor functions
   // ---------------------------------------------------------------------
-  NABoolean errorsCanOccur (const NAType& target, NABoolean lax=TRUE) const;
+  SQLBooleanNative(NABoolean allowSQLnull,
+                  NAMemory * heap=0);
+  
+  // ---------------------------------------------------------------------
+  // A virtual function to return a copy of the type.
+  // ---------------------------------------------------------------------
+  virtual NAType *newCopy(NAMemory* h=0) const;
 
-  // ---------------- Methods not inherited from NAType ----------------
+  virtual short getFSDatatype() const { return REC_BOOLEAN; }
 
   // ---------------------------------------------------------------------
-  // A method which tells if this SQLBoolean can evualuate to
-  // unknown or only to (true,flase)
+  // Get the external/SQL name of the Type.
   // ---------------------------------------------------------------------
-  NABoolean canBeSQLUnknown() const;
-  void setSQLUnknownFlag(NABoolean flag);
+  virtual NAString getTypeSQLname(NABoolean terse = FALSE) const
+  {return "BOOLEAN";}
 
-  private:
-  NABoolean unknownFlag_;
+  // ---------------------------------------------------------------------
+  // A virtual function for synthesizing the type of a binary operator.
+  // ---------------------------------------------------------------------
+  virtual const NAType* synthesizeType(enum NATypeSynthRuleEnum synthRule,
+                                       const NAType& operand1,
+                                       const NAType& operand2,
+				       CollHeap* h,
+				       UInt32 *flags = NULL) const;
+  
+  virtual void minRepresentableValue(void* bufPtr, Lng32* bufLen,
+                                     NAString ** stringLiteral,
+				     CollHeap* h) const;
+
+  virtual void maxRepresentableValue(void* bufPtr, Lng32* bufLen,
+                                     NAString ** stringLiteral,
+				     CollHeap* h) const;
 
-}; // class SQLBoolean
+  // ---------------- Methods not inherited from NAType ----------------
+
+  private:
+}; // class SQLBooleanNative
 
 // ***********************************************************************
 //

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/NAType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/NAType.cpp b/core/sql/common/NAType.cpp
index 78b00bd..1bbe1b5 100644
--- a/core/sql/common/NAType.cpp
+++ b/core/sql/common/NAType.cpp
@@ -626,6 +626,10 @@ Lng32 NAType::getDisplayLength(Lng32 datatype,
       d_len = length;
       break;
 
+    case REC_BOOLEAN:
+      d_len = SQL_BOOLEAN_DISPLAY_SIZE;
+      break;
+
     default:
       d_len = length;
       break;
@@ -729,6 +733,10 @@ short NAType::getMyTypeAsHiveText(NAString * outputStr)  // output
       *outputStr = "double";
       break;
 
+    case REC_BOOLEAN:
+      *outputStr = "boolean";
+      break;
+
     case REC_DATETIME:
       {
         DatetimeIntervalCommonType & dtiCommonType =

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/NumericType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/NumericType.cpp b/core/sql/common/NumericType.cpp
index b401522..1a3b445 100644
--- a/core/sql/common/NumericType.cpp
+++ b/core/sql/common/NumericType.cpp
@@ -834,24 +834,6 @@ NABoolean NumericType::isEncodingNeeded() const
 #endif
 }
 
-NABoolean NumericType::expConvSupported
-(const NAType &otherNAType) const
-{
-  if (getFSDatatype() != REC_BIN64_UNSIGNED)
-    return TRUE;
-
-  if ((otherNAType.getFSDatatype() == REC_BIN64_SIGNED) ||
-      (otherNAType.getFSDatatype() == REC_BIN64_UNSIGNED) ||
-      (otherNAType.getFSDatatype() == REC_FLOAT32) ||
-      (otherNAType.getFSDatatype() == REC_FLOAT64) ||
-      (otherNAType.getFSDatatype() == REC_NUM_BIG_SIGNED) ||
-      (otherNAType.getFSDatatype() == REC_NUM_BIG_UNSIGNED) ||
-      (DFS2REC::isAnyCharacter(otherNAType.getFSDatatype())))
-    return TRUE;
-
-  return FALSE;
-}
-
 // -----------------------------------------------------------------------
 //  Methods for SQLTiny
 // -----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/NumericType.h
----------------------------------------------------------------------
diff --git a/core/sql/common/NumericType.h b/core/sql/common/NumericType.h
index 3ed2039..7c40019 100644
--- a/core/sql/common/NumericType.h
+++ b/core/sql/common/NumericType.h
@@ -247,9 +247,6 @@ public:
   virtual NAType *newCopy(CollHeap* h=0) const 
     { return new(h) NumericType(*this,h); }
 
-  virtual NABoolean expConvSupported
-  (const NAType &otherNAType) const;
-
 protected:
 
   // ---------------------------------------------------------------------
@@ -912,23 +909,29 @@ public:
     {
       if (isUnsigned())
 	{
-	  if (getNominalSize() == sizeof(short))
-	    return REC_BIN16_UNSIGNED;
+	  if (getNominalSize() == sizeof(UInt8))
+	    return REC_BIN8_UNSIGNED;
 	  else
-	    if (getNominalSize() == sizeof(Lng32))
-	      return REC_BIN32_UNSIGNED;
-	    else 
-              return REC_BIN64_UNSIGNED;
+            if (getNominalSize() == sizeof(short))
+              return REC_BIN16_UNSIGNED;
+            else
+              if (getNominalSize() == sizeof(Lng32))
+                return REC_BIN32_UNSIGNED;
+              else 
+                return REC_BIN64_UNSIGNED;
 	}
       else
 	{
-	  if (getNominalSize() == sizeof(short))
-	    return REC_BIN16_SIGNED;
+	  if (getNominalSize() == sizeof(Int8))
+	    return REC_BIN8_SIGNED;
 	  else
-	    if (getNominalSize() == sizeof(Lng32))
-	      return REC_BIN32_SIGNED;
-	    else
-	      return REC_BIN64_SIGNED;
+            if (getNominalSize() == sizeof(short))
+              return REC_BIN16_SIGNED;
+            else
+              if (getNominalSize() == sizeof(Lng32))
+                return REC_BIN32_SIGNED;
+              else
+                return REC_BIN64_SIGNED;
 	}
       
     }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/SQLTypeDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/SQLTypeDefs.h b/core/sql/common/SQLTypeDefs.h
index e1a73a0..27b29d8 100644
--- a/core/sql/common/SQLTypeDefs.h
+++ b/core/sql/common/SQLTypeDefs.h
@@ -70,6 +70,7 @@
 #define SQL_DOUBLE_PRECISION_SIZE 8
 #define SQL_CHAR_SIZE 1
 #define SQL_DBCHAR_SIZE 2
+#define SQL_BOOLEAN_SIZE 1
 
 #define SQL_NULL_HDR_SIZE 2
 #define SQL_VARCHAR_HDR_SIZE 2
@@ -88,6 +89,7 @@
 #define SQL_ULARGE_DISPLAY_SIZE 20
 #define SQL_REAL_DISPLAY_SIZE 15
 #define SQL_REAL_MIN_DISPLAY_SIZE 9
+#define SQL_BOOLEAN_DISPLAY_SIZE 5
 #define SQL_REAL_FRAG_DIGITS 7
 #define SQL_FLOAT_DISPLAY_SIZE 25
 #define SQL_FLOAT_FRAG_DIGITS 17

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/dfs2rec.h
----------------------------------------------------------------------
diff --git a/core/sql/common/dfs2rec.h b/core/sql/common/dfs2rec.h
index 7036eba..c87defb 100644
--- a/core/sql/common/dfs2rec.h
+++ b/core/sql/common/dfs2rec.h
@@ -132,12 +132,7 @@
   #define REC_BYTE_F_DOUBLE              2      // MP same name
   #define REC_NCHAR_F_UNICODE            2	// [MXsynonym]
 
-//#define REC_BYTE_F_DOUBLE_UP           3      // MP same name
-//#define REC_BYTE_F_MIXED               4      // MP same name
-//#define REC_BYTE_F_MIXED_UP            5      // MP same name
-
   #define REC_MAX_F_CHAR_H              47      // MP same name
-  // MP dfs2rec defines REC_BYTE_F_COLL_MIN..MAX, values 48..63, here
 
   #define REC_MIN_V_CHAR_H              64      // MP same name
 
@@ -148,10 +143,6 @@
   #define REC_BYTE_V_DOUBLE             66      // MP same name
   #define REC_NCHAR_V_UNICODE           66	// [MXsynonym]
 
-//#define REC_BYTE_V_DOUBLE_UP          67      // MP same name
-//#define REC_BYTE_V_MIXED              68      // MP same name
-//#define REC_BYTE_V_MIXED_UP           69      // MP same name
-
   #define REC_BYTE_V_ASCII_LONG         70      // MX only: ODBC LONG VARCHAR
 
 // These types do not exist in MP, *and* they do not exist as persistent
@@ -186,9 +177,9 @@
   #define REC_BLOB                     160      // SQ only: blob datatype
   #define REC_CLOB                     161      // SQ only: clob datatype
 
+  #define REC_BOOLEAN                  170
 
-
-#define REC_DATETIME      192
+  #define REC_DATETIME                  192
 
 // The ANSI defines are also in cli/SqlCLI.h (since they are externalized)
 // and must be the same as those defined there.  We don't source that file

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/str.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/str.cpp b/core/sql/common/str.cpp
index e51c125..a2a6c8c 100644
--- a/core/sql/common/str.cpp
+++ b/core/sql/common/str.cpp
@@ -997,19 +997,40 @@ Lng32 str_decode(void *tgt, Lng32 tgtMaxLen, const char *src, Lng32 srcLen)
   return length;
 }
 
-// Strips leading and trailing blanks. src will contain a NULL after the
+// Strips leading and/or trailing blanks. src will contain a NULL after the
 // end of the first non-blank character.The length of the "stripped" string
-// is returned in len
-
-void str_strip_blanks(char *src , Lng32 &len)
+// is returned in len.
+// Returns pointer to the start of string after leading blanks.
+char * str_strip_blanks(char *src , Lng32 &len, 
+                        NABoolean stripLeading,
+                        NABoolean stripTrailing
+                        )
 {
+  if (! src)
+    return NULL;
+
   len = str_len(src)-1;
-  while ((len >= 0) && (src[len] == ' '))
-    len--;
+  if (len <= 0)
+    return src;
 
-  len++;
+  if (stripTrailing)
+    {
+      while ((len >= 0) && (src[len] == ' '))
+        len--;
+
+      len++;
+      src[len] = 0;
+    }
+
+  Lng32 i = 0;
+  if (stripLeading)
+    {
+      while ((i < len) && (src[i] == ' '))
+        i++;
+      len = len - i;
+    }
 
-  src[len] = 0;
+  return &src[i];
 }
 
 #if !defined(__EID) && !defined(ARKFS_OPEN)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/common/str.h
----------------------------------------------------------------------
diff --git a/core/sql/common/str.h b/core/sql/common/str.h
index 327e459..f0741e3 100644
--- a/core/sql/common/str.h
+++ b/core/sql/common/str.h
@@ -357,13 +357,17 @@ NA_EIDPROC
 Lng32 str_decoded_len(Lng32 srcLen);
 NA_EIDPROC
 Lng32 str_decode(void *tgt, Lng32 tgtMaxLen, const char *src, Lng32 srcLen);
+
 //------------------------------------------------------------------------
-// Strips trailing blanks. src will contain a NULL after the
+// Strips leading and/or trailing blanks. src will contain a NULL after the
 // end of the first non-blank character.The length of the "stripped" string
-// is returned in len
+// is returned in len.
+// Returns pointer to the start of string after leading blanks.
 //------------------------------------------------------------------------
-NA_EIDPROC
-void str_strip_blanks(char *src , Lng32 &len);
+char * str_strip_blanks(char *src , Lng32 &len, 
+                      NABoolean stripLeading = FALSE,
+                      NABoolean stripTrailing = TRUE
+                        );
 //------------------------------------------------------------------------
 // This funtion transforms src into the form of an SQL identifier
 // Input : src,allowedChar

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/exp/ExpErrorEnums.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpErrorEnums.h b/core/sql/exp/ExpErrorEnums.h
index 6215598..2336ea0 100644
--- a/core/sql/exp/ExpErrorEnums.h
+++ b/core/sql/exp/ExpErrorEnums.h
@@ -148,6 +148,7 @@ enum ExeErrorCode
   EXE_FIELD_NUM_OVERFLOW                = 8423,
   EXE_MATH_FUNC_NOT_SUPPORTED           = 8424,
   EXE_DEFAULT_VALUE_ERROR               = 8425,
+  EXE_INVALID_BOOLEAN_VALUE             = 8426,
   EXE_SORT_ERROR                        = 8427,
   EXE_BAD_ARG_TO_MATH_FUNC              = 8428,
   EXE_MAPPED_FUNCTION_ERROR             = 8429,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/exp/ExpPCode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCode.cpp b/core/sql/exp/ExpPCode.cpp
index e40116f..9f0948e 100644
--- a/core/sql/exp/ExpPCode.cpp
+++ b/core/sql/exp/ExpPCode.cpp
@@ -546,10 +546,13 @@ Int32 PCode::size() {
                       || a == PCIT::MATTR3) ? 3 :    \
                       (  a == PCIT::IATTR2           \
                       || a == PCIT::MBIN8            \
+                      || a == PCIT::MBIN8S           \
+                      || a == PCIT::MBIN8U           \
                       || a == PCIT::MBIN16U          \
                       || a == PCIT::MBIN16S          \
                       || a == PCIT::MBIN32U          \
                       || a == PCIT::MBIN32S          \
+                      || a == PCIT::MBIN64U          \
                       || a == PCIT::MBIN64S          \
                       || a == PCIT::MPTR32           \
                       || a == PCIT::MASCII           \
@@ -1089,8 +1092,42 @@ Int32 PCode::size() {
   I3(Op_DECODE,MASCII,MBIN32S,IBIN32S,DECODE_MASCII_MBIN32S_IBIN32S),  // Instruction 333
   I3(Op_DECODE,MASCII,MBIN32U,IBIN32S,DECODE_MASCII_MBIN32U_IBIN32S),  // Instruction 334
   I3(Op_DECODE,MASCII,MBIN64S,IBIN32S,DECODE_MASCII_MBIN64S_IBIN32S),  // Instruction 335
-  I4(Op_DECODE,MASCII,MASCII,IBIN32S,IBIN32S,DECODE_NXX),              // Instruction 336
-  I4(Op_DECODE,MASCII,MDECS,IBIN32S,IBIN32S,DECODE_DECS),             // Instruction 337
+  I4(Op_DECODE,MASCII,MASCII,IBIN32S,IBIN32S,DECODE_DATETIME),         // Instruction 336
+  I4(Op_DECODE,MASCII,MASCII,IBIN32S,IBIN32S,DECODE_NXX),              // Instruction 337
+  I4(Op_DECODE,MASCII,MDECS,IBIN32S,IBIN32S,DECODE_DECS),              // Instruction 338
+
+  I2(Op_NEG,MASCII,MASCII,NEGATE_MASCII_MASCII),                       // Instruction 339
+
+  I3(Op_ENCODE,MASCII,MBIN8S,IBIN32S,ENCODE_MASCII_MBIN8S_IBIN32S),  // Instruction 340
+  I3(Op_ENCODE,MASCII,MBIN8U,IBIN32S,ENCODE_MASCII_MBIN8U_IBIN32S),  // Instruction 341
+
+  I3(Op_DECODE,MASCII,MBIN8S,IBIN32S,DECODE_MASCII_MBIN8S_IBIN32S),  // Instruction 342
+  I3(Op_DECODE,MASCII,MBIN8U,IBIN32S,DECODE_MASCII_MBIN8U_IBIN32S),  // Instruction 343
+ 
+  I2(Op_MOVE,MBIN16S,MBIN8S,MOVE_MBIN16S_MBIN8S),                    // Instruction 344
+  I2(Op_MOVE,MBIN16U,MBIN8U,MOVE_MBIN16U_MBIN8U),                    // Instruction 345
+  I2(Op_MOVE,MBIN32S,MBIN8S,MOVE_MBIN32S_MBIN8S),                    // Instruction 346
+  I2(Op_MOVE,MBIN32U,MBIN8U,MOVE_MBIN32U_MBIN8U),                    // Instruction 347
+  I2(Op_MOVE,MBIN64S,MBIN8S,MOVE_MBIN64S_MBIN8S),                    // Instruction 348
+  I2(Op_MOVE,MBIN64U,MBIN8U,MOVE_MBIN64U_MBIN8U),                    // Instruction 349
+
+  I3(Op_EQ,MBIN32S,MBIN8S,MBIN8S,EQ_MBIN32S_MBIN8S_MBIN8S),          // Instruction 350
+  I3(Op_NE,MBIN32S,MBIN8S,MBIN8S,NE_MBIN32S_MBIN8S_MBIN8S),          // Instruction 351
+  I3(Op_LT,MBIN32S,MBIN8S,MBIN8S,LT_MBIN32S_MBIN8S_MBIN8S),          // Instruction 352
+  I3(Op_GT,MBIN32S,MBIN8S,MBIN8S,GT_MBIN32S_MBIN8S_MBIN8S),          // Instruction 353
+  I3(Op_LE,MBIN32S,MBIN8S,MBIN8S,LE_MBIN32S_MBIN8S_MBIN8S),          // Instruction 354
+  I3(Op_GE,MBIN32S,MBIN8S,MBIN8S,GE_MBIN32S_MBIN8S_MBIN8S),          // Instruction 355
+
+  I3(Op_EQ,MBIN32S,MBIN8U,MBIN8U,EQ_MBIN32S_MBIN8U_MBIN8U),          // Instruction 356
+  I3(Op_NE,MBIN32S,MBIN8U,MBIN8U,NE_MBIN32S_MBIN8U_MBIN8U),          // Instruction 357
+  I3(Op_LT,MBIN32S,MBIN8U,MBIN8U,LT_MBIN32S_MBIN8U_MBIN8U),          // Instruction 358
+  I3(Op_GT,MBIN32S,MBIN8U,MBIN8U,GT_MBIN32S_MBIN8U_MBIN8U),          // Instruction 359
+  I3(Op_LE,MBIN32S,MBIN8U,MBIN8U,LE_MBIN32S_MBIN8U_MBIN8U),          // Instruction 360
+  I3(Op_GE,MBIN32S,MBIN8U,MBIN8U,GE_MBIN32S_MBIN8U_MBIN8U),          // Instruction 361
+
+  I2(Op_MOVE,MBIN64S,MBIN64U,MOVE_MBIN64S_MBIN64U),                  // Instruction 362
+  I2(Op_MOVE,MBIN64U,MBIN64S,MOVE_MBIN64U_MBIN64S),                  // Instruction 363
+  I2(Op_MOVE,MBIN64U,MBIN64U,MOVE_MBIN64U_MBIN64U),                  // Instruction 364
 
   };
 
@@ -1568,18 +1605,25 @@ PCIT::AddressingMode PCIT::getMemoryAddressingMode(Int32 datatype)
 {
   switch(datatype)
     {
+    case REC_BIN8_UNSIGNED: return PCIT::MBIN8U; break;
+    case REC_BIN8_SIGNED:   return PCIT::MBIN8S; break;
+
     case REC_BIN16_UNSIGNED: 
     case REC_BPINT_UNSIGNED: return PCIT::MBIN16U; break;
 
     case REC_BIN16_SIGNED:   return PCIT::MBIN16S; break;
     case REC_BIN32_UNSIGNED: return PCIT::MBIN32U; break;
     case REC_BIN32_SIGNED:   return PCIT::MBIN32S; break;
+    case REC_BIN64_UNSIGNED: return PCIT::MBIN64U; break;
     case REC_BIN64_SIGNED:   return PCIT::MBIN64S; break;
     case REC_IEEE_FLOAT32:   return PCIT::MFLT32; break;
     case REC_IEEE_FLOAT64:   return PCIT::MFLT64; break;
     case REC_DECIMAL_LSE:    return PCIT::MDECS; break;
     case REC_DECIMAL_UNSIGNED: return PCIT::MDECU; break;
+
+    case REC_BOOLEAN:        return PCIT::MASCII; break;
     case REC_BYTE_F_ASCII: return PCIT::MASCII; break;
+
     case REC_BYTE_V_ASCII: return PCIT::MATTR5; break;
     case REC_NCHAR_F_UNICODE: return PCIT::MUNI; break;
     case REC_NCHAR_V_UNICODE: return PCIT::MUNIV; break;
@@ -1593,6 +1637,8 @@ Int16 PCIT::getDataTypeForMemoryAddressingMode(PCIT::AddressingMode am)
 {
   switch(am)
   {
+    case PCIT::MBIN8S: return REC_BIN8_SIGNED; break;
+    case PCIT::MBIN8U: return REC_BIN8_UNSIGNED; break;
     case PCIT::IBIN16U:
     case PCIT::MBIN16U: return REC_BIN16_UNSIGNED; break;
     case PCIT::MBIN16S: return REC_BIN16_SIGNED; break;
@@ -1601,6 +1647,7 @@ Int16 PCIT::getDataTypeForMemoryAddressingMode(PCIT::AddressingMode am)
     case PCIT::MBIN32S: return REC_BIN32_SIGNED; break;
     case PCIT::IBIN64S:
     case PCIT::MBIN64S: return REC_BIN64_SIGNED; break;
+    case PCIT::MBIN64U: return REC_BIN64_UNSIGNED; break;
     case PCIT::MFLT32: return REC_IEEE_FLOAT32; break;
     case PCIT::MFLT64: return REC_IEEE_FLOAT64; break;
     case PCIT::MDECS: return REC_DECIMAL_LSE; break;
@@ -1635,10 +1682,13 @@ Int32 PCIT::getNumberOperandsForAddressingMode(PCIT::AddressingMode am)
       return 2;
 
     case PCIT::MBIN8:
+    case PCIT::MBIN8S:
+    case PCIT::MBIN8U:
     case PCIT::MBIN16U:
     case PCIT::MBIN16S:
     case PCIT::MBIN32U:
     case PCIT::MBIN32S:
+    case PCIT::MBIN64U:
     case PCIT::MBIN64S:
     case PCIT::MFLT32:
     case PCIT::MFLT64:
@@ -1681,6 +1731,8 @@ Int32 PCIT::getOperandLengthForAddressingMode(PCIT::AddressingMode am)
     case PCIT::MASCII:
     case PCIT::MDECS:
     case PCIT::MDECU:
+    case PCIT::MBIN8S:
+    case PCIT::MBIN8U:
     case PCIT::IBIN8U:
     case PCIT::IATTR4:
     case PCIT::IATTR3:
@@ -1695,6 +1747,7 @@ Int32 PCIT::getOperandLengthForAddressingMode(PCIT::AddressingMode am)
     case PCIT::MFLT32:
     case PCIT::IBIN32S:
       return 4;
+    case PCIT::MBIN64U:
     case PCIT::MBIN64S:
     case PCIT::MFLT64:
     case PCIT::IBIN64S:
@@ -1713,10 +1766,13 @@ Int32 PCIT::isMemoryAddressingMode(PCIT::AddressingMode am)
   switch(am)
     {
     case PCIT::MBIN8:
+    case PCIT::MBIN8U:
+    case PCIT::MBIN8S:
     case PCIT::MBIN16U:
     case PCIT::MBIN16S:
     case PCIT::MBIN32U:
     case PCIT::MBIN32S:
+    case PCIT::MBIN64U:
     case PCIT::MBIN64S:
     case PCIT::MFLT32:
     case PCIT::MFLT64:
@@ -1832,10 +1888,13 @@ const char *PCIT::operationString(PCIT::Operation op) {
 const char *PCIT::addressingModeString(PCIT::AddressingMode am) {
   switch(am) {
   case PCIT::MBIN8: return("MBIN8");
+  case PCIT::MBIN8S: return("MBIN8S");
+  case PCIT::MBIN8U: return("MBIN8U");
   case PCIT::MBIN16U: return("MBIN16U");
   case PCIT::MBIN16S: return("MBIN16S");
   case PCIT::MBIN32U: return("MBIN32U");
   case PCIT::MBIN32S: return("MBIN32S");
+  case PCIT::MBIN64U: return("MBIN64U");
   case PCIT::MBIN64S: return("MBIN64S");
   case PCIT::MFLT32: return("MFLT32");
   case PCIT::MFLT64: return("MFLT64");
@@ -1897,6 +1956,11 @@ Int32 PCI::getMemoryOperandLength(PCIT::AddressingMode am, Int32 op)
       if (am == PCIT::MPTR32)
         return getOperand(7);
       return 0;
+    case PCIT::ENCODE_MASCII_MBIN8S_IBIN32S:
+    case PCIT::ENCODE_MASCII_MBIN8U_IBIN32S:
+    case PCIT::DECODE_MASCII_MBIN8S_IBIN32S:
+    case PCIT::DECODE_MASCII_MBIN8U_IBIN32S:
+     return 1; 
     case PCIT::ENCODE_MASCII_MBIN16S_IBIN32S:
     case PCIT::ENCODE_MASCII_MBIN16U_IBIN32S:
     case PCIT::DECODE_MASCII_MBIN16S_IBIN32S:

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/exp/ExpPCodeClauseGen.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeClauseGen.cpp b/core/sql/exp/ExpPCodeClauseGen.cpp
index 83063c1..81c56fe 100644
--- a/core/sql/exp/ExpPCodeClauseGen.cpp
+++ b/core/sql/exp/ExpPCodeClauseGen.cpp
@@ -417,18 +417,22 @@ ex_expr::exp_return_type ex_function_encode::pCodeGenerate(Space *space, UInt32
       (isAnyOperandNullable()))
     return ex_clause::pCodeGenerate(space, f);
 
+  AttributesPtr *attrs = getOperand();
+  Attributes    *src = attrs[1];
+  Lng32 fsDataType = src->getDatatype();
+  Lng32 length = src->getLength();
+
   if (isDecode())
     {
       if (! getenv("PCODE_DECODE"))
 	return ex_clause::pCodeGenerate(space, f);
     }
     
-  AttributesPtr *attrs = getOperand();
-  Attributes    *src = attrs[1];
-  Lng32 fsDataType = src->getDatatype();
-  Lng32 length = src->getLength();
-
   switch(fsDataType) {
+  case REC_BIN8_SIGNED:
+  case REC_BIN8_UNSIGNED:
+    break;
+
   case REC_BIN16_SIGNED:
   case REC_BIN16_UNSIGNED:
   case REC_BIN32_SIGNED:
@@ -441,17 +445,11 @@ ex_expr::exp_return_type ex_function_encode::pCodeGenerate(Space *space, UInt32
     {
       // not enabled for NEO CA
       return ex_clause::pCodeGenerate(space, f);
-      
-      if (ex_expr::downrevCompile(f))
-	return ex_clause::pCodeGenerate(space, f);
     }
   break;
 
   case REC_BYTE_F_ASCII:
     // case REC_NCHAR_F_UNICODE:
-    // ascii pcode encode is not done on pre R2.1 nodes.
-    if (ex_expr::downrevCompileR2FCS(f))
-      return ex_clause::pCodeGenerate(space, f);
 
     // for now, do non-pcode encoding for caseInsensitive datatypes.
     // Later, add this to PCODE.
@@ -467,10 +465,6 @@ ex_expr::exp_return_type ex_function_encode::pCodeGenerate(Space *space, UInt32
   break;
 
   case REC_DATETIME:
-    // datetime pcode encode is not done on pre R2.1 nodes.
-    if (ex_expr::downrevCompileR2FCS(f))
-      return ex_clause::pCodeGenerate(space, f);
-
     // Do not generate PCODE to encode the non-standard SQL/MP
     // datetime types (for now).
     // Do not generate PCODE on windows(Little Endian) platform.
@@ -744,9 +738,6 @@ ex_expr::exp_return_type bool_result_clause::pCodeGenerate(Space *space, UInt32
 //
 ex_expr::exp_return_type ex_branch_clause::pCodeGenerate(Space *space, UInt32 f) {
 
-  if (ex_expr::downrevCompile(f))
-    return ex_clause::pCodeGenerate(space, f);
-
   if ((getOperType() != ITM_AND) &&
       (getOperType() != ITM_OR))
     return ex_clause::pCodeGenerate(space, f);
@@ -823,9 +814,6 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case LE_ASCII_F_F:
   case GT_ASCII_F_F:
   case GE_ASCII_F_F:
-    // ascii pcode comparison is not done on pre R2.1 nodes.
-    if (ex_expr::downrevCompileR2FCS(f))
-      return ex_clause::pCodeGenerate(space, f);
     break;
 
   case NE_UNICODE_F_F:
@@ -856,16 +844,14 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case LE_ASCII_COMP:
   case GT_ASCII_COMP:
   case GE_ASCII_COMP:
-    // ascii pcode comparison is not done on pre R2.1 nodes.
-    if (ex_expr::downrevCompileR2FCS(f))
-      return ex_clause::pCodeGenerate(space, f);
-
     // PCIT::getMemoryAddressingMode(), used below, cannot currently handle these.
     if ((attrs[1]->getDatatype() == REC_BYTE_V_ASCII_LONG ) ||
         (attrs[2]->getDatatype() == REC_BYTE_V_ASCII_LONG ))
       return ex_clause::pCodeGenerate(space, f);
     break;
 
+  case EQ_BIN8S_BIN8S:
+  case EQ_BIN8U_BIN8U:
   case EQ_BIN16S_BIN16S: 
   case EQ_BIN16S_BIN32S:
   case EQ_BIN32S_BIN16S: 
@@ -877,6 +863,8 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case EQ_BIN16S_BIN32U:
   case EQ_BIN32U_BIN16S:
 
+  case LT_BIN8S_BIN8S:
+  case LT_BIN8U_BIN8U:
   case LT_BIN16S_BIN16S: 
   case LT_BIN16S_BIN32S:
   case LT_BIN32S_BIN16S: 
@@ -888,6 +876,8 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case LT_BIN16S_BIN32U:
   case LT_BIN32U_BIN16S:
 
+  case GT_BIN8S_BIN8S:
+  case GT_BIN8U_BIN8U:
   case GT_BIN16S_BIN16S: 
   case GT_BIN16S_BIN32S:
   case GT_BIN32S_BIN16S: 
@@ -900,6 +890,8 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case GT_BIN32U_BIN16S:
     break;
 
+  case LE_BIN8S_BIN8S:
+  case LE_BIN8U_BIN8U:
   case LE_BIN16S_BIN16S: 
   case LE_BIN16S_BIN32S:
   case LE_BIN32S_BIN16S: 
@@ -911,6 +903,8 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case LE_BIN16S_BIN32U:
   case LE_BIN32U_BIN16S:
 
+  case GE_BIN8S_BIN8S:
+  case GE_BIN8U_BIN8U:
   case GE_BIN16S_BIN16S: 
   case GE_BIN16S_BIN32S:
   case GE_BIN32S_BIN16S: 
@@ -921,8 +915,6 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case GE_BIN32U_BIN32U: 
   case GE_BIN16S_BIN32U:
   case GE_BIN32U_BIN16S:
-    if (ex_expr::downrevCompileR2FCS(f))
-      return ex_clause::pCodeGenerate(space, f);
     break;
 
   case EQ_BIN16U_BIN16S: 
@@ -930,8 +922,6 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case LT_BIN16U_BIN16S:
   case GE_BIN16U_BIN16S:
   case GT_BIN16U_BIN16S:
-    if (ex_expr::downrevCompileRR(f))
-      return ex_clause::pCodeGenerate(space, f);
     break;
 
   case EQ_BIN64S_BIN64S:
@@ -940,13 +930,11 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case GE_BIN64S_BIN64S:
   case GT_BIN64S_BIN64S:
   case NE_BIN64S_BIN64S:
-    if (ex_expr::downrevCompileRR(f))
-      return ex_clause::pCodeGenerate(space, f);
     break;
 
+  case NE_BIN8S_BIN8S:
+  case NE_BIN8U_BIN8U:
   case NE_BIN16S_BIN16S:
-    if (ex_expr::downrevCompile(f))
-      return ex_clause::pCodeGenerate(space, f);
     break;
 
   case NE_FLOAT32_FLOAT32:
@@ -962,8 +950,6 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case LE_FLOAT64_FLOAT64:
   case GT_FLOAT64_FLOAT64:
   case GE_FLOAT64_FLOAT64:
-    if (ex_expr::downrevCompile(f))
-      return ex_clause::pCodeGenerate(space, f);
     break;
 
 
@@ -974,10 +960,6 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   case LE_DATETIME_DATETIME:
   case GE_DATETIME_DATETIME:
 #endif
-    // datetime pcode comparison is not done on pre R2.1 nodes.
-    if (ex_expr::downrevCompileR2FCS(f))
-      return ex_clause::pCodeGenerate(space, f);
-
     // Do not generate PCODE to encode the non-standard SQL/MP
     // datetime types (for now).
     if ((attrs[1]->getPrecision() > REC_DTCODE_TIMESTAMP) ||
@@ -986,6 +968,10 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
       return ex_clause::pCodeGenerate(space, f);
     break;
 
+  case EQ_BOOL_BOOL:
+  case NE_BOOL_BOOL:
+    break;
+
   default:
     return ex_clause::pCodeGenerate(space, f);
   }
@@ -995,14 +981,16 @@ ex_expr::exp_return_type ex_comp_clause::pCodeGenerate(Space *space, UInt32 f) {
   PCIT::Operation op = PCIT::Op_OPDATA; // prevent init warning
   switch(get_case_index()) {
 
-case EQ_BIN32S_BIN16S:
+  case EQ_BIN32S_BIN16S:
   case EQ_BIN32U_BIN16U:
   case EQ_BIN32U_BIN16S:
     // Normalize instructions so smaller operand comes first
     flipOperands = TRUE;
     op = PCIT::Op_EQ;
     break;
-    
+
+  case EQ_BIN8S_BIN8S:
+  case EQ_BIN8U_BIN8U:
   case EQ_BIN16U_BIN16S: 
   case EQ_BIN16S_BIN16S: 
   case EQ_BIN16S_BIN32S:
@@ -1020,6 +1008,10 @@ case EQ_BIN32S_BIN16S:
      op = PCIT::Op_EQ;
     break;
 
+  case EQ_BOOL_BOOL:
+     op = PCIT::Op_EQ;
+    break;
+
   case LT_BIN32S_BIN16S:
   case LT_BIN32U_BIN16U:
   case LT_BIN32U_BIN16S:
@@ -1028,6 +1020,8 @@ case EQ_BIN32S_BIN16S:
     op = PCIT::Op_GT;
     break;
 
+  case LT_BIN8S_BIN8S:
+  case LT_BIN8U_BIN8U:
   case LT_BIN16U_BIN16S:
   case LT_BIN16S_BIN16S:
   case LT_BIN16S_BIN32S:
@@ -1053,6 +1047,8 @@ case EQ_BIN32S_BIN16S:
     op = PCIT::Op_LT;
     break;
 
+  case GT_BIN8S_BIN8S:
+  case GT_BIN8U_BIN8U:
   case GT_BIN16U_BIN16S:
   case GT_BIN16S_BIN16S:
   case GT_BIN16S_BIN32S:
@@ -1078,6 +1074,8 @@ case EQ_BIN32S_BIN16S:
     op = PCIT::Op_GE;
     break;
 
+  case LE_BIN8S_BIN8S:
+  case LE_BIN8U_BIN8U:
   case LE_BIN16U_BIN16S:
   case LE_BIN16S_BIN16S:
   case LE_BIN16S_BIN32S:
@@ -1103,6 +1101,8 @@ case EQ_BIN32S_BIN16S:
     op = PCIT::Op_LE;
     break;
 
+  case GE_BIN8S_BIN8S:
+  case GE_BIN8U_BIN8U:
   case GE_BIN16U_BIN16S:
   case GE_BIN16S_BIN16S:
   case GE_BIN16S_BIN32S:
@@ -1122,12 +1122,15 @@ case EQ_BIN32S_BIN16S:
     op = PCIT::Op_GE;
     break;
 
+  case NE_BIN8S_BIN8S:
+  case NE_BIN8U_BIN8U:
   case NE_FLOAT32_FLOAT32:
   case NE_FLOAT64_FLOAT64:
   case NE_BIN64S_BIN64S:
   case NE_BIN16S_BIN16S:
   case NE_ASCII_COMP:
   case NE_ASCII_F_F:
+  case NE_BOOL_BOOL:
     op = PCIT::Op_NE;
     break;
 
@@ -1149,9 +1152,6 @@ case EQ_BIN32S_BIN16S:
   //
   if (isAnyOperandNullable())
     {
-      if (ex_expr::downrevCompile(f))
-	return ex_clause::pCodeGenerate(space, f);
-
       // if special nulls, only handle equality predicate. 
       if ( isSpecialNulls() && (getOperType() != ITM_EQUAL) )
         return ex_clause::pCodeGenerate(space, f);
@@ -1207,11 +1207,13 @@ case EQ_BIN32S_BIN16S:
     code.append(pci);
   }
   // both the operands are fixed chars/unicode or are of type DATETIME
+  // or of type boolean.
   else if (((op1->getDatatype() == REC_BYTE_F_ASCII) &&
             (op2->getDatatype() == REC_BYTE_F_ASCII)) ||
            ((op1->getDatatype() == REC_NCHAR_F_UNICODE) &&
             (op2->getDatatype() == REC_NCHAR_F_UNICODE)) ||
-           (op1->getDatatype() == REC_DATETIME))
+           (op1->getDatatype() == REC_DATETIME) ||
+           (op1->getDatatype() == REC_BOOLEAN))
   {
     // Operand 1: memory location of boolean result
     // Operand 2: memory location of 1st argument
@@ -1354,14 +1356,14 @@ case EQ_BIN32S_BIN16S:
       op2 = tempOp;
     }
 
-  AML aml(PCIT::getMemoryAddressingMode(attrs[0]->getDatatype()),
-          PCIT::getMemoryAddressingMode(op1->getDatatype()),
-          PCIT::getMemoryAddressingMode(op2->getDatatype()));
-
-  OL ol(attrs[0]->getAtp(), attrs[0]->getAtpIndex(), attrs[0]->getOffset(),
-        op1->getAtp(), op1->getAtpIndex(), op1->getOffset(),
-        op2->getAtp(), op2->getAtpIndex(), op2->getOffset());
-
+    AML aml(PCIT::getMemoryAddressingMode(attrs[0]->getDatatype()),
+            PCIT::getMemoryAddressingMode(op1->getDatatype()),
+            PCIT::getMemoryAddressingMode(op2->getDatatype()));
+    
+    OL ol(attrs[0]->getAtp(), attrs[0]->getAtpIndex(), attrs[0]->getOffset(),
+          op1->getAtp(), op1->getAtpIndex(), op1->getOffset(),
+          op2->getAtp(), op2->getAtpIndex(), op2->getOffset());
+    
     // Add the comparison instruction.
     //
     PCI pci(op, aml, ol);
@@ -1581,9 +1583,7 @@ ex_expr::exp_return_type ExHDPHash::pCodeGenerate(Space *space, UInt32 f)
   // The third operand is the length of the data.
   //
   PCIType::AddressingMode oper;
-  if (ex_expr::downrevCompile(f))
-    oper = PCIT::MPTR32;
-  else if (attrs[1]->getLength() == 8)
+  if (attrs[1]->getLength() == 8)
     oper = PCIT::MBIN64S;
   else if (attrs[1]->getLength() == 4)
     oper = PCIT::MBIN32S;
@@ -1737,9 +1737,7 @@ ex_expr::exp_return_type ex_function_hash::pCodeGenerate(Space *space, UInt32 f)
   // The third operand is the length of the data.
   //
   PCIType::AddressingMode oper;
-  if (ex_expr::downrevCompile(f))
-    oper = PCIT::MPTR32;
-  else if (attrs[1]->getLength() == 8)
+  if (attrs[1]->getLength() == 8)
     oper = PCIT::MBIN64S;
   else if (attrs[1]->getLength() == 4)
     oper = PCIT::MBIN32S;
@@ -1885,9 +1883,6 @@ ex_expr::exp_return_type ExHashComb::pCodeGenerate(Space *space, UInt32 f) {
   if(getenv("PCODE_NO_HASHCOMB")) return ex_clause::pCodeGenerate(space, f);
 #endif
 
-  if (ex_expr::downrevCompileR2FCS(f))
-    return ex_clause::pCodeGenerate(space, f);
-  
   // Get a handle on the operands
   //
   AttributesPtr *attrs = getOperand();
@@ -2030,6 +2025,91 @@ Int32 isTemporaryAttribute(Attributes *attr) { return attr->getAtpIndex() == 1;}
 NA_EIDPROC
 Int32 isAtpAttribute(Attributes *attr) { return attr->getAtpIndex() > 1; };
 
+ex_expr::exp_return_type ex_arith_clause::unaryArithPCodeGenerate
+(Space *space, UInt32 f) 
+{
+  if (getNumOperands() != 2)
+    return ex_expr::EXPR_ERROR;
+
+  AttributesPtr *attrs = getOperand();
+
+  switch(get_case_index()) {
+
+  case NEGATE_BOOLEAN:
+    break;
+
+  default:
+    return ex_clause::pCodeGenerate(space, f);
+  }
+
+  // Allocate the code list and get a handle on the attributes
+  //
+  PCIList code(space);
+
+  // Don't get mixed up in interval conversions. The precision for
+  // interval conversions is not set up correctly.
+  //
+  Attributes *dst = attrs[0];
+  Attributes *op1 = attrs[1];
+  
+  // Generate pre clause PCI's
+  //
+  PCode::preClausePCI(this, code);
+
+  // Construct the operands.
+  //
+  OL ol2(dst->getAtp(), dst->getAtpIndex(), dst->getOffset(),  
+	 op1->getAtp(), op1->getAtpIndex(), op1->getOffset());
+
+  AML aml2(PCIT::getMemoryAddressingMode(dst->getDatatype()),
+	   PCIT::getMemoryAddressingMode(op1->getDatatype()));
+
+  // Construct the operation.
+  //
+  AML *aml = NULL;
+  OL *ol = NULL;
+  PCIT::Operation inst = PCIT::Op_OPDATA;  // prevent uninitialized var warning
+ 
+  switch(get_case_index()) 
+    {
+    case NEGATE_BOOLEAN:
+      aml = &aml2;
+      ol = &ol2;
+      inst = PCIT::Op_NEG;
+      break;
+    }
+
+  // Add the null logic if necessary.
+  //
+  PCIID branchToEnd = PCode::nullBranch(this, code, attrs);
+
+  // Add the instruction.
+  //
+  PCI pci(inst, *aml, *ol);
+  code.append(pci);
+
+  // Add the branch target if necessary.
+  //
+  if(branchToEnd)
+  {
+    AML aml; 
+#ifdef NA_64BIT
+    OL ol((Int64)branchToEnd);
+#else
+    OL ol((PCIType::Operand)branchToEnd);
+#endif
+    PCI pci(PCIT::Op_TARGET, aml, ol); 
+    code.append(pci);
+  }
+
+  // Generate post clause PCI's
+  //
+  PCode::postClausePCI(this, code);
+
+  setPCIList(code.getList());
+  return ex_expr::EXPR_OK;
+}
+
 // ex_arith_clause::pCodeGenerate
 //
 // Generate PCI's for the arithematic operations. The PCI's load the operands,
@@ -2046,6 +2126,12 @@ ex_expr::exp_return_type ex_arith_clause::pCodeGenerate(Space *space, UInt32 f)
   if(getenv("PCODE_NO_ARITH")) return ex_clause::pCodeGenerate(space, f);
 #endif
 
+  // if unary arith operator, generator unary pcode.
+  if (getNumOperands() == 2) // 1 result and 1 operand
+    {
+      return unaryArithPCodeGenerate(space, f);
+    }
+
   // Generate the standard clause->eval PCode for cases that
   // are not handled with more fundamental PCode operations.
   //
@@ -2080,34 +2166,18 @@ ex_expr::exp_return_type ex_arith_clause::pCodeGenerate(Space *space, UInt32 f)
   case MUL_BIN16S_BIN32S_BIN64S:
   case MUL_BIN32S_BIN16S_BIN64S:
   case MUL_BIN32S_BIN32S_BIN64S:
-    {
-      if (ex_expr::downrevCompile(f))
-	return ex_clause::pCodeGenerate(space, f);
-    }
     break;
 
   case DIV_BIN64S_BIN64S_BIN64S:
-    {
-      if (ex_expr::downrevCompileR2FCS(f))
-	return ex_clause::pCodeGenerate(space, f);
-    }
     break;
 
   case DIV_BIN64S_BIN64S_BIN64S_ROUND:
-    {
-      if (ex_expr::downrevCompileR2FCS(f))
-	return ex_clause::pCodeGenerate(space, f);
-    }
     break;
 
   case ADD_FLOAT64_FLOAT64_FLOAT64:
   case SUB_FLOAT64_FLOAT64_FLOAT64:
   case MUL_FLOAT64_FLOAT64_FLOAT64:
   case DIV_FLOAT64_FLOAT64_FLOAT64:
-    {
-      if (ex_expr::downrevCompile(f))
-        return ex_clause::pCodeGenerate(space, f);
-    }
     break;
 
   case SUB_COMPLEX:
@@ -2121,7 +2191,7 @@ ex_expr::exp_return_type ex_arith_clause::pCodeGenerate(Space *space, UInt32 f)
     return ex_clause::pCodeGenerate(space, f);
   }
 
-  // Allocate the code list and get <a handle on the attributes
+  // Allocate the code list and get a handle on the attributes
   //
   PCIList code(space);
 
@@ -2137,7 +2207,7 @@ ex_expr::exp_return_type ex_arith_clause::pCodeGenerate(Space *space, UInt32 f)
      (op1->getDatatype() < REC_MIN_NUMERIC) ||
      (op1->getDatatype() > REC_MAX_NUMERIC))
     return ex_clause::pCodeGenerate(space, f);
-
+  
   // Generate pre clause PCI's
   //
   PCode::preClausePCI(this, code);
@@ -2319,6 +2389,7 @@ ex_expr::exp_return_type ex_arith_clause::pCodeGenerate(Space *space, UInt32 f)
       ol = &olx;
       inst = PCIT::Op_DIV;
       break;      
+
     }
 
   // Add the null logic if necessary.
@@ -2381,10 +2452,6 @@ ex_expr::exp_return_type ex_arith_sum_clause::pCodeGenerate(Space *space, UInt32
     break;
 
   case ADD_FLOAT64_FLOAT64_FLOAT64:
-    {
-      if (ex_expr::downrevCompile(f))
-        return ex_clause::pCodeGenerate(space, f);
-    }
     break;
 
   case ADD_COMPLEX:
@@ -2514,9 +2581,9 @@ ex_expr::exp_return_type ex_arith_count_clause::pCodeGenerate(Space *space, UInt
 };
 
 NA_EIDPROC static void computeBounds(Attributes *attr, Int64 &lowBounds, 
-			  Int64 &highBounds, Int32 &bigBounds, Int32 &isSigned)
+			  UInt64 &highBounds, Int32 &bigBounds, Int32 &isSigned)
 {
-const  Int64 decimalPrecision[] = {
+const  UInt64 decimalPrecision[] = {
     0,
     9, 
     99, 
@@ -2527,7 +2594,6 @@ const  Int64 decimalPrecision[] = {
     9999999, 
     99999999, 
     999999999,
-//SQ_LINUX #ifndef NA_HSC
     9999999999LL, 
     99999999999LL, 
     999999999999LL, 
@@ -2537,7 +2603,8 @@ const  Int64 decimalPrecision[] = {
     9999999999999999LL,
     99999999999999999LL,
     999999999999999999LL,
-    4999999999999999999LL
+    4999999999999999999LL,
+    9999999999999999999ULL
   };
 
 const  Int32 bpPrecision[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
@@ -2557,6 +2624,10 @@ const  Int32 bpPrecision[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
       isSigned = 1;
       switch(attr->getDatatype())
 	{
+	case REC_BIN8_UNSIGNED:
+	  isSigned = 0;
+	  break;
+
 	case REC_BIN16_UNSIGNED:
 	  isSigned = 0;
 	  break;
@@ -2567,10 +2638,17 @@ const  Int32 bpPrecision[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
 
 	case REC_BIN64_SIGNED:
 	  bigBounds = 1;
+          break;
+
+	case REC_BIN64_UNSIGNED:
+          isSigned = 0;
+	  bigBounds = 1;
+          break;
 	}
 
       lowBounds = 0;
-      if(isSigned) lowBounds = - decimalPrecision[attr->getPrecision()];
+      if (isSigned) 
+        lowBounds = - decimalPrecision[attr->getPrecision()];
       highBounds = decimalPrecision[attr->getPrecision()];
     }
   // Binarys have precision = 0
@@ -2584,6 +2662,12 @@ const  Int32 bpPrecision[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
 	  highBounds = bpPrecision[attr->getPrecision()];
 	  break;
 
+	case REC_BIN8_SIGNED:
+	  lowBounds = CHAR_MIN;
+	  highBounds = CHAR_MAX;
+	  isSigned = 1;
+	  break;
+
 	case REC_BIN16_SIGNED:
 	  lowBounds = SHRT_MIN;
 	  highBounds = SHRT_MAX;
@@ -2614,6 +2698,13 @@ const  Int32 bpPrecision[] = { 0, 1, 3, 7, 15, 31, 63, 127, 255, 511,
 	  highBounds = (Int64)LLONG_MAX;
 	  isSigned = 1;
 	  break;
+
+	case REC_BIN64_UNSIGNED:
+	  bigBounds = 1;
+	  lowBounds = 0;
+	  highBounds = ULLONG_MAX;
+	  break;
+
 	}
     }
 }
@@ -2651,11 +2742,12 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
 
   // CIF bulk move -- no pcode yet --there will be later
 
-    if ( lastVOAoffset_>0)
+  if ( lastVOAoffset_>0)
     {
       if (getenv("NO_CIF_BULK_MOVE_PCODE"))
-      return ex_clause::pCodeGenerate(space, f);
+        return ex_clause::pCodeGenerate(space, f);
     }
+
   // Get a handle on the operands.
   //
   AttributesPtr *attrs = getOperand();
@@ -2683,30 +2775,31 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
 	  return ex_clause::pCodeGenerate(space, f);
 	}
     }
-  else
-  // Don't get mixed up in interval conversions. The precision for
-  // interval conversions is not set up correctly.
-  //
-  if (((dst->getDatatype() < REC_MIN_NUMERIC) ||
-       (dst->getDatatype() > REC_MAX_NUMERIC) ||
-       (src->getDatatype() < REC_MIN_NUMERIC) ||
-       (src->getDatatype() > REC_MAX_NUMERIC)) &&
-      (((dst->getDatatype() != REC_BYTE_F_ASCII) ||
-	(src->getDatatype() != REC_BYTE_F_ASCII)) &&
-       ((dst->getDatatype() != REC_BYTE_V_ASCII) ||
-	(src->getDatatype() != REC_BYTE_V_ASCII)) &&
-       ((dst->getDatatype() != REC_BYTE_F_ASCII) ||
-	(src->getDatatype() != REC_BYTE_V_ASCII)) &&
-       ((dst->getDatatype() != REC_BYTE_V_ASCII) ||
-	(src->getDatatype() != REC_BYTE_F_ASCII)) &&
-       ((dst->getDatatype() != REC_NCHAR_V_UNICODE) ||
-        (src->getDatatype() != REC_NCHAR_V_UNICODE)) &&
-       ((dst->getDatatype() != REC_NCHAR_F_UNICODE) ||
-        (src->getDatatype() != REC_NCHAR_F_UNICODE)) &&
-       ((dst->getDatatype() != REC_DATETIME) ||
-	(src->getDatatype() != REC_DATETIME))))
+  else if ((dst->getDatatype() == REC_BOOLEAN) &&
+           (src->getDatatype() == REC_BOOLEAN))
+    {
+      // boolean conversions are pcode supported.
+    }
+  else if (((dst->getDatatype() < REC_MIN_NUMERIC) ||
+            (dst->getDatatype() > REC_MAX_NUMERIC) ||
+            (src->getDatatype() < REC_MIN_NUMERIC) ||
+            (src->getDatatype() > REC_MAX_NUMERIC)) &&
+           (((dst->getDatatype() != REC_BYTE_F_ASCII) ||
+             (src->getDatatype() != REC_BYTE_F_ASCII)) &&
+            ((dst->getDatatype() != REC_BYTE_V_ASCII) ||
+             (src->getDatatype() != REC_BYTE_V_ASCII)) &&
+            ((dst->getDatatype() != REC_BYTE_F_ASCII) ||
+             (src->getDatatype() != REC_BYTE_V_ASCII)) &&
+            ((dst->getDatatype() != REC_BYTE_V_ASCII) ||
+             (src->getDatatype() != REC_BYTE_F_ASCII)) &&
+            ((dst->getDatatype() != REC_NCHAR_V_UNICODE) ||
+             (src->getDatatype() != REC_NCHAR_V_UNICODE)) &&
+            ((dst->getDatatype() != REC_NCHAR_F_UNICODE) ||
+             (src->getDatatype() != REC_NCHAR_F_UNICODE)) &&
+            ((dst->getDatatype() != REC_DATETIME) ||
+             (src->getDatatype() != REC_DATETIME))))
     return ex_clause::pCodeGenerate(space, f);
-
+  
   // Generate the standard clause->eval PCode for particular
   // conversions that are not handled with more fundamental PCode 
   // operations.
@@ -2737,6 +2830,10 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
   case CONV_BIN64S_BIN16S: /*case CONV_BIN64S_BIN16U:*/
   case CONV_BIN64S_BIN32S: case CONV_BIN64S_BIN32U:
   case CONV_BIN64S_BIN64S: 
+  case CONV_BIN64U_BIN64U: 
+
+  case CONV_BIN64S_BIN64U:
+    //  case CONV_BIN64U_BIN64S: // not yet supported
     break;
     /*case CONV_BIN64S_FLOAT32: case CONV_BIN64S_FLOAT64:*/
     
@@ -2754,9 +2851,6 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
       // not enabled for NEO CA
       return ex_clause::pCodeGenerate(space, f);
       
-      if (ex_expr::downrevCompile(f))
-        return ex_clause::pCodeGenerate(space, f);
-      
       if (attrs[0]->getScale() != attrs[1]->getScale())
 	return ex_clause::pCodeGenerate(space, f);
     }
@@ -2787,20 +2881,12 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
 
   case CONV_FLOAT32_FLOAT32:
   case CONV_FLOAT64_FLOAT64:
-    {
-      if (ex_expr::downrevCompile(f))
-        return ex_clause::pCodeGenerate(space, f);
-    }
   break;
   
   case CONV_BIN64S_FLOAT64:
   case CONV_BIN32S_FLOAT64:
   case CONV_BIN16S_FLOAT64:
   case CONV_FLOAT32_FLOAT64:
-    {
-      if (ex_expr::downrevCompile(f))
-        return ex_clause::pCodeGenerate(space, f);
-    }
   break;
 
   case CONV_ASCII_F_F:
@@ -2843,20 +2929,12 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
 	{
 	  if (dst->getLength() < src->getLength())
 	    return ex_clause::pCodeGenerate(space, f);
-	  else if (dst->getLength() > src->getLength())
-	    {
-	      if (ex_expr::downrevCompileRR(f))
-		return ex_clause::pCodeGenerate(space, f);
-	    }
 	}
 
       if ((get_case_index() == CONV_ASCII_V_V) ||
 	  (get_case_index() == CONV_DATETIME_DATETIME) ||
 	  (get_case_index() == CONV_DECS_DECS))
 	{
-	  //	  if (ex_expr::downrevCompileR2FCS(f))
-	  // return ex_clause::pCodeGenerate(space, f);
-	  
 	  if ((get_case_index() == CONV_DATETIME_DATETIME) ||
 	      (get_case_index() == CONV_DECS_DECS))
 	    {
@@ -2957,20 +3035,19 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
     }
   break;
   
-  /**
-    case CONV_SIMPLE_TO_COMPLEX:
-    if((attrs[0]->getDatatype() == REC_DECIMAL_LARGE_SIGNED) &&
-    (attrs[1]->getDatatype() == REC_BIN64_SIGNED))
+  case CONV_BIN8S_BIN8S:
+  case CONV_BIN8U_BIN8U:
+  case CONV_BIN8S_BIN16S:
+  case CONV_BIN8U_BIN16U:
+  case CONV_BIN8S_BIN32S:
+  case CONV_BIN8U_BIN32U:
+  case CONV_BIN8S_BIN64S:
+  case CONV_BIN8U_BIN64U:
     break;
-    return ex_clause::pCodeGenerate(space, f);
-    
-    case CONV_COMPLEX_TO_COMPLEX:
-    if((attrs[0]->getDatatype() == REC_DECIMAL_LARGE_SIGNED) &&
-    (attrs[1]->getDatatype() == REC_DECIMAL_LARGE_SIGNED))
+
+  case CONV_BOOL_BOOL:
     break;
-    return ex_clause::pCodeGenerate(space, f);
-    **/
-  
+
   default:
     return ex_clause::pCodeGenerate(space, f);
   }
@@ -3018,16 +3095,17 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
      (get_case_index() != CONV_FLOAT32_FLOAT64) &&
      (get_case_index() != CONV_BIN16S_FLOAT64) &&
      (get_case_index() != CONV_BIN32S_FLOAT64) &&
-     (get_case_index() != CONV_BIN64S_FLOAT64)) {
+     (get_case_index() != CONV_BIN64S_FLOAT64) &&
+     (get_case_index() != CONV_BOOL_BOOL)) {
 
 
     // Compute the high and low bounds of the source and destination
     // operands.
     //
     Int32 srcBig, dstBig, srcSigned, dstSigned;
-    Int64 srcHighBounds = 0;
+    UInt64 srcHighBounds = 0;
     Int64 srcLowBounds = 0;
-    Int64 dstHighBounds = 0;
+    UInt64 dstHighBounds = 0;
     Int64 dstLowBounds = 0;
 
     computeBounds(src, srcLowBounds, srcHighBounds, srcBig, srcSigned);
@@ -3086,9 +3164,13 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
     case CONV_BIN32U_BIN32U: case CONV_BIN32U_BIN32S:
     case CONV_BIN32S_BIN32S: case CONV_BIN32S_BIN32U:
     case CONV_BIN64S_BIN64S:
+    case CONV_BIN64U_BIN64U:
     case CONV_BPINTU_BPINTU:
     case CONV_FLOAT64_FLOAT64:
     case CONV_FLOAT32_FLOAT32:
+    case CONV_BIN8S_BIN8S:
+    case CONV_BIN8U_BIN8U:
+    case CONV_BOOL_BOOL:
       {
 	AML aml(PCIT::MBIN8, PCIT::MBIN8, PCIT::IBIN32S);
 #pragma nowarn(1506)   // warning elimination 
@@ -3236,6 +3318,19 @@ ex_expr::exp_return_type ex_conv_clause::pCodeGenerate(Space *space, UInt32 f) {
       break;
     }
 
+    case CONV_BIN8S_BIN16S:
+    case CONV_BIN8U_BIN16U:
+     {
+	AML aml(PCIT::getMemoryAddressingMode(dst->getDatatype()),
+		PCIT::getMemoryAddressingMode(src->getDatatype()));
+	OL ol(dst->getAtp(), dst->getAtpIndex(), (Int32)dst->getOffset(),
+	      src->getAtp(), src->getAtpIndex(), (Int32)src->getOffset());
+	PCI pci(PCIT::Op_MOVE, aml, ol);
+
+	code.append(pci);
+      }
+      break;
+
     default:
       {
 	AML aml(PCIT::getMemoryAddressingMode(dst->getDatatype()),
@@ -3763,9 +3858,6 @@ ex_expr::exp_return_type ExFunctionRandomNum::pCodeGenerate(Space *space, UInt32
   if (NOT simpleRandom()) 
     return ex_clause::pCodeGenerate(space, f);
     
-  if (ex_expr::downrevCompile(f))
-    return ex_clause::pCodeGenerate(space, f);
-      
   // Get a handle on the operands
   //
   AttributesPtr *attrs = getOperand();
@@ -3948,8 +4040,8 @@ ex_expr::exp_return_type ex_function_substring::pCodeGenerate(Space *space,
   if(cs != CharInfo::ISO88591)
     return ex_clause::pCodeGenerate(space, f);
 
-  // If there are too many nullable fields, or downrev...
-  if ((numOfNullableFields > 2) || ex_expr::downrevCompile(f))
+  // If there are too many nullable fields
+  if (numOfNullableFields > 2)
     return ex_clause::pCodeGenerate(space, f);
 
   //

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/exp/ExpPCodeExpGen.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeExpGen.cpp b/core/sql/exp/ExpPCodeExpGen.cpp
index 5846715..a40e54a 100644
--- a/core/sql/exp/ExpPCodeExpGen.cpp
+++ b/core/sql/exp/ExpPCodeExpGen.cpp
@@ -692,8 +692,7 @@ ex_expr::exp_return_type ex_expr::pCodeGenerate(Space * space,
                 if (!getenv("PCODE_NO_STD_MOVE"))
 #endif
                   {
-                  if ((NOT doPCodeMoveFastpathOpt) &&
-		      (!ex_expr_base::downrevCompile(f)))
+                  if (NOT doPCodeMoveFastpathOpt)
                     {
                     Lng32 length = storePci->getOperand(6);
 
@@ -742,7 +741,7 @@ ex_expr::exp_return_type ex_expr::pCodeGenerate(Space * space,
                         // move.
                         storePci->replaceAddressingModesAndOperands(aml, ol);
                       }
-	            }   // if !downrevCompile
+	            }   // if
 	          }
 	    }    // if PCIT::MOVE_MBIN8_MBIN8_IBIN32S
         else

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/exp/ExpPCodeInstruction.h
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeInstruction.h b/core/sql/exp/ExpPCodeInstruction.h
index f0ab593..e903996 100644
--- a/core/sql/exp/ExpPCodeInstruction.h
+++ b/core/sql/exp/ExpPCodeInstruction.h
@@ -106,7 +106,7 @@ public:
     // Logical operators
     Op_AND, Op_OR, 
     // Arithematic operators
-    Op_ADD, Op_SUB, Op_MUL, Op_DIV, Op_DIV_ROUND, Op_SUM, Op_MOD,
+    Op_ADD, Op_SUB, Op_MUL, Op_DIV, Op_DIV_ROUND, Op_SUM, Op_MOD, Op_NEG,
     Op_MINMAX,
     // Bitwise operator
     Op_BITOR,
@@ -166,7 +166,8 @@ public:
 
     // Memory accesses
     //
-    MBIN8, MBIN16U, MBIN16S, MBIN32U, MBIN32S, MBIN64S, MPTR32,
+    MBIN8, MBIN8U, MBIN8S, MBIN16U, MBIN16S, MBIN32U, MBIN32S, 
+    MBIN64S, MBIN64U, MPTR32,
     MASCII, MDECS, MDECU, MFLT32, MFLT64, MATTR3, MATTR4, MATTR5, MATTR6,
     MBIGU, MBIGS, MUNI, MUNIV,
 
@@ -689,7 +690,41 @@ public:
     DECODE_MASCII_MBIN64S_IBIN32S = 335,
     DECODE_DATETIME               = 336,
     DECODE_NXX                    = 337,
-    DECODE_DECS                 = 338,
+    DECODE_DECS                   = 338,
+
+    // unary operations
+    NEGATE_MASCII_MASCII          = 339,
+
+    // tinyint operations
+    ENCODE_MASCII_MBIN8S_IBIN32S  = 340,
+    ENCODE_MASCII_MBIN8U_IBIN32S  = 341,
+    DECODE_MASCII_MBIN8S_IBIN32S  = 342,
+    DECODE_MASCII_MBIN8U_IBIN32S  = 343,
+    MOVE_MBIN16S_MBIN8S           = 344,
+    MOVE_MBIN16U_MBIN8U           = 345,
+    MOVE_MBIN32S_MBIN8S           = 346,
+    MOVE_MBIN32U_MBIN8U           = 347,
+    MOVE_MBIN64S_MBIN8S           = 348,
+    MOVE_MBIN64U_MBIN8U           = 349,
+
+    EQ_MBIN32S_MBIN8S_MBIN8S      = 350,
+    NE_MBIN32S_MBIN8S_MBIN8S      = 351,
+    LT_MBIN32S_MBIN8S_MBIN8S      = 352,
+    GT_MBIN32S_MBIN8S_MBIN8S      = 353,
+    LE_MBIN32S_MBIN8S_MBIN8S      = 354,
+    GE_MBIN32S_MBIN8S_MBIN8S      = 355,
+
+    EQ_MBIN32S_MBIN8U_MBIN8U      = 356,
+    NE_MBIN32S_MBIN8U_MBIN8U      = 357,
+    LT_MBIN32S_MBIN8U_MBIN8U      = 358,
+    GT_MBIN32S_MBIN8U_MBIN8U      = 359,
+    LE_MBIN32S_MBIN8U_MBIN8U      = 360,
+    GE_MBIN32S_MBIN8U_MBIN8U      = 361,
+
+    // largeint unsigned operations
+    MOVE_MBIN64S_MBIN64U          = 362,
+    MOVE_MBIN64U_MBIN64S          = 363,
+    MOVE_MBIN64U_MBIN64U          = 364,
 
     //***************************************************************
     // Add new PCODE instructions immediately above this comment!!!!!

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/exp/ExpPCodeOptimizations.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeOptimizations.cpp b/core/sql/exp/ExpPCodeOptimizations.cpp
index 4589454..3d781fb 100644
--- a/core/sql/exp/ExpPCodeOptimizations.cpp
+++ b/core/sql/exp/ExpPCodeOptimizations.cpp
@@ -303,6 +303,8 @@ Int32 PCodeOperand::getAlign()
 
   switch (getType()) {
     case PCIT::MBIN8:
+    case PCIT::MBIN8S:
+    case PCIT::MBIN8U:
     case PCIT::MASCII:
       return 1;
 
@@ -1192,6 +1194,8 @@ NABoolean PCodeInst::isIntEqComp()
   Int32 opc = getOpcode();
 
   switch (opc) {
+    case PCIT::EQ_MBIN32S_MBIN8S_MBIN8S:
+    case PCIT::EQ_MBIN32S_MBIN8U_MBIN8U:
     case PCIT::EQ_MBIN32S_MBIN16S_MBIN16S:
     case PCIT::EQ_MBIN32S_MBIN16S_MBIN32S:
     case PCIT::EQ_MBIN32S_MBIN32S_MBIN32S:
@@ -1254,6 +1258,8 @@ NABoolean PCodeInst::isEncode()
   Int32 opc = getOpcode();
 
   switch (opc) {
+    case PCIT::ENCODE_MASCII_MBIN8S_IBIN32S:
+    case PCIT::ENCODE_MASCII_MBIN8U_IBIN32S:
     case PCIT::ENCODE_MASCII_MBIN16S_IBIN32S:
     case PCIT::ENCODE_MASCII_MBIN16U_IBIN32S:
     case PCIT::ENCODE_MASCII_MBIN32S_IBIN32S:
@@ -1271,6 +1277,8 @@ NABoolean PCodeInst::isDecode()
   Int32 opc = getOpcode();
 
   switch (opc) {
+    case PCIT::DECODE_MASCII_MBIN8S_IBIN32S:
+    case PCIT::DECODE_MASCII_MBIN8U_IBIN32S:
     case PCIT::DECODE_MASCII_MBIN16S_IBIN32S:
     case PCIT::DECODE_MASCII_MBIN16U_IBIN32S:
     case PCIT::DECODE_MASCII_MBIN32S_IBIN32S:
@@ -3993,6 +4001,9 @@ void PCodeCfg::inlining()
       return;
 
   switch (inst->getOpcode()) {
+    case PCIT::EQ_MBIN32S_MBIN8S_MBIN8S:
+    case PCIT::EQ_MBIN32S_MBIN8U_MBIN8U:
+
     case PCIT::EQ_MBIN32S_MBIN16S_MBIN16S:
     case PCIT::EQ_MBIN32S_MBIN32S_MBIN32S:
     case PCIT::EQ_MBIN32S_MBIN16U_MBIN16U:
@@ -4659,12 +4670,16 @@ NABoolean PCodeCfg::localCSE(INSTLIST** parent, PCodeBlock* tailBlock,
             match = (head->code[1] == tail->code[1]);
             break;
 
+          case PCIT::ENCODE_MASCII_MBIN8S_IBIN32S:
+          case PCIT::ENCODE_MASCII_MBIN8U_IBIN32S:
           case PCIT::ENCODE_MASCII_MBIN32S_IBIN32S:
           case PCIT::ENCODE_MASCII_MBIN32U_IBIN32S:
           case PCIT::ENCODE_MASCII_MBIN16S_IBIN32S:
           case PCIT::ENCODE_MASCII_MBIN16U_IBIN32S:
           case PCIT::ENCODE_MASCII_MBIN64S_IBIN32S:
           case PCIT::ENCODE_NXX:
+          case PCIT::DECODE_MASCII_MBIN8S_IBIN32S:
+          case PCIT::DECODE_MASCII_MBIN8U_IBIN32S:
           case PCIT::DECODE_MASCII_MBIN32S_IBIN32S:
           case PCIT::DECODE_MASCII_MBIN32U_IBIN32S:
           case PCIT::DECODE_MASCII_MBIN16S_IBIN32S:
@@ -7674,11 +7689,41 @@ void PCodeCfg::loadOperandsOfInst (PCodeInst* newInst)
       addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MPTR32, pcode[4]);
       break;
 
-    case PCIT::MOVE_MBIN16U_MBIN8:
+    case PCIT::MOVE_MBIN16S_MBIN8S:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN16S, 2);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8S, 1);
+      break;
+
+    case PCIT::MOVE_MBIN16U_MBIN8U:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN16U, 2);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8U, 1);
+      break;
+
+     case PCIT::MOVE_MBIN16U_MBIN8:
       addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN16U, 2);
       addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8, 1);
       break;
 
+    case PCIT::MOVE_MBIN32S_MBIN8S:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN32S, 4);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8S, 1);
+      break;
+
+    case PCIT::MOVE_MBIN32U_MBIN8U:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN32U, 4);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8U, 1);
+      break;
+
+    case PCIT::MOVE_MBIN64S_MBIN8S:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN64S, 8);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8S, 1);
+      break;
+
+    case PCIT::MOVE_MBIN64U_MBIN8U:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN64U, 8);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8U, 1);
+      break;
+
     case PCIT::MOVE_MBIN32U_MBIN16U:
       addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN32U, 4);
       addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN16U, 2);
@@ -7719,7 +7764,22 @@ void PCodeCfg::loadOperandsOfInst (PCodeInst* newInst)
       addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN32S, 4);
       break;
 
-    case PCIT::MOVE_MBIN64S_MDECS_IBIN32S:
+    case PCIT::MOVE_MBIN64S_MBIN64U:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN64S, 8);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN64U, 8);
+      break;
+
+    case PCIT::MOVE_MBIN64U_MBIN64S:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN64U, 8);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN64S, 8);
+      break;
+
+    case PCIT::MOVE_MBIN64U_MBIN64U:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN64U, 8);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN64U, 8);
+      break;
+
+     case PCIT::MOVE_MBIN64S_MDECS_IBIN32S:
       addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN64S, 8);
       addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MDECS, pcode[4]);
       break;
@@ -7800,8 +7860,6 @@ void PCodeCfg::loadOperandsOfInst (PCodeInst* newInst)
     }
 
 
-
-
     case PCIT::ZERO_MBIN32S_MBIN32U:
     case PCIT::NOTZERO_MBIN32S_MBIN32U:
       addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN32S, 4);
@@ -7809,6 +7867,28 @@ void PCodeCfg::loadOperandsOfInst (PCodeInst* newInst)
       break;
 
 
+    case PCIT::EQ_MBIN32S_MBIN8S_MBIN8S:
+    case PCIT::NE_MBIN32S_MBIN8S_MBIN8S:
+    case PCIT::LT_MBIN32S_MBIN8S_MBIN8S:
+    case PCIT::GT_MBIN32S_MBIN8S_MBIN8S:
+    case PCIT::LE_MBIN32S_MBIN8S_MBIN8S:
+    case PCIT::GE_MBIN32S_MBIN8S_MBIN8S:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN32S, 4);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8S, 1);
+      addOperand(pcode, newInst->getROps(), 4, 5, -1, PCIT::MBIN8S, 1);
+      break;
+
+    case PCIT::EQ_MBIN32S_MBIN8U_MBIN8U:
+    case PCIT::NE_MBIN32S_MBIN8U_MBIN8U:
+    case PCIT::LT_MBIN32S_MBIN8U_MBIN8U:
+    case PCIT::GT_MBIN32S_MBIN8U_MBIN8U:
+    case PCIT::LE_MBIN32S_MBIN8U_MBIN8U:
+    case PCIT::GE_MBIN32S_MBIN8U_MBIN8U:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN32S, 4);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8U, 1);
+      addOperand(pcode, newInst->getROps(), 4, 5, -1, PCIT::MBIN8U, 1);
+      break;
+
 
     case PCIT::EQ_MBIN32S_MBIN16S_MBIN16S:
     case PCIT::NE_MBIN32S_MBIN16S_MBIN16S:
@@ -8050,6 +8130,11 @@ void PCodeCfg::loadOperandsOfInst (PCodeInst* newInst)
       break;
 
 
+    case PCIT::NEGATE_MASCII_MASCII:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MASCII, 2);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MASCII, 2);
+      break;
+
 
     case PCIT::SUM_MBIN32S_MBIN32S:
       addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN32S, 4);
@@ -8078,11 +8163,19 @@ void PCodeCfg::loadOperandsOfInst (PCodeInst* newInst)
 
 
 
+    case PCIT::ENCODE_MASCII_MBIN8S_IBIN32S:
+    case PCIT::ENCODE_MASCII_MBIN8U_IBIN32S:
+    case PCIT::DECODE_MASCII_MBIN8S_IBIN32S:
+    case PCIT::DECODE_MASCII_MBIN8U_IBIN32S:
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN8S, 1);
+      addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN8S, 1);
+      break;
+
     case PCIT::ENCODE_MASCII_MBIN16S_IBIN32S:
     case PCIT::ENCODE_MASCII_MBIN16U_IBIN32S:
     case PCIT::DECODE_MASCII_MBIN16S_IBIN32S:
     case PCIT::DECODE_MASCII_MBIN16U_IBIN32S:
-       addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN16S, 2);
+      addOperand(pcode, newInst->getWOps(), 0, 1, -1, PCIT::MBIN16S, 2);
       addOperand(pcode, newInst->getROps(), 2, 3, -1, PCIT::MBIN16S, 2);
       break;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/exp/ExpPCodeOptsConstProp.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/ExpPCodeOptsConstProp.cpp b/core/sql/exp/ExpPCodeOptsConstProp.cpp
index 9f57619..18c5feb 100644
--- a/core/sql/exp/ExpPCodeOptsConstProp.cpp
+++ b/core/sql/exp/ExpPCodeOptsConstProp.cpp
@@ -1825,6 +1825,12 @@ Int64 PCodeCfg::getIntConstValue(PCodeOperand* op)
     case PCIT::MBIN8:
       value = (Int64)*((UInt8*)(constPtr->getData()));
       break;
+    case PCIT::MBIN8S:
+      value = (Int64)*((Int8*)(constPtr->getData()));
+      break;
+    case PCIT::MBIN8U:
+      value = (Int64)*((UInt8*)(constPtr->getData()));
+      break;
     case PCIT::MBIN16S:
       value = (Int64)*((Int16*)(constPtr->getData()));
       break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d48a0c94/core/sql/exp/exp_arith.cpp
----------------------------------------------------------------------
diff --git a/core/sql/exp/exp_arith.cpp b/core/sql/exp/exp_arith.cpp
index dcec35f..b7f2b6f 100644
--- a/core/sql/exp/exp_arith.cpp
+++ b/core/sql/exp/exp_arith.cpp
@@ -1337,7 +1337,11 @@ ex_expr::exp_return_type ex_arith_clause::eval(char *op_data[],
 	  }
       }
       break;
-       
+
+    case NEGATE_BOOLEAN:
+      *(Int8 *)op_data[0] = (*(Int8*)op_data[1] == 1 ? 0 : 1);
+      break;
+
       // COMPLEX datatype operations
     case ADD_COMPLEX:
       ((ComplexType *)getOperand(0))->add(getOperand(1), getOperand(2), op_data);



Mime
View raw message