You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2015/08/18 17:18:41 UTC

[2/4] incubator-trafodion git commit: TRAFODION-1457 Issues related to decoding HBase region keys and TEXT table

TRAFODION-1457 Issues related to decoding HBase region keys and TEXT table


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

Branch: refs/heads/master
Commit: 1e60a9b8cd487698c44659663ad09ddc455c3708
Parents: d35f77e
Author: Hans Zeller <ha...@esgyn.com>
Authored: Mon Aug 17 21:43:31 2015 +0000
Committer: Hans Zeller <ha...@esgyn.com>
Committed: Mon Aug 17 21:43:31 2015 +0000

----------------------------------------------------------------------
 core/sql/bin/SqlciErrors.txt                    |   9 +-
 core/sql/common/CharType.cpp                    | 266 ++++++-------------
 core/sql/common/CharType.h                      |   7 +
 core/sql/common/ComSmallDefs.h                  |   7 +-
 core/sql/common/IntervalType.cpp                |   2 +-
 core/sql/common/NAType.h                        |   7 +
 core/sql/common/csconvert.cpp                   |  21 ++
 core/sql/common/csconvert.h                     |  14 +-
 core/sql/optimizer/BindItemExpr.cpp             |  14 +-
 core/sql/optimizer/EncodedKeyValue.cpp          |   1 +
 core/sql/optimizer/ItemCache.cpp                |   1 -
 core/sql/optimizer/ItemColRef.h                 |  10 -
 core/sql/optimizer/ItemExpr.cpp                 | 108 +-------
 core/sql/optimizer/NATable.cpp                  | 227 +++++++++++-----
 core/sql/optimizer/NATable.h                    |   1 -
 core/sql/optimizer/QRDescGenerator.cpp          |   4 +-
 core/sql/parser/ElemDDLNode.cpp                 |   2 +-
 core/sql/parser/StmtDDLCreate.cpp               |  10 +-
 core/sql/regress/charsets/DIFF002.KNOWN.SB      |  14 -
 core/sql/regress/charsets/DIFF002.KNOWN.SB.OS   |  14 -
 core/sql/regress/charsets/EXPECTED002           | 260 ++++++++++++++++++
 core/sql/regress/charsets/EXPECTED002.SB        | 254 ------------------
 core/sql/regress/charsets/EXPECTED003           | 217 +++++++++++++++
 core/sql/regress/charsets/EXPECTED003.SB        | 217 ---------------
 core/sql/regress/charsets/EXPECTED012           | 205 ++++++++++++++
 core/sql/regress/charsets/EXPECTED012.SB        | 205 --------------
 core/sql/regress/compGeneral/DIFF042.KNOWN.SB   |  38 +--
 core/sql/regress/compGeneral/EXPECTED042        | 105 ++++----
 core/sql/regress/compGeneral/EXPECTEDTOK2       |  46 ++++
 core/sql/regress/compGeneral/EXPECTEDTOK2.LINUX |  46 ----
 core/sql/regress/compGeneral/TEST015            |  10 +-
 core/sql/regress/compGeneral/TEST042            |  16 +-
 core/sql/regress/core/TEST056                   |  10 +-
 core/sql/sqlcomp/CmpDescribe.cpp                |   2 +-
 core/sql/sqlcomp/CmpSeabaseDDL.h                |  22 +-
 core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp        | 216 +++++++++------
 core/sql/sqlcomp/CmpSeabaseDDLindex.cpp         |  10 +-
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp         |  59 ++--
 core/sql/sqlcomp/CmpSeabaseDDLupgrade.cpp       |   9 +-
 core/sql/sqlcomp/CmpSeabaseDDLview.cpp          |  13 +-
 core/sql/sqlcomp/DefaultConstants.h             |   2 +
 core/sql/sqlcomp/nadefaults.cpp                 |   6 +
 42 files changed, 1349 insertions(+), 1358 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/bin/SqlciErrors.txt
----------------------------------------------------------------------
diff --git a/core/sql/bin/SqlciErrors.txt b/core/sql/bin/SqlciErrors.txt
index f90cfa6..68ed8a0 100644
--- a/core/sql/bin/SqlciErrors.txt
+++ b/core/sql/bin/SqlciErrors.txt
@@ -205,6 +205,13 @@
 1203 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU HBASE_OPTIONS clause in CREATE statement is longer than 6000 characters. Object $0~string0 was not created.
 1204 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU Unsupported Hive datatype $0~string0.
 1205 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU Hive feature $0~string0 is not supported.
+1206 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU SALT AND SPLIT BY clauses are not allowed together.
+1207 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU Text to be inserted into the TEXT metadata table contains too many quotes.
+1208 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU The SPLIT BY clause is not supported for indexes.
+1209 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU The SPLIT BY clause has more columns than the table has key columns ($0~Int0).
+1210 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU Column $0~String0 is not allowed at position $1~Int0 in the SPLIT BY clause, because SPLIT BY must specify a prefix of the clustering key columns and the next clustering key column is $2~String1.
+1211 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU The column values of the SPLIT BY first key in position $0~Int0 (one-based) are not greater (for ascending columns) or less (for descending columns) than its predecessor.
+1212 ZZZZZ 99999 UUUUUUUU UUUUU UUUUUUU An HBase region start key provided only part of the value for Trafodion key column $0~Int0. This could in some unusual situations cause errors.
 1220 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Code must contain two non-blank characters.
 1221 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Only system components may contain system operations.
 1222 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Command not supported when authorization is not enabled.
@@ -843,7 +850,7 @@ $1~String1 --------------------------------
 3100 42000 99999 BEGINNER MAJOR DBADMIN Duplicate DSLACK clauses were specified.
 3101 42000 99999 BEGINNER MAJOR DBADMIN Duplicate ISLACK clauses were specified.
 3102 42000 99999 BEGINNER MAJOR DBADMIN Duplicate PARALLEL EXECUTION clauses were specified.
-3103 42000 99999 BEGINNER MAJOR DBADMIN Duplicate PARTITION clauses were specified.
+3103 42000 99999 BEGINNER MAJOR DBADMIN Duplicate $0~string0 clauses were specified.
 3104 42000 99999 BEGINNER MAJOR DBADMIN Only the ADD option is allowed in a PARTITION clause in a CREATE TABLE statement.
 3105 0A000 99999 BEGINNER MAJOR DBADMIN Only range, hash, hash2 and system partitioning are currently supported.
 3106 42000 99999 BEGINNER MAJOR DBADMIN Duplicate PRIMARY KEY clauses were specified.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/common/CharType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/CharType.cpp b/core/sql/common/CharType.cpp
index 4811884..40d258d 100644
--- a/core/sql/common/CharType.cpp
+++ b/core/sql/common/CharType.cpp
@@ -1140,46 +1140,74 @@ NAString* CharType::getKey(CollHeap* h) const
   return new (h) NAString(getTypeSQLname(), h);
 }
 
-
-// -- Min and max permissible values for a CHAR string
-// ## These too will need to be changed to handle different collating sequences
-// ## and character sets and multibyte chars and such ...
-
-void SQLChar::minRepresentableValue(void* bufPtr, Lng32* bufLen,
-				    NAString ** stringLiteral,
-				    CollHeap* h) const
+void CharType::minMaxRepresentableValue(void* bufPtr,
+                                        Lng32* bufLen,
+                                        NAString ** stringLiteral,
+                                        NABoolean isMax,
+                                        CollHeap* h) const
 {
-// 2/19/98: checked for unicode. No need to add Unicode case.
-  ComASSERT(*bufLen >= getNominalSize());
+  Int32 i;
+  Int32 vcLenHdrSize = getVarLenHdrSize();
+  char *valPtr       = reinterpret_cast<char *>(bufPtr) + vcLenHdrSize;
+  Int32 valBufLen    = getNominalSize();
+  Int32 valLen       = valBufLen; // output length of min/max value
+  char minmax_char;
+  wchar_t minmax_wchar;
 
-  Lng32 i = 0;
-  Lng32 bufCnt = *bufLen;
-  char min_char;
-  wchar_t min_wchar;
+  ComASSERT(*bufLen >= vcLenHdrSize + valBufLen);
 
-  if (getCharSet() == CharInfo::ISO88591 ||
-      getCharSet() == CharInfo::UTF8 ||
-      (getCharSet() == CharInfo::SJIS && getEncodingCharSet() == CharInfo::SJIS))
-  {
-      min_char = (char)getMinSingleCharacterValue();
-      for ( ;i < bufCnt; i++)
-         ((char *)bufPtr)[i] = min_char;
-  }
-  else if (getCharSet() == CharInfo::UCS2 ||
-           getBytesPerChar() == SQL_DBCHAR_SIZE /* same as SQL_SJIS_CHAR_MAXSIZE - so be careful */)
+  switch (getCharSet())
   {
-      min_wchar = (wchar_t)getMinSingleCharacterValue();
+  case CharInfo::ISO88591:
+  case CharInfo::SJIS:
+    if (isMax)
+      minmax_char = (char)getMaxSingleCharacterValue();
+    else
+      minmax_char = (char)getMinSingleCharacterValue();
+    memset(valPtr, minmax_char, valBufLen);
+    break;
+
+  case CharInfo::UTF8:
+    if (isMax)
+      valLen = fillWithMaxUTF8Chars(valPtr,
+                                    valBufLen,
+                                    getPrecisionOrMaxNumChars());
+    else
+      valLen = fillWithMinUTF8Chars(valPtr,
+                                    valBufLen,
+                                    getPrecisionOrMaxNumChars());
+    break;
+
+  case CharInfo::UCS2:
+    if (isMax)
+      minmax_wchar = (wchar_t)getMaxSingleCharacterValue();
+    else
+      minmax_wchar = (wchar_t)getMinSingleCharacterValue();
 #ifdef NA_LITTLE_ENDIAN
-      wc_swap_bytes(&min_wchar, 1);
+    wc_swap_bytes(&minmax_wchar, 1);
 #endif // NA_LITTLE_ENDIAN
-      bufCnt = bufCnt / SQL_DBCHAR_SIZE;
-      for ( ;i < bufCnt; i++)
-         ((wchar_t *)bufPtr)[i] = min_wchar;
+    valBufLen /= SQL_DBCHAR_SIZE;
+    for (i=0 ;i < valBufLen; i++)
+      ((wchar_t *)valPtr)[i] = minmax_wchar;
+    break;
 
-      i = i * SQL_DBCHAR_SIZE; // For proper NAString construction
+  default:
+    ComASSERT(FALSE); //LCOV_EXCL_LINE :rfi -- no other CharSets are supported yet.
   }
+
+  // copy the output value length into the varchar len header
+  if (vcLenHdrSize == sizeof(short))
+    {
+      short vc_len = (short) valLen;
+      str_cpy_all((char *)bufPtr, (char *)&vc_len, vcLenHdrSize);
+    }
+  else if (vcLenHdrSize == sizeof(Int32))
+    {
+      Int32 vc_len = (Int32) valLen;
+      str_cpy_all((char *)bufPtr, (char *)&vc_len, vcLenHdrSize);
+    }
   else
-      ComASSERT(FALSE); //LCOV_EXCL_LINE :rfi -- no other CharSets are supported yet.
+    ComASSERT(vcLenHdrSize == 0);
 
   if (stringLiteral)
     {
@@ -1189,51 +1217,22 @@ void SQLChar::minRepresentableValue(void* bufPtr, Lng32* bufLen,
     }
 }
 
-void SQLChar::maxRepresentableValue(void* bufPtr, Lng32* bufLen,
+// -- Min and max permissible values for a CHAR string
+// ## These too will need to be changed to handle different collating sequences
+// ## and character sets and multibyte chars and such ...
+
+void SQLChar::minRepresentableValue(void* bufPtr, Lng32* bufLen,
 				    NAString ** stringLiteral,
 				    CollHeap* h) const
 {
-// 2/19/98: checked for unicode
-  ComASSERT(*bufLen >= getNominalSize());
-
-  Lng32 i = 0;
-  Lng32 bufCnt = *bufLen;
-  char max_char;
-  wchar_t max_wchar;
-
-  if (getCharSet() == CharInfo::ISO88591 ||
-      (getCharSet() == CharInfo::SJIS && getEncodingCharSet() == CharInfo::SJIS))
-  {
-      max_char = (char)getMaxSingleCharacterValue();
-      for ( ;i < bufCnt; i++)
-         ((char *)bufPtr)[i] = max_char;
-  }
-  else if (getCharSet() == CharInfo::UTF8)
-  {
-    fillWithMaxUTF8Chars((char *)bufPtr,bufCnt,getPrecisionOrMaxNumChars());
-  }
-  else if (getCharSet() == CharInfo::UCS2 ||
-           getBytesPerChar() == SQL_DBCHAR_SIZE /* same as SQL_SJIS_CHAR_MAXSIZE - so be careful */)
-  {
-      max_wchar = (wchar_t)getMaxSingleCharacterValue();
-#ifdef NA_LITTLE_ENDIAN
-      wc_swap_bytes(&max_wchar, 1);
-#endif // NA_LITTLE_ENDIAN
-      bufCnt = bufCnt / SQL_DBCHAR_SIZE;
-      for ( ;i < bufCnt; i++)
-         ((wchar_t *)bufPtr)[i] = max_wchar;
-
-      i = i * SQL_DBCHAR_SIZE; // For proper NAString construction
-  }
-  else
-      ComASSERT(FALSE); //LCOV_EXCL_LINE :rfi -- no other CharSets are supported yet.
+  minMaxRepresentableValue(bufPtr, bufLen, stringLiteral, FALSE, h);
+}
 
-  if (stringLiteral)
-    {
-      NABoolean isNull = FALSE;
-      NABoolean res = createSQLLiteral((const char *) bufPtr, *stringLiteral, isNull, h);
-      assert(res);
-    }
+void SQLChar::maxRepresentableValue(void* bufPtr, Lng32* bufLen,
+				    NAString ** stringLiteral,
+				    CollHeap* h) const
+{
+  minMaxRepresentableValue(bufPtr, bufLen, stringLiteral, TRUE, h);
 }
 
 //  encoding of the max char value
@@ -1281,130 +1280,15 @@ void SQLVarChar::minRepresentableValue(void* bufPtr, Lng32* bufLen,
 				       NAString ** stringLiteral,
 				       CollHeap* h) const
 {
-  ComASSERT(*bufLen >= getNominalSize() + getVarLenHdrSize());
-
-  // copy the max length into the varchar len header
-  if (getVarLenHdrSize() == sizeof(short))
-    {
-      short vc_len = (short)getNominalSize();
-      str_cpy_all((char *)bufPtr, (char *)&vc_len, getVarLenHdrSize());
-    }
-  else  if (getVarLenHdrSize() == sizeof(Lng32))
-    {
-      Lng32 vc_len = (Lng32)getNominalSize();
-      str_cpy_all((char *)bufPtr, (char *)&vc_len, getVarLenHdrSize());
-    }
-  else
-    ComASSERT(0);
-
-  Lng32 i = getVarLenHdrSize();
-  Lng32 bufCnt = getVarLenHdrSize() + getNominalSize();
-  char min_char;
-  wchar_t min_wchar;
-
-  switch (getBytesPerChar())
-  {
-    case 4: // sames SQL_UTF8_CHAR_MAXSIZE
-      if (getCharSet() != CharInfo::UTF8)
-        ComASSERT(FALSE); //LCOV_EXCL_LINE :rfi -- no CharSet other than UTF8 has 4-byte chars
-      // fall through
-    case 1:
-      min_char = (char)getMinSingleCharacterValue();
-      for ( ;i < bufCnt; i++)
-         ((char *)bufPtr)[i] = min_char;
-      break;
-    case SQL_DBCHAR_SIZE: // same as BYTES_PER_NAWCHAR and SQL_SJIS_CHAR_MAXSIZE
-#if 0 /* SJIS NOT SUPPORTED YET */
-      if (getCharSet() == CharInfo::SJIS &&
-          getEncodingCharSet() == CharInfo::SJIS)
-      {
-        min_char = (char)getMinSingleCharacterValue();
-        for ( ;i < bufCnt; i++)
-           ((char *)bufPtr)[i] = min_char;
-        break;
-      }
-#endif
-      // else getCharSet() == CharInfo::UCS2
-      min_wchar = (wchar_t)getMinSingleCharacterValue();
-#ifdef NA_LITTLE_ENDIAN
-      wc_swap_bytes(&min_wchar, 1);
-#endif // NA_LITTLE_ENDIAN
-      bufCnt = bufCnt / SQL_DBCHAR_SIZE;
-      for (i = i / SQL_DBCHAR_SIZE; i < bufCnt; i++)
-         ((wchar_t *)bufPtr)[i] = min_wchar;
-
-      i = i * SQL_DBCHAR_SIZE; // For proper NAString construction
-      break;
-    default:
-      ComASSERT(FALSE); //LCOV_EXCL_LINE :rfi  -- no values other than 1,2, & 4 are possible
-  }
-  if (stringLiteral)
-    {
-      NABoolean isNull = FALSE;
-      NABoolean res = createSQLLiteral((const char *) bufPtr, *stringLiteral, isNull, h);
-      assert(res);
-    }
-} // minRepresentableValue()
+  minMaxRepresentableValue(bufPtr, bufLen, stringLiteral, FALSE, h);
+}
 
 void SQLVarChar::maxRepresentableValue(void* bufPtr, Lng32* bufLen,
 				       NAString ** stringLiteral,
 				       CollHeap* h) const
 {
-  ComASSERT(*bufLen >= getNominalSize() + getVarLenHdrSize());
-
-  // copy the max length into the varchar len header
-  if (getVarLenHdrSize() == sizeof(short))
-    {
-      short vc_len = (short)getNominalSize();
-      str_cpy_all((char *)bufPtr, (char *)&vc_len, getVarLenHdrSize());
-    }
-  else  if (getVarLenHdrSize() == sizeof(Lng32))
-    {
-      Lng32 vc_len = (Lng32)getNominalSize();
-      str_cpy_all((char *)bufPtr, (char *)&vc_len, getVarLenHdrSize());
-    }
-  else
-    ComASSERT(0);
-
-  Lng32 i = getVarLenHdrSize();
-  Lng32 bufCnt = getVarLenHdrSize() + getNominalSize();
-  char max_char;
-  wchar_t max_wchar;
-
-  switch (getBytesPerChar())
-  {
-    case 4: // sames SQL_UTF8_CHAR_MAXSIZE
-      ComASSERT(getCharSet() == CharInfo::UTF8);
-      fillWithMaxUTF8Chars(&((char *)bufPtr)[i],bufCnt-i,getPrecisionOrMaxNumChars());
-      break;
-    case 1:
-      max_char = (char)getMaxSingleCharacterValue();
-      for ( ;i < bufCnt; i++)
-         ((char *)bufPtr)[i] = max_char;
-      break;
-    case SQL_DBCHAR_SIZE: // same as BYTES_PER_NAWCHAR and SQL_SJIS_CHAR_MAXSIZE
-      {
-        max_wchar = (wchar_t)getMaxSingleCharacterValue();
-#ifdef NA_LITTLE_ENDIAN
-        wc_swap_bytes(&max_wchar, 1);
-#endif // NA_LITTLE_ENDIAN
-        wchar_t *wBufPtr = (wchar_t *) (((char *) bufPtr) + getVarLenHdrSize());
-        Int32 wBufCnt = getNominalSize() / SQL_DBCHAR_SIZE;
-        for (i=0; i < wBufCnt; i++)
-          wBufPtr[i] = max_wchar;
-
-        break;
-      }
-    default:
-      ComASSERT(FALSE); //LCOV_EXCL_LINE :rfi -- No values other than 1,2, & 4 are possible.
-  }
-  if (stringLiteral)
-    {
-      NABoolean isNull = FALSE;
-      NABoolean res = createSQLLiteral((const char *) bufPtr, *stringLiteral, isNull, h);
-      assert(res);
-    }
-} // maxRepresentableValue()
+  minMaxRepresentableValue(bufPtr, bufLen, stringLiteral, TRUE, h);
+}
 
 //LCOV_EXCL_START : cnu -- As of 8/30/2011, needed to link successfully, but not actually called.
 double SQLVarChar::encode (void *bufPtr) const

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/common/CharType.h
----------------------------------------------------------------------
diff --git a/core/sql/common/CharType.h b/core/sql/common/CharType.h
index 898eb90..e8c0e9e 100644
--- a/core/sql/common/CharType.h
+++ b/core/sql/common/CharType.h
@@ -339,6 +339,13 @@ virtual NABoolean createSQLLiteral(const char * buf,
                                    NABoolean &isNull,
                                    CollHeap *h) const;
 
+protected:
+void minMaxRepresentableValue(void* bufPtr,
+                              Lng32* bufLen,
+                              NAString ** stringLiteral,
+                              NABoolean isMax,
+                              CollHeap* h) const;
+
 private:
 
 void NONVIRT_METHOD_PLACEHOLDER_1();	// slot for reuse, or delete it!##

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/common/ComSmallDefs.h
----------------------------------------------------------------------
diff --git a/core/sql/common/ComSmallDefs.h b/core/sql/common/ComSmallDefs.h
index 203d31d..a4d8522 100644
--- a/core/sql/common/ComSmallDefs.h
+++ b/core/sql/common/ComSmallDefs.h
@@ -615,13 +615,16 @@ enum ComParamDefaultClass { COM_CURRENT_PARAM_DEFAULT        = COM_CURRENT_DEFAU
 #define COM_ALWAYS_COMPUTE_COMPUTED_PARAM_DEFAULT_LIT "AC"
 #define COM_ALWAYS_DEFAULT_COMPUTED_PARAM_DEFAULT_LIT "AD"
 
-// represent the kind of string value stored in TEXT table
+// Represents the kind of string value stored in TEXT table.  Note
+// that changing existing values will require an UPGRADE of the
+// metadata.
 enum ComTextType {COM_VIEW_TEXT = 0,
                   COM_CHECK_CONSTR_TEXT = 1,
                   COM_HBASE_OPTIONS_TEXT = 2,
                   COM_TABLE_COMMENT_TEXT = 3,
                   COM_COMPUTED_COL_TEXT = 4,
-                  COM_HBASE_COL_FAMILY_TEXT = 5
+                  COM_HBASE_COL_FAMILY_TEXT = 5,
+                  COM_HBASE_SPLIT_TEXT = 6
 };
 
 enum ComColumnDirection { COM_UNKNOWN_DIRECTION

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/common/IntervalType.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/IntervalType.cpp b/core/sql/common/IntervalType.cpp
index 8524182..e6b8250 100644
--- a/core/sql/common/IntervalType.cpp
+++ b/core/sql/common/IntervalType.cpp
@@ -619,7 +619,7 @@ NABoolean IntervalType::createSQLLiteral(const char * buf,
              getNominalSize(),
              getFSDatatype(),
              getPrecision(),
-             getScale(),
+             getFractionPrecision(),
              numVal,
              NUMVAL_LEN,
              REC_BYTE_V_ASCII,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/common/NAType.h
----------------------------------------------------------------------
diff --git a/core/sql/common/NAType.h b/core/sql/common/NAType.h
index ddf6fca..ea4c64d 100644
--- a/core/sql/common/NAType.h
+++ b/core/sql/common/NAType.h
@@ -322,6 +322,13 @@ public:
   virtual void maxRepresentableValue(void*, Lng32*,
 				     NAString ** stringLiteral = NULL,
 				     CollHeap * h=0) const;
+  inline void minMaxRepresentableValue(void* buf,
+                                       Lng32* bufLen,
+                                       NABoolean isMax,
+                                       NAString ** stringLiteral = NULL,
+                                       CollHeap * h=0) const
+  { if (isMax) maxRepresentableValue(buf, bufLen, stringLiteral, h);
+    else       minRepresentableValue(buf, bufLen, stringLiteral, h); }
 
   virtual double getMinValue() const { return 0; };
   virtual double getMaxValue() const { return 0; };

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/common/csconvert.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/csconvert.cpp b/core/sql/common/csconvert.cpp
index e818e12..ffc5370 100644
--- a/core/sql/common/csconvert.cpp
+++ b/core/sql/common/csconvert.cpp
@@ -1181,6 +1181,27 @@ int lightValidateUTF8StrAndPad(char *bufr,
 }
 #endif /* Not currently called anywhere.*/
 
+int fillWithMinUTF8Chars(char *bufr,
+                         int in_len,
+                         int max_chars)
+{
+  int i;
+
+  if (max_chars <= 0)
+    max_chars = in_len;
+
+  // fill with minimum characters (NUL), up to the
+  // limit of characters
+  memset(bufr, 0, max_chars);
+
+  // fill up the remainder with blanks, which is the
+  // convention for UTF-8 strings with a character limit
+  if (in_len > max_chars)
+    memset(&bufr[max_chars], ' ', in_len-max_chars);
+
+  return max_chars;
+}
+
 int fillWithMaxUTF8Chars(char *bufr,
                          int in_len,
                          int max_chars)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/common/csconvert.h
----------------------------------------------------------------------
diff --git a/core/sql/common/csconvert.h b/core/sql/common/csconvert.h
index ae42698..56c9603 100644
--- a/core/sql/common/csconvert.h
+++ b/core/sql/common/csconvert.h
@@ -258,15 +258,25 @@ int lightValidateUTF8StrAndPad(char *bufr,
                                int max_chars = 0,
                                int ignore_trailing_blanks = 1);
 
-/* A method to create the maximum valid UTF-8 character
-   string that fits into a given buffer. Used to form high keys.
+/* A method to create the minimum/maximum valid UTF-8 character
+   string that fits into a given buffer. Used to form low/high keys.
    If max_chars is > 0, generates at most max_chars and pads
    the remaining bytes with blanks. Returns the space occupied
    by actual characters, not padding (same as in_len if max_chars == 0).
 */
+int fillWithMinUTF8Chars(char *bufr,
+                         int in_len, // in bytes
+                         int max_chars);
 int fillWithMaxUTF8Chars(char *bufr,
                          int in_len, // in bytes
                          int max_chars);
+inline int fillWithMinMaxUTF8Chars(char *bufr,
+                                   int in_len, // in bytes
+                                   int max_chars,
+                                   int is_max)
+{ if (is_max) return fillWithMaxUTF8Chars(bufr, in_len, max_chars);
+  else        return fillWithMinUTF8Chars(bufr, in_len, max_chars); }
+                                   
 
 /* A method to find the beginning of a UTF8 char that is at the end off
    a buffer.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/optimizer/BindItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindItemExpr.cpp b/core/sql/optimizer/BindItemExpr.cpp
index 32a0edf..6bdf67c 100644
--- a/core/sql/optimizer/BindItemExpr.cpp
+++ b/core/sql/optimizer/BindItemExpr.cpp
@@ -10298,23 +10298,23 @@ NABoolean ZZZBinderFunction::isPadWithSpace (ExprValueId& padExpr, CharInfo::Cha
   if ((padExpr->castToItemExpr()->getOperatorType() == ITM_CONSTANT) &&
       (!((ConstValue *)padExpr->castToItemExpr())->getText().isNull()))
   {
-     NAWString padString(
-       ((ConstValue *)padExpr->castToItemExpr())->getConstWStr());
+     NAString padString(
+       ((ConstValue *)padExpr->castToItemExpr())->getConstStr(FALSE));
      Int32 i = 0;
      NABoolean foundSingleQuote = FALSE;
-     for (const NAWchar *s = padString.data(); *s; s++)
+     for (const char *s = padString.data(); *s; s++)
      {
-       i++;  // 0x0027 is the single quote character '
-       if ((!foundSingleQuote)&&(*s != 0x0027)) // loop through 
+       i++;  // 0x27 is the single quote character '
+       if ((!foundSingleQuote)&&(*s != 0x27)) // loop through 
          continue;  // the prefix _UCS2 or _ISO88591
        else if ((!foundSingleQuote))
        {
         foundSingleQuote = TRUE; // found the leading single quote.
         continue;
        }
-       if ((i == (padString.length())) && (*s == 0x0027)) // trailing single quote
+       if ((i == (padString.length())) && (*s == 0x27)) // trailing single quote
          continue;
-       if (*s != 0x0020) // 0x0020 is the single space character ' '
+       if (*s != 0x20) // 0x20 is the single space character ' '
          return FALSE;
      }
      return foundSingleQuote;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/optimizer/EncodedKeyValue.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/EncodedKeyValue.cpp b/core/sql/optimizer/EncodedKeyValue.cpp
index b98659e..5216e0f 100644
--- a/core/sql/optimizer/EncodedKeyValue.cpp
+++ b/core/sql/optimizer/EncodedKeyValue.cpp
@@ -390,6 +390,7 @@ short encodeKeyValues(desc_struct   * column_descs,
 
   atp_struct * workAtp = keyEncodeExpr->getWorkAtp();
   workAtp->getTupp(keyAtpIndex).setDataPointer(encodedKeyBuffer);
+  workAtp->setDiagsArea(diagsArea);
   
   if (keyEncodeExpr->getExpr()->eval(workAtp, 0, space) == ex_expr::EXPR_ERROR)
     error = -1;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/optimizer/ItemCache.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemCache.cpp b/core/sql/optimizer/ItemCache.cpp
index 80426bc..9bdd830 100644
--- a/core/sql/optimizer/ItemCache.cpp
+++ b/core/sql/optimizer/ItemCache.cpp
@@ -645,7 +645,6 @@ Lng32 ConstValue::getSize() const
 {
   return (Lng32)(sizeof(*this) + getStorageSize() + 
     (text_ ? text_->length() : 0) +
-    (wtext_ ? wtext_->length() : 0) + 
     (locale_strval ? locale_strval->length() : 0) +
     (locale_wstrval ? locale_wstrval->length() : 0));
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/optimizer/ItemColRef.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemColRef.h b/core/sql/optimizer/ItemColRef.h
index e4d3ddd..0382f1a 100644
--- a/core/sql/optimizer/ItemColRef.h
+++ b/core/sql/optimizer/ItemColRef.h
@@ -448,9 +448,6 @@ public:
   // has been transformed (i.e., all \0 chars become "\0").
   NAString getConstStr(NABoolean transformNeeded = TRUE) const;
     
-  NAWString getConstWStr();
-  // returns the Unicode-encoded string form of column default values
-    
   short isNull() const			 { return isNull_ ? -1 : 0; }
   NABoolean isNullWasDefaultSpec() const { return isNull_==IS_NULL_WAS_DEFAULT;}
   void setWasDefaultSpec()		 { if (isNull_)
@@ -598,9 +595,6 @@ private:
             enum CharInfo::CharSet strLitPrefixCharSet = CharInfo::UnknownCharSet
          );
 
-   void init_wtext_field(enum CharInfo::CharSet strLitPrefixCharSet
-                         = CharInfo::UnknownCharSet);
-
 private:
 
   // this indicates whether the constant is a NULL constant
@@ -626,10 +620,6 @@ private:
   // code that doesn't always store valid literals.
   NABoolean textIsValidatedSQLLiteralInUTF8_;
 
-  // wtext_ is used to hold and return (via getConstWStr())
-  // a column default's string value.
-  NAWString *wtext_;  
-
   NABoolean rebindNeeded_; // TRUE if the string const value is originally
                            // set with an unknown charset value.
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index cf2c477..8cb182f 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -2289,6 +2289,10 @@ void ItemExpr::computeKwdAndFlags( NAString &kwd,
     else
       kwd = getText();
   }
+  else if (operatorType == ITM_NAMED_TYPE_TO_ITEM)
+  {
+    kwd = ToAnsiIdentifier(((NamedTypeToItem *)this)->getText());
+  }
   else if (( operatorType == ITM_CACHE_PARAM) &&
            (form == QUERY_FORMAT) )
     ((ConstantParameter *)this)->getConstVal()->unparse(kwd, phase, QUERY_FORMAT, tabId);
@@ -9737,7 +9741,7 @@ ConstValue::ConstValue()
      , storageSize_(0)
      , text_(new (CmpCommon::statementHeap()) NAString("NULL", CmpCommon::statementHeap()))
      , textIsValidatedSQLLiteralInUTF8_(FALSE)
-     , wtext_(0), isSystemSupplied_(FALSE)
+     , isSystemSupplied_(FALSE)
      , locale_strval(0)
      , locale_wstrval(0)
      , isStrLitWithCharSetPrefix_(FALSE)
@@ -9751,7 +9755,6 @@ ConstValue::ConstValue(Lng32 intval, NAMemory * outHeap)
            : ItemExpr(ITM_CONSTANT)
            , isNull_(IS_NOT_NULL)
            , textIsValidatedSQLLiteralInUTF8_(FALSE)
-           , wtext_(0)
            , type_(new (CmpCommon::statementHeap()) SQLInt(TRUE, FALSE))
 	   , isSystemSupplied_(FALSE)
            , locale_strval(0)
@@ -9778,7 +9781,7 @@ ConstValue::ConstValue(const NAString & strval,
              enum CharInfo::Collation collation,
              enum CharInfo::Coercibility coercibility,
              NAMemory * outHeap)
-: ItemExpr(ITM_CONSTANT), isNull_(IS_NOT_NULL), wtext_(0),
+: ItemExpr(ITM_CONSTANT), isNull_(IS_NOT_NULL),
   textIsValidatedSQLLiteralInUTF8_(FALSE), isStrLitWithCharSetPrefix_(FALSE),
   isSystemSupplied_(FALSE), locale_wstrval(0), rebindNeeded_(FALSE)
 {
@@ -9876,7 +9879,6 @@ ConstValue::ConstValue(const NAWString& wstrval,
    isSystemSupplied_(FALSE),
    value_(0),
    text_(0),
-   wtext_(0),
    locale_strval(0),
    locale_wstrval(0),
    isStrLitWithCharSetPrefix_(FALSE),
@@ -9951,8 +9953,6 @@ void ConstValue::initCharConstValue(const NAWString& strval,
 	    NAString((char*)strval.data(), storageSize_,
 	     outHeap);
   textIsValidatedSQLLiteralInUTF8_ = FALSE;
-
-  init_wtext_field(strLitPrefixCharSet);
 }
 
 
@@ -9964,7 +9964,6 @@ ConstValue::ConstValue(NAString strval, NAWString wstrval,
    value_(0),
    text_(0),
    textIsValidatedSQLLiteralInUTF8_(FALSE),
-   wtext_(0),
    isSystemSupplied_(FALSE),
    isStrLitWithCharSetPrefix_(FALSE),
    rebindNeeded_(FALSE)
@@ -10066,7 +10065,6 @@ ConstValue::ConstValue(const NAType * type, void * value, Lng32 value_len,
   : ItemExpr(ITM_CONSTANT)
   , isNull_(IS_NOT_NULL)
   , type_(type)
-  , wtext_(0)
   , isSystemSupplied_(FALSE)
   , locale_strval(0)
   , locale_wstrval(0)
@@ -10128,7 +10126,6 @@ ConstValue::ConstValue(const NAType * type, void * value, Lng32 value_len,
   : ItemExpr(ITM_CONSTANT)
   , isNull_(isNull)
   , type_(type)
-  , wtext_(0)
   , isSystemSupplied_(FALSE)
   , locale_strval(0)
   , locale_wstrval(0)
@@ -10176,7 +10173,6 @@ ConstValue::ConstValue(const NAType * type,
 		       const NABoolean includeNull,
                        NAMemory * outHeap)
 : ItemExpr(ITM_CONSTANT)
-, wtext_(0)
 , isNull_(IsNullEnum(type->supportsSQLnull() && includeNull && !wantMinValue))
 , type_(type)
 , isSystemSupplied_(FALSE)
@@ -10267,7 +10263,7 @@ ConstValue::ConstValue(OperatorTypeEnum otype,
 
 ConstValue::ConstValue(const ConstValue& s, NAHeap *h)
   : ItemExpr(ITM_CONSTANT), isNull_(s.isNull_), type_(s.type_)
-  , storageSize_(s.storageSize_), wtext_(s.wtext_)
+  , storageSize_(s.storageSize_)
   , textIsValidatedSQLLiteralInUTF8_(s.textIsValidatedSQLLiteralInUTF8_)
   , isSystemSupplied_(s.isSystemSupplied_)
   , isStrLitWithCharSetPrefix_(s.isStrLitWithCharSetPrefix_)
@@ -10284,7 +10280,7 @@ ConstValue::ConstValue(const ConstValue& s, NAHeap *h)
 
 ConstValue::ConstValue(const ConstValue& s)
   : ItemExpr(ITM_CONSTANT), isNull_(s.isNull_), type_(s.type_)
-  , storageSize_(s.storageSize_), wtext_(s.wtext_), value_(s.value_)
+  , storageSize_(s.storageSize_), value_(s.value_)
   , textIsValidatedSQLLiteralInUTF8_(s.textIsValidatedSQLLiteralInUTF8_)
   , text_(s.text_), isSystemSupplied_(s.isSystemSupplied_)
   , isStrLitWithCharSetPrefix_(s.isStrLitWithCharSetPrefix_)
@@ -10302,9 +10298,6 @@ ConstValue::~ConstValue()
 
   if (text_)
     NADELETEBASIC((NAString*)text_,CmpCommon::statementHeap());
-
-  if (wtext_)
-    NADELETEBASIC((NAWString*)wtext_,CmpCommon::statementHeap());
 }
 
 NABoolean ConstValue::isAUserSuppliedInput() const    { return TRUE; }
@@ -10494,16 +10487,12 @@ NAString ConstValue::getConstStr(NABoolean transformeNeeded) const
   {
     CharType* chType = (CharType*)getType();
 
-     // 4/8/96: added the Boolean switch so that displayable
-     // and non-displayable version can be differed.
-    if ( transformeNeeded ) {
+    // 4/8/96: added the Boolean switch so that displayable
+    // and non-displayable version can be differed.
+    if ( transformeNeeded )
       return chType->getCharSetAsPrefix() + getText();
-    }
-    else {
-      NAString str(CmpCommon::statementHeap());
-      ToQuotedString(str, *text_);
-      return chType->getCharSetAsPrefix() + str;
-    }
+    else
+      return chType->getCharSetAsPrefix() + getTextForQuery(QUERY_FORMAT);
   }
   else
   {
@@ -10511,76 +10500,6 @@ NAString ConstValue::getConstStr(NABoolean transformeNeeded) const
   }
 }
 
-NAWString ConstValue::getConstWStr()
-{
-  if (wtext_ == NULL)
-    init_wtext_field();
-
-  return *wtext_;
-}
-
-void ConstValue::init_wtext_field(enum CharInfo::CharSet strLitPrefixCharSet)
-{
-  NAMemory *heap = CmpCommon::statementHeap();
-
-  if (getType()->getTypeQualifier() == NA_CHARACTER_TYPE)
-    {
-      CharType* chType = (CharType*)getType();
-      enum CharInfo::CharSet charset = chType->getCharSet();
-      switch (charset)
-        {
-        case CharInfo::ISO88591:
-        case CharInfo::UTF8:
-        // case CharInfo::SJIS: // Uncomment if we ever support SJIS
-          {
-            NAWcharBuf *wBuf = NULL;
-            NAString str(getConstStr(FALSE), heap);
-
-#pragma nowarn(1506)   // warning elimination
-            charBuf cBuf((unsigned char*)str.data(), str.length(), heap);
-#pragma warn(1506)  // warning elimination
-            Int32 ErrCod = 0;
-            wBuf = csetToUnicode(cBuf, heap, wBuf, charset, ErrCod);
-            if (wBuf)
-              {
-                wtext_ = new (heap)
-                  NAWString(wBuf->data(), wBuf->getStrLen(), heap);
-                NADELETE(wBuf, NAWcharBuf, heap);
-              }
-            break;
-          }
-        case CharInfo::UNICODE:
-          {
-            NAWString wt((NAWchar*)text_->data(), (text_->length() / BYTES_PER_NAWCHAR));
-            NAWString wstr = wt.ToQuotedWString();
-            if ( ( strLitPrefixCharSet == CharInfo::ISO88591 ) ||
-                 ( strLitPrefixCharSet == CharInfo::UTF8 )   )
-            {
-              wtext_ = new (heap)
-                NAWString(NAWString(CharInfo::ISO88591,
-                          (strLitPrefixCharSet == CharInfo::ISO88591)
-                           ? "_ISO88591" : "_UTF8" ) + wstr,
-                          heap);
-            }
-            else
-            {
-            wtext_ = new (heap)
-	      NAWString(
-	        NAWString(CharInfo::ISO88591, chType->getCharSetAsPrefix()) + wstr,
-                        heap);
-            }
-            break;
-          }
-        }
-    }
-  else
-    {
-      wtext_ = new (heap) NAWString(CharInfo::ISO88591, getConstStr().data(), heap);
-    }
-
-  if (!wtext_) wtext_ = new (heap) NAWString(WIDE_(""), heap);
-}
-
 // Genesis 10-980402-1556 (see Binder)
 ConstValue * ConstValue::toUpper(CollHeap *h)
 {
@@ -10813,7 +10732,6 @@ NABoolean ConstValue::isEmptyString() const
 {
   if (getType()->getTypeQualifier() == NA_CHARACTER_TYPE) {
     if (text_ && text_->length() == 0) { return TRUE; }
-    if (wtext_ && wtext_->length() == 0) { return TRUE; }
   }
   return FALSE;
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index 81ebed1..f1b5de6 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -1452,6 +1452,9 @@ static ItemExpr * getRangePartitionBoundaryValuesFromEncodedKeys(
       // need to extend the partial buffer, allocate a copy
       actEncodedKey = new(heap) char[totalKeyLength];
       memcpy(actEncodedKey, encodedKey, encodedKeyLen);
+
+      // extend the remainder with zeroes, assuming that this is what
+      // HBase does when deciding which region a row belongs to
       memset(&actEncodedKey[encodedKeyLen], 0, totalKeyLength-encodedKeyLen);
       Lng32 currOffset = lenOfFullyProvidedCols;
 
@@ -1459,11 +1462,14 @@ static ItemExpr * getRangePartitionBoundaryValuesFromEncodedKeys(
       // so that we can treat the buffer as fully encoded in the final loop below
       for (CollIndex j = numProvidedCols; j < partColArray.entries(); j++)
         {
-          const NAType *pkType = partColArray[j]->getType();
-          Lng32 nullHdrSize = pkType->getSQLnullHdrSize();
-          Lng32 colEncodedLength = nullHdrSize + pkType->getNominalSize();
-          NABoolean isDescending = (partColArray[j]->getClusteringKeyOrdering() == DESCENDING);
-
+          const NAType *pkType        = partColArray[j]->getType();
+          Lng32 nullHdrSize           = pkType->getSQLnullHdrSize();
+          int valOffset               = currOffset + nullHdrSize;
+          int valEncodedLength        = pkType->getNominalSize();
+          Lng32 colEncodedLength      = nullHdrSize + valEncodedLength;
+          NABoolean isDescending      = (partColArray[j]->getClusteringKeyOrdering() == DESCENDING);
+
+          NABoolean nullHdrAlreadySet = FALSE;
           NABoolean columnIsPartiallyProvided = (currOffset < encodedKeyLen);
 
           if (columnIsPartiallyProvided)
@@ -1472,58 +1478,161 @@ static ItemExpr * getRangePartitionBoundaryValuesFromEncodedKeys(
               // value. Note that the buffer has a prefix of some bytes with actual key
               // values, followed by bytes that are zeroed out. 
 
+              // the number of bytes actually provided in the key (not filled in)
+              int numBytesInProvidedVal = encodedKeyLen-valOffset;
+
+              if (nullHdrSize && numBytesInProvidedVal <= 0)
+                {
+                  // only the null-header or a part thereof was provided
+                  CMPASSERT(nullHdrSize == sizeof(short));
+
+                  // get the partial indicator values into a short
+                  short indicatorVal = *reinterpret_cast<short *>(&actEncodedKey[currOffset]);
+
+                  // make it either 0 or -1
+                  if (indicatorVal)
+                    indicatorVal = -1;
 
-              // First, for descending columns, use 0xFF instead of 0 for fillers
-              if (isDescending)
-                memset(&actEncodedKey[encodedKeyLen],
-                       0xFF,
-                       currOffset + colEncodedLength - encodedKeyLen);
+                  // put it back and let the code below know that we set it already
+                  // (this is handled otherwise as a non-provided column)
+                  memcpy(&actEncodedKey[currOffset], &indicatorVal, sizeof(indicatorVal));
+                  nullHdrAlreadySet = TRUE;
+                  columnIsPartiallyProvided = FALSE;
+                }
 
               // Next, decide by data type whether it's ok for the type to have
-              // a suffix of the buffer zeroed out (even descending columns will
-              // in the end see zeroes). If the type can't take it, we'll just
-              // discard all the partial information.
+              // a suffix of the buffer zeroed out (descending columns will
+              // see 0xFF values, once the encoded value gets inverted). If the
+              // type can't take it or we are not quite sure, we'll just discard
+              // all the partial information. Note that this could potentially
+              // lead to two partition boundaries with the same key, and also
+              // to partition boundaries that don't reflect the actual region
+              // boundaries.
 
-              switch (pkType->getTypeQualifier())
-                {
-                case NA_NUMERIC_TYPE:
+              if (columnIsPartiallyProvided)
+                switch (pkType->getTypeQualifier())
                   {
-                    NumericType *nt = (NumericType *) pkType;
+                  case NA_NUMERIC_TYPE:
+                    {
+                      NumericType *nt = (NumericType *) pkType;
+
+                      if (!nt->isExact() || nt->isDecimal() || nt->isBigNum() ||
+                          (isDescending && nt->decimalPrecision()))
+                        // we may be able to improve this in the future
+                        columnIsPartiallyProvided = FALSE;
+                    }
+                    break;
 
-                    if (!nt->isExact() || nt->isDecimal() || nt->isBigNum())
+                  case NA_DATETIME_TYPE:
+                  case NA_INTERVAL_TYPE:
+                    // those types should tolerate zeroing out trailing bytes, but
+                    // not filling with 0xFF 
+                    if (isDescending)
                       columnIsPartiallyProvided = FALSE;
-                  }
-                  break;
+                    break;
 
-                case NA_DATETIME_TYPE:
-                case NA_INTERVAL_TYPE:
-                  // those types should tolerate zeroing out trailing bytes
-                  break;
+                  case NA_CHARACTER_TYPE:
+                    // generally, character types should also tolerate zeroing out
+                    // trailing bytes, but we might need to clean up characters
+                    // that got split in the middle
+                    {
+                      CharInfo::CharSet cs = pkType->getCharSet();
+
+                      switch (cs)
+                        {
+                        case CharInfo::UCS2:
+                          // For now just accept partial characters, it's probably ok
+                          // since they are just used as a key. May look funny in EXPLAIN.
+                          break;
+                        case CharInfo::UTF8:
+                          {
+                            // temporarily invert the provided key so it is actual UTF8
+                            if (isDescending)
+                              for (int i=0; i<numBytesInProvidedVal; i++)
+                                actEncodedKey[valOffset+i] = ~actEncodedKey[valOffset+i];
+
+                            CMPASSERT(numBytesInProvidedVal > 0);
+
+                            // remove a trailing partial character, if needed
+                            int validLen = lightValidateUTF8Str(&actEncodedKey[valOffset],
+                                                                numBytesInProvidedVal);
+
+                            // replace the remainder of the buffer with UTF8 min/max chars
+                            fillWithMinMaxUTF8Chars(&actEncodedKey[valOffset+validLen],
+                                                    valEncodedLength - validLen,
+                                                    0,
+                                                    isDescending);
+
+                            // limit to the max # of UTF-8characters, if needed
+                            if (pkType->getPrecisionOrMaxNumChars() > 0)
+                              {
+                                // this time validate the # of chars (likely to be more,
+                                // since we filled to the end with non-blanks)
+                                validLen = lightValidateUTF8Str(&actEncodedKey[valOffset],
+                                                                valEncodedLength,
+                                                                pkType->getPrecisionOrMaxNumChars());
+
+                                if (validLen > 0)
+                                  // space after valid #chars is filled with blanks
+                                  memset(&actEncodedKey[valOffset+validLen], ' ', valEncodedLength-validLen);
+                                else
+                                  columnIsPartiallyProvided = FALSE;
+                              }
+
+                            // undo the inversion, if needed, now for the whole key
+                            if (isDescending)
+                              for (int k=0; k<valEncodedLength; k++)
+                                actEncodedKey[valOffset+k] = ~actEncodedKey[valOffset+k];
+                          }
+                          break;
+                        case CharInfo::ISO88591:
+                          // filling with 0x00 or oxFF should both be ok
+                          break;
+
+                        default:
+                          // don't accept partial keys for other charsets
+                          columnIsPartiallyProvided = FALSE;
+                          break;
+                        }
+                    }
+                    break;
 
-                case NA_CHARACTER_TYPE:
-                  // generally, character types should also tolerate zeroing out
-                  // trailing bytes, but we might need to clean up characters
-                  // that got split in the middle
-                  {
-                    CharInfo::CharSet cs = pkType->getCharSet();
-
-                    switch (cs)
-                      {
-                      case CharInfo::UCS2:
-                      case CharInfo::UTF8:
-                        // For now just accept partial characters, it's probably ok
-                        // since they are just used as a key. May look funny in EXPLAIN.
-                        break;
-
-                      default:
-                        break;
-                      }
+                  default:
+                    // don't accept partial keys for any other data types
+                    columnIsPartiallyProvided = FALSE;
+                    break;
                   }
-                  break;
 
-                default:
-                  columnIsPartiallyProvided = FALSE;
-                  break;
+              if (columnIsPartiallyProvided)
+                {
+                  // a CQD can suppress, give errors, warnings or enable partially provided cols
+                  DefaultToken tok = CmpCommon::getDefault(HBASE_RANGE_PARTITIONING_PARTIAL_COLS);
+
+                  switch (tok)
+                    {
+                    case DF_OFF:
+                      // disable use of partial columns
+                      // (use this as a workaround if they cause problems)
+                      columnIsPartiallyProvided = FALSE;
+                      break;
+
+                    case DF_MINIMUM:
+                      // give an error (again, this is probably mostly used as a
+                      // workaround or to detect past problems)
+                      *CmpCommon::diags() << DgSqlCode(-1212) << DgInt0(j);
+                      break;
+
+                    case DF_MEDIUM:
+                      // give a warning, could be used for searching or testing
+                      *CmpCommon::diags() << DgSqlCode(+1212) << DgInt0(j);
+                      break;
+
+                    case DF_ON:
+                    case DF_MAXIMUM:
+                    default:
+                      // allow it, no warning or error
+                      break;
+                    }
                 }
 
               if (columnIsPartiallyProvided)
@@ -1539,9 +1648,9 @@ static ItemExpr * getRangePartitionBoundaryValuesFromEncodedKeys(
               // NOTE: This is generating un-encoded values, unlike
               //       the values we get from HBase. The next loop below
               //       will skip decoding for any values generated here.
-              Lng32 remainingBufLen = colEncodedLength - nullHdrSize;
+              Lng32 remainingBufLen = valEncodedLength;
 
-              if (nullHdrSize)
+              if (nullHdrSize && !nullHdrAlreadySet)
                 {
                   // generate a NULL indicator
                   // NULL (-1) for descending columns, this is the max value
@@ -1552,20 +1661,11 @@ static ItemExpr * getRangePartitionBoundaryValuesFromEncodedKeys(
                   memcpy(&actEncodedKey[currOffset], &indicatorVal, sizeof(indicatorVal));
                 }
 
-              if (isDescending)
-                {
-                  pkType->maxRepresentableValue(&actEncodedKey[currOffset + nullHdrSize],
-                                                &remainingBufLen,
-                                                NULL,
-                                                heap);
-                }
-              else
-                {
-                  pkType->minRepresentableValue(&actEncodedKey[currOffset + nullHdrSize],
-                                                &remainingBufLen,
-                                                NULL,
-                                                heap);
-                }
+              pkType->minMaxRepresentableValue(&actEncodedKey[valOffset],
+                                               &remainingBufLen,
+                                               isDescending,
+                                               NULL,
+                                               heap);
             }
 
           currOffset += colEncodedLength;
@@ -1628,11 +1728,12 @@ static ItemExpr * getRangePartitionBoundaryValuesFromEncodedKeys(
           }
 
           // un-encode the key value by using an expression
+          NAString encConstLiteral("encoded_val");
           ConstValue *keyColEncVal =
             new (heap) ConstValue(pkType,
                                   (void *) encodedKeyP,
                                   decodedValueLen,
-                                  NULL,
+                                  &encConstLiteral,
                                   heap);
           CMPASSERT(keyColEncVal);
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/optimizer/NATable.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.h b/core/sql/optimizer/NATable.h
index 76fd913..4eb3c23 100644
--- a/core/sql/optimizer/NATable.h
+++ b/core/sql/optimizer/NATable.h
@@ -777,7 +777,6 @@ public:
   NABoolean insertMissingStatsWarning(CollIndexSet colsSet) const;
 
   const desc_struct * getTableDesc() const { return tableDesc_; }
-  Lng32 numSaltPartns() { return clusteringIndex_->numSaltPartns(); }
   NAList<HbaseCreateOption*> * hbaseCreateOptions()
     { return clusteringIndex_->hbaseCreateOptions();}
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/optimizer/QRDescGenerator.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/QRDescGenerator.cpp b/core/sql/optimizer/QRDescGenerator.cpp
index c53b18f..2a412a3 100644
--- a/core/sql/optimizer/QRDescGenerator.cpp
+++ b/core/sql/optimizer/QRDescGenerator.cpp
@@ -764,9 +764,7 @@ QRExplicitExprPtr QRDescGenerator::getExprTree(ItemExpr* itemExpr)
                                        QRDescriptorException,
                                        "Unhandled bytes-per-char: %d",
                                        ((CharType*)type)->getBytesPerChar());
-                    QRWStringValPtr wideScalar = new (mvqrHeap_) QRWStringVal(ADD_MEMCHECK_ARGS(mvqrHeap_));
-                    wideScalar->setWideValue(constVal->getConstWStr());
-                    scalar = wideScalar;
+                    scalar->setValue(constVal->getConstStr(FALSE));
                     valueWasSet = TRUE;
                   }
                 break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/parser/ElemDDLNode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.cpp b/core/sql/parser/ElemDDLNode.cpp
index 2bdea29..c728b5a 100644
--- a/core/sql/parser/ElemDDLNode.cpp
+++ b/core/sql/parser/ElemDDLNode.cpp
@@ -2214,7 +2214,7 @@ ElemDDLKeyValue::getText() const
 // virtual
 NAString ElemDDLKeyValue::getSyntax() const
 {
-  return keyValue_->getConstStr();
+  return keyValue_->getConstStr(FALSE);
 
 
 } // getSyntax()

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/parser/StmtDDLCreate.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/StmtDDLCreate.cpp b/core/sql/parser/StmtDDLCreate.cpp
index 5c31d46..ee39303 100644
--- a/core/sql/parser/StmtDDLCreate.cpp
+++ b/core/sql/parser/StmtDDLCreate.cpp
@@ -5222,8 +5222,10 @@ StmtDDLCreateTable::setPartitions(ElemDDLPartitionClause * pPartitionClause)
     // "hash2 partitioning") and a partitioning count (e.g. 
     // "number of partitions 2")   But, if "no partitions" is specified 
     // (number of partitions 0) then we don't allow any other partn spec
-    *SqlParser_Diags << DgSqlCode(-3103);
+    *SqlParser_Diags << DgSqlCode(-3103)
+                     << DgString0("PARTITION");
   }
+
   isPartitionClauseSpec_ = TRUE;
 
   //
@@ -5570,7 +5572,8 @@ StmtDDLCreateTable::setTableOption(ElemDDLNode * pTableOption)
       // "hash2 partitioning") and a partitioning count (e.g. 
       // "number of partitions 2")   But, if "no partitions" is specified 
       // (number of partitions 0) then we don't allow any other partn spec
-      *SqlParser_Diags << DgSqlCode(-3103);
+      *SqlParser_Diags << DgSqlCode(-3103)
+                       << DgString0("PARTITION");
     }
 
     isPOSNumPartnsSpecified_ = TRUE;    
@@ -6669,7 +6672,8 @@ StmtDDLCreateMV::checkPartitionDefinitionclause(
   if (isPartitionDefinitionSpecified_ || isPartitionByClauseSpecified_)
   {
     // Duplicate PARTITION clauses.
-    *SqlParser_Diags << DgSqlCode(-3103);
+    *SqlParser_Diags << DgSqlCode(-3103)
+                     << DgString0("PARTITION");
   }
   isPartitionDefinitionSpecified_ = TRUE;
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/regress/charsets/DIFF002.KNOWN.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/charsets/DIFF002.KNOWN.SB b/core/sql/regress/charsets/DIFF002.KNOWN.SB
deleted file mode 100644
index 5481b53..0000000
--- a/core/sql/regress/charsets/DIFF002.KNOWN.SB
+++ /dev/null
@@ -1,14 +0,0 @@
-111c111,114
-< --- SQL operation complete.
----
-> *** ERROR[4222] The DDL feature is not supported in this software version.
-> 
-> *** ERROR[8822] The statement was not prepared.
-> 
-116c119,122
-< --- SQL operation complete.
----
-> *** ERROR[4222] The DDL feature is not supported in this software version.
-> 
-> *** ERROR[8822] The statement was not prepared.
-> 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/regress/charsets/DIFF002.KNOWN.SB.OS
----------------------------------------------------------------------
diff --git a/core/sql/regress/charsets/DIFF002.KNOWN.SB.OS b/core/sql/regress/charsets/DIFF002.KNOWN.SB.OS
deleted file mode 100644
index 5481b53..0000000
--- a/core/sql/regress/charsets/DIFF002.KNOWN.SB.OS
+++ /dev/null
@@ -1,14 +0,0 @@
-111c111,114
-< --- SQL operation complete.
----
-> *** ERROR[4222] The DDL feature is not supported in this software version.
-> 
-> *** ERROR[8822] The statement was not prepared.
-> 
-116c119,122
-< --- SQL operation complete.
----
-> *** ERROR[4222] The DDL feature is not supported in this software version.
-> 
-> *** ERROR[8822] The statement was not prepared.
-> 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/regress/charsets/EXPECTED002
----------------------------------------------------------------------
diff --git a/core/sql/regress/charsets/EXPECTED002 b/core/sql/regress/charsets/EXPECTED002
new file mode 100755
index 0000000..3d40878
--- /dev/null
+++ b/core/sql/regress/charsets/EXPECTED002
@@ -0,0 +1,260 @@
+>>
+>>--HEADING can only be character_string_literal without Phase I work
+>>create table t001 (c char(10) HEADING 'MYHEADING');
+
+--- SQL operation complete.
+>>create table t002 (c char(10) HEADING _ISO88591'MYISOHEADING');
+
+--- SQL operation complete.
+>>create table t003 (c char(10) default 'asdf');
+
+--- SQL operation complete.
+>>
+>>--default can be UCS2
+>>create table t004 (c char(10) character set UCS2 default _UCS2'adf');
+
+--- SQL operation complete.
+>>
+>>create table t005 (c char(10) check (c > 'aaaa'));
+
+--- SQL operation complete.
+>>create table t006 (c char(10), check (c > 'aaaa'));
+
+--- SQL operation complete.
+>>create table t007 (c char(10), constraint myc1 check (c > 'qwew'));
+
+--- SQL operation complete.
+>>
+>>--UNIQUE constraint can be specified on UCS2 columns
+>>create table t008 (c char(10) character set UCS2 NOT NULL, 
++>                   d char(10) character set UCS2 NOT NULL, 
++>                   primary key(c), 
++>                   constraint myc5 unique(c,d));
+
+--- SQL operation complete.
+>>
+>>--Referential Integrity on UCS2 colums
+>>create table t009 (x char(10) character set UCS2, y int NOT NULL NOT DROPPABLE,
++>		   primary key(y),
++>                   foreign key(x) references $$TEST_SCHEMA$$.t008(c));
+
+--- SQL operation complete.
+>>
+>>
+>>create table t010 (c char(10) character set UCS2);
+
+--- SQL operation complete.
+>>
+>>--view can be defined on a UCS2 column
+>>create view t010v2 as select c from t010;
+
+--- SQL operation complete.
+>>
+>>--index can be created on a UCS2 column
+>>create table t011(c char(10) character set UCS2, d char(10) character set UCS2);
+
+--- SQL operation complete.
+>>create index t011i1 on t011(c,d);
+
+--- SQL operation complete.
+>>
+>>--the COLLATION clause can be specified on the UCS2 or ISO88591 column
+>>--and DEFAULT/BINARY is the only allowed collation
+>>create table t012 (a char(10) character set ISO88591 COLLATE default,
++>                   b char(10) character set UCS2 COLLATE default);
+
+--- SQL operation complete.
+>>
+>>
+>>create table nt001 (c char(10) HEADING _UCS2'MYUCS2HEADING');
+
+--- SQL operation complete.
+>>create table nt002 (c char(10) character set UCS2 default _UCS2'default');
+
+--- SQL operation complete.
+>>
+>>--UCS2 strings are NOW allowed in a constraint
+>>create table nt003 (c char(10) character set UCS2 check (c > _UCS2'aaaa'));
+
+--- SQL operation complete.
+>>
+>>--UCS2 strings are NOW allowed in a constraint
+>>create table nt004 (c char(10) character set UCS2, check (c = _UCS2'aaaa'));
+
+--- SQL operation complete.
+>>
+>>--UCS2 strings are NOW allowed in a constraint
+>>create table nt005 (c char(10) character set UCS2, constraint myc2 check (c >
++>_UCS2'asdf'));
+
+--- SQL operation complete.
+>>
+>>--no UCS2 strings in a view text
+>>create view nt006v1 as select * from t013 where c > _UCS2'aaaa';
+
+*** ERROR[4082] Object CAT.SCH.T013 does not exist or is inaccessible.
+
+--- SQL operation failed with errors.
+>>
+>>--no UCS2 strings in a trigger text
+>>create table nt007 (d char(10) character set UCS2, i int);
+
+--- SQL operation complete.
+>>
+>>--ok
+>>create table nt008 (d char(10) character set UCS2, i int);
+
+--- SQL operation complete.
+>>create trigger t013t1 after insert on nt008
++>	update nt008 set i = 7 where i = 9;
+
+*** ERROR[4222] The DDL feature is not supported in this software version.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>--not ok
+>>create trigger t013t2 after insert on nt008
++>	update nt007 set d = _UCS2'qwer' where d = _UCS2'aaaa';
+
+*** ERROR[4222] The DDL feature is not supported in this software version.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>--no UCS2 strings in a FIRST KEY clause
+>>create table nt009 (c char(10) character set UCS2)
++>	location  $$partition$$
++>	partition (add first key (_UCS2'aaa') location  $$partition1$$);
+
+*** ERROR[1240] The character set for a PARTITION KEY column must be ISO88591.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>--INFER_CHARSET works for default values in CREATE TABLE DDL
+>>control query default infer_charset 'on';
+
+--- SQL operation complete.
+>>create table t013(a char(10) character set ucs2 default 'aa');
+
+--- SQL operation complete.
+>>create table t013a(a char(10));
+
+--- SQL operation complete.
+>>invoke t013;
+
+-- Definition of table CAT.SCH.T013
+-- Definition current  Fri Jul 23 16:05:50 2010
+
+  (
+    A                                CHAR(10) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT _UCS2'aa'
+  )
+
+--- SQL operation complete.
+>>
+>>-- test INFER_CHARSET fixes:
+>>-- test fix to genesis case 10-060317-2228
+>>select *,case when a is null then 'A' else 'B' end as test_fld from t013;
+
+--- 0 row(s) selected.
+>>-- select used to get error 4035
+>>
+>>-- test fix to genesis case 10-060315-0580
+>>select * from (values('A'),('B')) as t(c);
+
+C
+-
+
+A
+B
+
+--- 2 row(s) selected.
+>> -- used to get error 4035
+>>
+>>-- test fix to case 10-081022-6724 
+>>prepare xx from insert into t013 select 'a' from t013a;
+
+--- SQL command prepared.
+>>prepare xx from insert into t013 select 'a' from t013a group by 'a';
+
+--- SQL command prepared.
+>>prepare xx from insert into t013 select 'a'||'b' from t013a;
+
+*** ERROR[4039] Column A is of type CHAR(10) CHARACTER SET UCS2, incompatible with the value's type, CHAR(2) CHARACTER SET ISO88591.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>control query default infer_charset 'off';
+
+--- SQL operation complete.
+>>
+>>?section dml
+>>
+>>?section clnup
+>>drop table t001;
+
+--- SQL operation complete.
+>>drop table t002;
+
+--- SQL operation complete.
+>>drop table t003;
+
+--- SQL operation complete.
+>>drop table t004;
+
+--- SQL operation complete.
+>>drop table t005;
+
+--- SQL operation complete.
+>>drop table t006;
+
+--- SQL operation complete.
+>>drop table t007;
+
+--- SQL operation complete.
+>>drop table t008 cascade;
+
+--- SQL operation complete.
+>>drop table t009;
+
+--- SQL operation complete.
+>>drop table t010 cascade;
+
+--- SQL operation complete.
+>>drop table t011;
+
+--- SQL operation complete.
+>>drop table t012;
+
+--- SQL operation complete.
+>>drop table t013;
+
+--- SQL operation complete.
+>>drop table t013a;
+
+--- SQL operation complete.
+>>drop table nt001;
+
+--- SQL operation complete.
+>>drop table nt002;
+
+--- SQL operation complete.
+>>drop table nt003;
+
+--- SQL operation complete.
+>>drop table nt004;
+
+--- SQL operation complete.
+>>drop table nt005;
+
+--- SQL operation complete.
+>>drop table nt007 cascade;
+
+--- SQL operation complete.
+>>drop table nt008 cascade;
+
+--- SQL operation complete.
+>>
+>>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/regress/charsets/EXPECTED002.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/charsets/EXPECTED002.SB b/core/sql/regress/charsets/EXPECTED002.SB
deleted file mode 100755
index a897a3d..0000000
--- a/core/sql/regress/charsets/EXPECTED002.SB
+++ /dev/null
@@ -1,254 +0,0 @@
->>
->>--HEADING can only be character_string_literal without Phase I work
->>create table t001 (c char(10) HEADING 'MYHEADING');
-
---- SQL operation complete.
->>create table t002 (c char(10) HEADING _ISO88591'MYISOHEADING');
-
---- SQL operation complete.
->>create table t003 (c char(10) default 'asdf');
-
---- SQL operation complete.
->>
->>--default can be UCS2
->>create table t004 (c char(10) character set UCS2 default _UCS2'adf');
-
---- SQL operation complete.
->>
->>create table t005 (c char(10) check (c > 'aaaa'));
-
---- SQL operation complete.
->>create table t006 (c char(10), check (c > 'aaaa'));
-
---- SQL operation complete.
->>create table t007 (c char(10), constraint myc1 check (c > 'qwew'));
-
---- SQL operation complete.
->>
->>--UNIQUE constraint can be specified on UCS2 columns
->>create table t008 (c char(10) character set UCS2 NOT NULL, 
-+>                   d char(10) character set UCS2 NOT NULL, 
-+>                   primary key(c), 
-+>                   constraint myc5 unique(c,d));
-
---- SQL operation complete.
->>
->>--Referential Integrity on UCS2 colums
->>create table t009 (x char(10) character set UCS2, y int NOT NULL NOT DROPPABLE,
-+>		   primary key(y),
-+>                   foreign key(x) references $$TEST_SCHEMA$$.t008(c));
-
---- SQL operation complete.
->>
->>
->>create table t010 (c char(10) character set UCS2);
-
---- SQL operation complete.
->>
->>--view can be defined on a UCS2 column
->>create view t010v2 as select c from t010;
-
---- SQL operation complete.
->>
->>--index can be created on a UCS2 column
->>create table t011(c char(10) character set UCS2, d char(10) character set UCS2);
-
---- SQL operation complete.
->>create index t011i1 on t011(c,d);
-
---- SQL operation complete.
->>
->>--the COLLATION clause can be specified on the UCS2 or ISO88591 column
->>--and DEFAULT/BINARY is the only allowed collation
->>create table t012 (a char(10) character set ISO88591 COLLATE default,
-+>                   b char(10) character set UCS2 COLLATE default);
-
---- SQL operation complete.
->>
->>
->>create table nt001 (c char(10) HEADING _UCS2'MYUCS2HEADING');
-
---- SQL operation complete.
->>create table nt002 (c char(10) character set UCS2 default _UCS2'default');
-
---- SQL operation complete.
->>
->>--UCS2 strings are NOW allowed in a constraint
->>create table nt003 (c char(10) character set UCS2 check (c > _UCS2'aaaa'));
-
---- SQL operation complete.
->>
->>--UCS2 strings are NOW allowed in a constraint
->>create table nt004 (c char(10) character set UCS2, check (c = _UCS2'aaaa'));
-
---- SQL operation complete.
->>
->>--UCS2 strings are NOW allowed in a constraint
->>create table nt005 (c char(10) character set UCS2, constraint myc2 check (c >
-+>_UCS2'asdf'));
-
---- SQL operation complete.
->>
->>--no UCS2 strings in a view text
->>create view nt006v1 as select * from t013 where c > _UCS2'aaaa';
-
-*** ERROR[4082] Object CAT.SCH.T013 does not exist or is inaccessible.
-
---- SQL operation failed with errors.
->>
->>--no UCS2 strings in a trigger text
->>create table nt007 (d char(10) character set UCS2, i int);
-
---- SQL operation complete.
->>
->>--ok
->>create table nt008 (d char(10) character set UCS2, i int);
-
---- SQL operation complete.
->>create trigger t013t1 after insert on nt008
-+>	update nt008 set i = 7 where i = 9;
-
---- SQL operation complete.
->>--not ok
->>create trigger t013t2 after insert on nt008
-+>	update nt007 set d = _UCS2'qwer' where d = _UCS2'aaaa';
-
---- SQL operation complete.
->>
->>--no UCS2 strings in a FIRST KEY clause
->>create table nt009 (c char(10) character set UCS2)
-+>	location  $$partition$$
-+>	partition (add first key (_UCS2'aaa') location  $$partition1$$);
-
-*** ERROR[1240] The character set for a PARTITION KEY column must be ISO88591.
-
-*** ERROR[8822] The statement was not prepared.
-
->>
->>--INFER_CHARSET works for default values in CREATE TABLE DDL
->>control query default infer_charset 'on';
-
---- SQL operation complete.
->>create table t013(a char(10) character set ucs2 default 'aa');
-
---- SQL operation complete.
->>create table t013a(a char(10));
-
---- SQL operation complete.
->>invoke t013;
-
--- Definition of table CAT.SCH.T013
--- Definition current  Fri Jul 23 16:05:50 2010
-
-  (
-    A                                CHAR(10) CHARACTER SET UCS2 COLLATE
-      DEFAULT DEFAULT _UCS2'aa'
-  )
-
---- SQL operation complete.
->>
->>-- test INFER_CHARSET fixes:
->>-- test fix to genesis case 10-060317-2228
->>select *,case when a is null then 'A' else 'B' end as test_fld from t013;
-
---- 0 row(s) selected.
->>-- select used to get error 4035
->>
->>-- test fix to genesis case 10-060315-0580
->>select * from (values('A'),('B')) as t(c);
-
-C
--
-
-A
-B
-
---- 2 row(s) selected.
->> -- used to get error 4035
->>
->>-- test fix to case 10-081022-6724 
->>prepare xx from insert into t013 select 'a' from t013a;
-
---- SQL command prepared.
->>prepare xx from insert into t013 select 'a' from t013a group by 'a';
-
---- SQL command prepared.
->>prepare xx from insert into t013 select 'a'||'b' from t013a;
-
-*** ERROR[4039] Column A is of type CHAR(10) CHARACTER SET UCS2, incompatible with the value's type, CHAR(2) CHARACTER SET ISO88591.
-
-*** ERROR[8822] The statement was not prepared.
-
->>
->>control query default infer_charset 'off';
-
---- SQL operation complete.
->>
->>?section dml
->>
->>?section clnup
->>drop table t001;
-
---- SQL operation complete.
->>drop table t002;
-
---- SQL operation complete.
->>drop table t003;
-
---- SQL operation complete.
->>drop table t004;
-
---- SQL operation complete.
->>drop table t005;
-
---- SQL operation complete.
->>drop table t006;
-
---- SQL operation complete.
->>drop table t007;
-
---- SQL operation complete.
->>drop table t008 cascade;
-
---- SQL operation complete.
->>drop table t009;
-
---- SQL operation complete.
->>drop table t010 cascade;
-
---- SQL operation complete.
->>drop table t011;
-
---- SQL operation complete.
->>drop table t012;
-
---- SQL operation complete.
->>drop table t013;
-
---- SQL operation complete.
->>drop table t013a;
-
---- SQL operation complete.
->>drop table nt001;
-
---- SQL operation complete.
->>drop table nt002;
-
---- SQL operation complete.
->>drop table nt003;
-
---- SQL operation complete.
->>drop table nt004;
-
---- SQL operation complete.
->>drop table nt005;
-
---- SQL operation complete.
->>drop table nt007 cascade;
-
---- SQL operation complete.
->>drop table nt008 cascade;
-
---- SQL operation complete.
->>
->>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/regress/charsets/EXPECTED003
----------------------------------------------------------------------
diff --git a/core/sql/regress/charsets/EXPECTED003 b/core/sql/regress/charsets/EXPECTED003
new file mode 100755
index 0000000..af07866
--- /dev/null
+++ b/core/sql/regress/charsets/EXPECTED003
@@ -0,0 +1,217 @@
+>>
+>>--test the exposure of UCS2 and disabling of UNICODE 
+>>--as a character set name.
+>>
+>>--positive
+>>--Table columns can be created to be associated with character set UCS2.
+>>create table t002(c char(10) character set UCS2);
+
+--- SQL operation complete.
+>>
+>>--INVOKE and SHOWDDL work for tables with columns associated with UCS2.
+>>invoke t002;
+
+-- Definition of table CAT.SCH.T002
+-- Definition current  Fri Apr 23 14:40:12 2010
+
+  (
+    C                                CHAR(10) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  )
+
+--- SQL operation complete.
+>>showddl t002;
+
+CREATE TABLE CAT.SCH.T002
+  (
+    C                                CHAR(10) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  )
+;
+
+--- SQL operation complete.
+>>
+>>--negative
+>>--Table columns can not be created to be assocated with UNICODE.
+>>create table t003(c char(10) character set UNICODE);
+
+*** ERROR[15001] A syntax error occurred at or before: 
+create table t003(c char(10) character set UNICODE);
+                                                 ^ (50 characters from start of SQL statement)
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>
+>>?section dml
+>>
+>>--positive
+>>insert into t002 values(_ucs2'qwer');
+
+--- 1 row(s) inserted.
+>>update t002 set c = _UCS2'xxxx' where c = _UCS2'qwer';
+
+--- 1 row(s) updated.
+>>delete from t002 where c = _UCS2'asdf';
+
+--- 0 row(s) deleted.
+>>select _UCS2'ucs2', _ISO88591'iso88591', c from t002;
+
+(EXPR)    (EXPR)    C                   
+--------  --------  --------------------
+
+ucs2      iso88591  xxxx                
+
+--- 1 row(s) selected.
+>>
+>>--negative
+>>insert into t002 values(_UNICODE'asdf');
+
+*** ERROR[3127] An invalid character was found in identifier _UNICODE.
+
+*** ERROR[15001] A syntax error occurred at or before: 
+insert into t002 values(_UNICODE'asdf');
+                        ^ (25 characters from start of SQL statement)
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>--VARNCHAR disallowed
+>>create table t004(c varnchar(10));
+
+*** ERROR[15001] A syntax error occurred at or before: 
+create table t004(c varnchar(10));
+                           ^ (28 characters from start of SQL statement)
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>
+>>-------------------------------
+>>--test translation name changes
+>>-------------------------------
+>>
+>>create table t001(c char(10));
+
+--- SQL operation complete.
+>>insert into t001 values(x'4e');
+
+--- 1 row(s) inserted.
+>>
+>>?section dml
+>>--New valid name. Case insensitive
+>>select translate(_kanji'asdf' using KANJITOISO88591) from (values(1))x;
+
+*** ERROR[3010] Character set KANJI is not yet supported.
+
+*** ERROR[15001] A syntax error occurred at or before: 
+select translate(_kanji'asdf' using KANJITOISO88591) from (values(1))x;
+                      ^ (23 characters from start of SQL statement)
+
+*** ERROR[8822] The statement was not prepared.
+
+>>select translate(_ksc5601'1234' using KSC5601TOISO88591) from (values(1))x;
+
+*** ERROR[3010] Character set KSC5601 is not yet supported.
+
+*** ERROR[15001] A syntax error occurred at or before: 
+select translate(_ksc5601'1234' using KSC5601TOISO88591) from (values(1))x;
+                        ^ (25 characters from start of SQL statement)
+
+*** ERROR[8822] The statement was not prepared.
+
+>>select translate(_UCS2'asdf' using UCS2TOISO88591) from (values(1))x;
+
+(EXPR)
+------
+
+asdf  
+
+--- 1 row(s) selected.
+>>insert into t002 
++>  select translate(c using iso88591ToUCS2) from t001 
++>     where c = x'4e';
+
+--- 1 row(s) inserted.
+>>
+>>--old name not allowed
+>>insert into t001 values(translate(_UCS2'qwer' using UToL1));
+
+*** ERROR[4105] Translation name is not recognized.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>insert into t001 values(translate(_UCS2'ewrt' using UNICODE_TO_ISO88591));
+
+*** ERROR[4105] Translation name is not recognized.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>insert into t002 values(translate('asdf' using ISO88591TOUCS2));
+
+--- 1 row(s) inserted.
+>>insert into t002 values(translate('qwer' using L1ToU));
+
+*** ERROR[4105] Translation name is not recognized.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>insert into t002 values(translate('ewrt' using ISO88591_TO_UNICODE));
+
+*** ERROR[4105] Translation name is not recognized.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>-------------------------------
+>>--test TERMINAL_CHARSETS 
+>>-------------------------------
+>>
+>>set terminal_charset iso88591;
+>>
+>>-- the following should fail
+>>set terminal_charset iso88592;
+
+*** ERROR[15990] Character set name for SQLCI attribute TERMINAL_CHARSET is not valid.
+
+>>set terminal_charset ucs2;
+
+*** ERROR[2038] Character set ucs2 is not supported for SQLCI attribute TERMINAL_CHARSET.
+
+>>set terminal_charset sjis;
+>>set terminal_charset x0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
+
+*** ERROR[15990] Character set name for SQLCI attribute TERMINAL_CHARSET is not valid.
+
+>>
+>>-- the default is ucs2. this is a no-op.
+>>control query default national_charset 'ucs2';
+
+--- SQL operation complete.
+>>
+>>--test CQD NATIONAL_CHARSET (should fail)
+>>-------------------------------
+>>control query default national_charset 'ios88591';
+
+*** ERROR[4130] NATIONAL_CHARSET is a read-only DEFAULTS attribute and cannot be updated.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>-- an invalid sqlci command, exercise the single-byte version of StoreSyntaxError()
+>>bad_sqlci_cmd 1;
+
+*** ERROR[15001] A syntax error occurred at or before: 
+bad_sqlci_cmd 1;
+              ^ (15 characters from start of SQL statement)
+
+>>
+>>?section clnup
+>>drop table t001;
+
+--- SQL operation complete.
+>>drop table t002;
+
+--- SQL operation complete.
+>>
+>>log;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/1e60a9b8/core/sql/regress/charsets/EXPECTED003.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/charsets/EXPECTED003.SB b/core/sql/regress/charsets/EXPECTED003.SB
deleted file mode 100755
index af07866..0000000
--- a/core/sql/regress/charsets/EXPECTED003.SB
+++ /dev/null
@@ -1,217 +0,0 @@
->>
->>--test the exposure of UCS2 and disabling of UNICODE 
->>--as a character set name.
->>
->>--positive
->>--Table columns can be created to be associated with character set UCS2.
->>create table t002(c char(10) character set UCS2);
-
---- SQL operation complete.
->>
->>--INVOKE and SHOWDDL work for tables with columns associated with UCS2.
->>invoke t002;
-
--- Definition of table CAT.SCH.T002
--- Definition current  Fri Apr 23 14:40:12 2010
-
-  (
-    C                                CHAR(10) CHARACTER SET UCS2 COLLATE
-      DEFAULT DEFAULT NULL
-  )
-
---- SQL operation complete.
->>showddl t002;
-
-CREATE TABLE CAT.SCH.T002
-  (
-    C                                CHAR(10) CHARACTER SET UCS2 COLLATE
-      DEFAULT DEFAULT NULL
-  )
-;
-
---- SQL operation complete.
->>
->>--negative
->>--Table columns can not be created to be assocated with UNICODE.
->>create table t003(c char(10) character set UNICODE);
-
-*** ERROR[15001] A syntax error occurred at or before: 
-create table t003(c char(10) character set UNICODE);
-                                                 ^ (50 characters from start of SQL statement)
-
-*** ERROR[8822] The statement was not prepared.
-
->>
->>
->>?section dml
->>
->>--positive
->>insert into t002 values(_ucs2'qwer');
-
---- 1 row(s) inserted.
->>update t002 set c = _UCS2'xxxx' where c = _UCS2'qwer';
-
---- 1 row(s) updated.
->>delete from t002 where c = _UCS2'asdf';
-
---- 0 row(s) deleted.
->>select _UCS2'ucs2', _ISO88591'iso88591', c from t002;
-
-(EXPR)    (EXPR)    C                   
---------  --------  --------------------
-
-ucs2      iso88591  xxxx                
-
---- 1 row(s) selected.
->>
->>--negative
->>insert into t002 values(_UNICODE'asdf');
-
-*** ERROR[3127] An invalid character was found in identifier _UNICODE.
-
-*** ERROR[15001] A syntax error occurred at or before: 
-insert into t002 values(_UNICODE'asdf');
-                        ^ (25 characters from start of SQL statement)
-
-*** ERROR[8822] The statement was not prepared.
-
->>
->>--VARNCHAR disallowed
->>create table t004(c varnchar(10));
-
-*** ERROR[15001] A syntax error occurred at or before: 
-create table t004(c varnchar(10));
-                           ^ (28 characters from start of SQL statement)
-
-*** ERROR[8822] The statement was not prepared.
-
->>
->>
->>-------------------------------
->>--test translation name changes
->>-------------------------------
->>
->>create table t001(c char(10));
-
---- SQL operation complete.
->>insert into t001 values(x'4e');
-
---- 1 row(s) inserted.
->>
->>?section dml
->>--New valid name. Case insensitive
->>select translate(_kanji'asdf' using KANJITOISO88591) from (values(1))x;
-
-*** ERROR[3010] Character set KANJI is not yet supported.
-
-*** ERROR[15001] A syntax error occurred at or before: 
-select translate(_kanji'asdf' using KANJITOISO88591) from (values(1))x;
-                      ^ (23 characters from start of SQL statement)
-
-*** ERROR[8822] The statement was not prepared.
-
->>select translate(_ksc5601'1234' using KSC5601TOISO88591) from (values(1))x;
-
-*** ERROR[3010] Character set KSC5601 is not yet supported.
-
-*** ERROR[15001] A syntax error occurred at or before: 
-select translate(_ksc5601'1234' using KSC5601TOISO88591) from (values(1))x;
-                        ^ (25 characters from start of SQL statement)
-
-*** ERROR[8822] The statement was not prepared.
-
->>select translate(_UCS2'asdf' using UCS2TOISO88591) from (values(1))x;
-
-(EXPR)
-------
-
-asdf  
-
---- 1 row(s) selected.
->>insert into t002 
-+>  select translate(c using iso88591ToUCS2) from t001 
-+>     where c = x'4e';
-
---- 1 row(s) inserted.
->>
->>--old name not allowed
->>insert into t001 values(translate(_UCS2'qwer' using UToL1));
-
-*** ERROR[4105] Translation name is not recognized.
-
-*** ERROR[8822] The statement was not prepared.
-
->>insert into t001 values(translate(_UCS2'ewrt' using UNICODE_TO_ISO88591));
-
-*** ERROR[4105] Translation name is not recognized.
-
-*** ERROR[8822] The statement was not prepared.
-
->>insert into t002 values(translate('asdf' using ISO88591TOUCS2));
-
---- 1 row(s) inserted.
->>insert into t002 values(translate('qwer' using L1ToU));
-
-*** ERROR[4105] Translation name is not recognized.
-
-*** ERROR[8822] The statement was not prepared.
-
->>insert into t002 values(translate('ewrt' using ISO88591_TO_UNICODE));
-
-*** ERROR[4105] Translation name is not recognized.
-
-*** ERROR[8822] The statement was not prepared.
-
->>
->>-------------------------------
->>--test TERMINAL_CHARSETS 
->>-------------------------------
->>
->>set terminal_charset iso88591;
->>
->>-- the following should fail
->>set terminal_charset iso88592;
-
-*** ERROR[15990] Character set name for SQLCI attribute TERMINAL_CHARSET is not valid.
-
->>set terminal_charset ucs2;
-
-*** ERROR[2038] Character set ucs2 is not supported for SQLCI attribute TERMINAL_CHARSET.
-
->>set terminal_charset sjis;
->>set terminal_charset x0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789;
-
-*** ERROR[15990] Character set name for SQLCI attribute TERMINAL_CHARSET is not valid.
-
->>
->>-- the default is ucs2. this is a no-op.
->>control query default national_charset 'ucs2';
-
---- SQL operation complete.
->>
->>--test CQD NATIONAL_CHARSET (should fail)
->>-------------------------------
->>control query default national_charset 'ios88591';
-
-*** ERROR[4130] NATIONAL_CHARSET is a read-only DEFAULTS attribute and cannot be updated.
-
-*** ERROR[8822] The statement was not prepared.
-
->>
->>-- an invalid sqlci command, exercise the single-byte version of StoreSyntaxError()
->>bad_sqlci_cmd 1;
-
-*** ERROR[15001] A syntax error occurred at or before: 
-bad_sqlci_cmd 1;
-              ^ (15 characters from start of SQL statement)
-
->>
->>?section clnup
->>drop table t001;
-
---- SQL operation complete.
->>drop table t002;
-
---- SQL operation complete.
->>
->>log;