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 2016/11/03 23:10:48 UTC

[1/2] incubator-trafodion git commit: [TRAFODION-2322] Improve UPDATE STATS performance on long char columns

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 294b8c6d6 -> af79ac47c


[TRAFODION-2322] Improve UPDATE STATS performance on long char columns


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

Branch: refs/heads/master
Commit: dfaaa41b044980ddf62c74b8e8778b29e3f267eb
Parents: 9c712a4
Author: Dave Birdsall <db...@apache.org>
Authored: Wed Nov 2 18:20:20 2016 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Wed Nov 2 18:20:20 2016 +0000

----------------------------------------------------------------------
 core/sql/common/NAMemory.cpp                |   5 +
 core/sql/common/NAMemory.h                  |   8 +-
 core/sql/common/OperTypeEnum.h              |   1 +
 core/sql/export/NAStringDef.cpp             |   7 ++
 core/sql/export/NAStringDef.h               |   1 +
 core/sql/parser/ElemDDLLikeOptions.cpp      |  25 ++++
 core/sql/parser/ElemDDLLikeOptions.h        |  34 +++++
 core/sql/parser/ElemDDLNode.cpp             |   5 +
 core/sql/parser/ElemDDLNode.h               |   2 +
 core/sql/parser/ParDDLLikeOpts.cpp          |  20 +++
 core/sql/parser/ParDDLLikeOptsCreateTable.h |  14 +++
 core/sql/parser/sqlparser.y                 |   5 +
 core/sql/regress/compGeneral/EXPECTED023    | 114 +++++++++--------
 core/sql/regress/compGeneral/TEST023        |  68 +++++-----
 core/sql/regress/seabase/EXPECTED040        | 151 +++++++++++++++++++++++
 core/sql/regress/seabase/TEST040            |  37 +++++-
 core/sql/sqlcomp/CmpDescribe.cpp            |  61 +++++++--
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp     |   9 +-
 core/sql/sqlcomp/DefaultConstants.h         |   4 +
 core/sql/sqlcomp/nadefaults.cpp             |   1 +
 core/sql/ustat/hs_cli.cpp                   |  90 +++++++-------
 core/sql/ustat/hs_globals.cpp               |  23 ++--
 core/sql/ustat/hs_globals.h                 |  12 +-
 core/sql/ustat/hs_parser.cpp                |   2 +-
 core/sql/ustat/hs_yacc.y                    |   5 +
 25 files changed, 543 insertions(+), 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/common/NAMemory.cpp
----------------------------------------------------------------------
diff --git a/core/sql/common/NAMemory.cpp b/core/sql/common/NAMemory.cpp
index cca6cbf..f8f9c5d 100644
--- a/core/sql/common/NAMemory.cpp
+++ b/core/sql/common/NAMemory.cpp
@@ -4130,6 +4130,11 @@ NAHeap::doCheckMallocState()
   assert(total <= totalSize_);
   assert(allocSize_ <= highWaterMark_);
   assert(allocSize_ <= intervalWaterMark_);
+
+  // also check for overflow
+  if (debugLevel_ == 2)
+    checkForOverflow();
+
 }
 
 // Find x in a bin. Used in other check functions.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/common/NAMemory.h
----------------------------------------------------------------------
diff --git a/core/sql/common/NAMemory.h b/core/sql/common/NAMemory.h
index 5b9978b..270289e 100644
--- a/core/sql/common/NAMemory.h
+++ b/core/sql/common/NAMemory.h
@@ -746,6 +746,13 @@ public:
 
   NA_EIDPROC void releaseFreePages(); // release deallocted pages to kernel
 
+#if (defined(_DEBUG) || defined(NSK_MEMDEBUG)) && !defined(__EID) 
+  // useful method for debugging buffer overruns; sprinkle your code
+  // with calls to this in order to narrow down where a buffer overrun
+  // is occurring
+  NA_EIDPROC void      doCheckMallocState();
+#endif // (defined(_DEBUG) || defined(NSK_MEMDEBUG)) && !defined(__EID)
+
 private:
   NA_EIDPROC static NABoolean isAligned(void *a);
   NA_EIDPROC static size_t    granularityAlign(size_t size);
@@ -809,7 +816,6 @@ private:
   NA_EIDPROC void      doCheckTree(NATreeFragment *t);
   NA_EIDPROC void      doCheckTreebin(bindex_t i);
   NA_EIDPROC void      doCheckSmallbin(bindex_t i);
-  NA_EIDPROC void      doCheckMallocState();
   NA_EIDPROC NABoolean binFind(NAHeapFragment *x);
   NA_EIDPROC size_t    traverseAndCheck();
 #ifndef STAND_ALONE

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/common/OperTypeEnum.h
----------------------------------------------------------------------
diff --git a/core/sql/common/OperTypeEnum.h b/core/sql/common/OperTypeEnum.h
index bc76f6d..6f2129a 100644
--- a/core/sql/common/OperTypeEnum.h
+++ b/core/sql/common/OperTypeEnum.h
@@ -1067,6 +1067,7 @@ enum OperatorTypeEnum {
                         ELM_LIKE_OPT_WITHOUT_SALT_ELEM,
                         ELM_LIKE_OPT_SALT_CLAUSE_ELEM,
                         ELM_LIKE_OPT_WITHOUT_DIVISION_ELEM,
+                        ELM_LIKE_OPT_LIMIT_COLUMN_LENGTH,
                         ELM_LOCATION_ELEM,
                         ELM_OPTION_LIST,
                         ELM_PARALLEL_EXEC_ELEM,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/export/NAStringDef.cpp
----------------------------------------------------------------------
diff --git a/core/sql/export/NAStringDef.cpp b/core/sql/export/NAStringDef.cpp
index 848f54c..94ef1d6 100644
--- a/core/sql/export/NAStringDef.cpp
+++ b/core/sql/export/NAStringDef.cpp
@@ -169,6 +169,13 @@ NAString::capacity(size_t nc)
   return capacity();
 }
 
+// Erase the contents of a string
+void
+NAString::clear(void)
+{
+  fbstring_.clear();
+}
+
 // String comparisons
 Int32
 NAString::compareTo(const char* cs2, caseCompare cmp) const

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/export/NAStringDef.h
----------------------------------------------------------------------
diff --git a/core/sql/export/NAStringDef.h b/core/sql/export/NAStringDef.h
index a9a3cf6..e46b6e1 100644
--- a/core/sql/export/NAStringDef.h
+++ b/core/sql/export/NAStringDef.h
@@ -364,6 +364,7 @@ public:
 
   size_t        capacity() const                {return fbstring_.capacity();}
   size_t        capacity(size_t N);
+  void          clear();
 #ifndef RW_NO_LOCALE
   Int32           collate(const char* cs) const   {return ::strcoll(data(), cs);}
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/parser/ElemDDLLikeOptions.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLLikeOptions.cpp b/core/sql/parser/ElemDDLLikeOptions.cpp
index 4912ce6..f97e34e 100644
--- a/core/sql/parser/ElemDDLLikeOptions.cpp
+++ b/core/sql/parser/ElemDDLLikeOptions.cpp
@@ -224,6 +224,31 @@ const NAString ElemDDLLikeOptWithoutDivision::getText() const
 }
 
 
+// -----------------------------------------------------------------------
+// methods for class ElemDDLLikeLimitColumnLength
+// -----------------------------------------------------------------------
+
+// virtual destructor
+ElemDDLLikeLimitColumnLength::~ElemDDLLikeLimitColumnLength()
+{
+}
+
+// casting
+ElemDDLLikeLimitColumnLength * ElemDDLLikeLimitColumnLength::castToElemDDLLikeLimitColumnLength()
+{
+  return this;
+}
+
+//
+// methods for tracing
+//
+
+const NAString ElemDDLLikeLimitColumnLength::getText() const
+{
+  return "ElemDDLLikeLimitColumnLength";
+}
+
+
 //
 // End of File
 //

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/parser/ElemDDLLikeOptions.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLLikeOptions.h b/core/sql/parser/ElemDDLLikeOptions.h
index 0b2eeec..8d118a3 100644
--- a/core/sql/parser/ElemDDLLikeOptions.h
+++ b/core/sql/parser/ElemDDLLikeOptions.h
@@ -258,4 +258,38 @@ private:
 
 }; // class ElemDDLLikeOptWithoutDivision
 
+// -----------------------------------------------------------------------
+// definition of class ElemDDLLikeLimitColumnLength
+// -----------------------------------------------------------------------
+class ElemDDLLikeLimitColumnLength : public ElemDDLLikeOpt
+{
+
+public:
+
+  // constructor
+  ElemDDLLikeLimitColumnLength(UInt32 limit)
+    : ElemDDLLikeOpt(ELM_LIKE_OPT_LIMIT_COLUMN_LENGTH),
+      columnLengthLimit_(limit)
+  { }
+
+  // virtual destructor
+  virtual ~ElemDDLLikeLimitColumnLength();
+
+  // cast
+  virtual ElemDDLLikeLimitColumnLength *
+    castToElemDDLLikeLimitColumnLength();
+
+  // method for tracing
+  virtual const NAString getText() const;
+
+  UInt32 getColumnLengthLimit()
+  { return columnLengthLimit_; };
+
+
+private:
+
+  UInt32 columnLengthLimit_; // in bytes
+
+}; // class ElemDDLLikeLimitColumnLength
+
 #endif // ELEMDDLLIKEOPTIONS_H

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/parser/ElemDDLNode.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.cpp b/core/sql/parser/ElemDDLNode.cpp
index f243f35..e59c8d3 100644
--- a/core/sql/parser/ElemDDLNode.cpp
+++ b/core/sql/parser/ElemDDLNode.cpp
@@ -568,6 +568,11 @@ ElemDDLLikeOptWithoutDivision * ElemDDLNode::castToElemDDLLikeOptWithoutDivision
   return NULL;
 }
 
+ElemDDLLikeLimitColumnLength * ElemDDLNode::castToElemDDLLikeLimitColumnLength()
+{
+  return NULL;
+}
+
 ElemDDLList *
 ElemDDLNode::castToElemDDLList()
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/parser/ElemDDLNode.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ElemDDLNode.h b/core/sql/parser/ElemDDLNode.h
index 3203ba0..4c400a9 100644
--- a/core/sql/parser/ElemDDLNode.h
+++ b/core/sql/parser/ElemDDLNode.h
@@ -137,6 +137,7 @@ class ElemDDLLikeOptWithHorizontalPartitions;
 class ElemDDLLikeOptWithoutSalt;
 class ElemDDLLikeSaltClause;
 class ElemDDLLikeOptWithoutDivision;
+class ElemDDLLikeLimitColumnLength;
 class ElemDDLList;
 class ElemDDLLocation;
 class ElemDDLOptionList;
@@ -460,6 +461,7 @@ public:
   virtual ElemDDLLikeOptWithoutSalt     * castToElemDDLLikeOptWithoutSalt();
   virtual ElemDDLLikeSaltClause         * castToElemDDLLikeSaltClause();
   virtual ElemDDLLikeOptWithoutDivision * castToElemDDLLikeOptWithoutDivision();
+  virtual ElemDDLLikeLimitColumnLength  * castToElemDDLLikeLimitColumnLength();
   virtual ElemDDLList                   * castToElemDDLList();
   virtual ElemDDLLocation               * castToElemDDLLocation();
   virtual ElemDDLOptionList             * castToElemDDLOptionList();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/parser/ParDDLLikeOpts.cpp
----------------------------------------------------------------------
diff --git a/core/sql/parser/ParDDLLikeOpts.cpp b/core/sql/parser/ParDDLLikeOpts.cpp
index bd2074a..5e8b932 100644
--- a/core/sql/parser/ParDDLLikeOpts.cpp
+++ b/core/sql/parser/ParDDLLikeOpts.cpp
@@ -113,6 +113,7 @@ ParDDLLikeOptsCreateTable::operator=(
   isLikeOptWithoutSaltSpec_     = likeOptions.isLikeOptWithoutSaltSpec_;
   isLikeOptSaltClauseSpec_      = likeOptions.isLikeOptSaltClauseSpec_;
   isLikeOptWithoutDivisionSpec_ = likeOptions.isLikeOptWithoutDivisionSpec_;
+  isLikeOptLimitColumnLengthSpec_ = likeOptions.isLikeOptLimitColumnLengthSpec_;
 
   isLikeOptWithComments_        = likeOptions.isLikeOptWithComments_;
   isLikeOptWithoutConstraints_  = likeOptions.isLikeOptWithoutConstraints_;
@@ -121,6 +122,7 @@ ParDDLLikeOptsCreateTable::operator=(
   isLikeOptWithHorizontalPartitions_  = likeOptions.isLikeOptWithHorizontalPartitions_;
   isLikeOptWithoutSalt_         = likeOptions.isLikeOptWithoutSalt_;
   isLikeOptWithoutDivision_     = likeOptions.isLikeOptWithoutDivision_;
+  isLikeOptColumnLengthLimit_   = likeOptions.isLikeOptColumnLengthLimit_;
 
   if (this != &likeOptions)  // make sure not assigning to self
     {
@@ -155,6 +157,7 @@ ParDDLLikeOptsCreateTable::initializeDataMembers()
   isLikeOptWithoutSaltSpec_     = FALSE;
   isLikeOptSaltClauseSpec_      = FALSE;
   isLikeOptWithoutDivisionSpec_ = FALSE;
+  isLikeOptLimitColumnLengthSpec_ = FALSE;
 
   isLikeOptWithComments_        = FALSE;
   isLikeOptWithoutConstraints_  = FALSE;
@@ -164,6 +167,7 @@ ParDDLLikeOptsCreateTable::initializeDataMembers()
   isLikeOptWithoutSalt_         = FALSE;
   isLikeOptSaltClause_          = NULL;
   isLikeOptWithoutDivision_     = FALSE;
+  isLikeOptColumnLengthLimit_   = UINT_MAX;
 }
 
 void
@@ -261,6 +265,22 @@ ParDDLLikeOptsCreateTable::setLikeOption(ElemDDLLikeOpt * pLikeOption)
     isLikeOptWithoutDivisionSpec_ = TRUE;
     break;
 
+  case ELM_LIKE_OPT_LIMIT_COLUMN_LENGTH:
+    {
+      if (isLikeOptLimitColumnLengthSpec_)
+      {
+        // ERROR[3152] Duplicate LIMIT COLUMN LENGTH phrases were specified
+        //             in LIKE clause in CREATE TABLE statement.
+        *SqlParser_Diags << DgSqlCode(-3152) << DgString0("LIMIT COLUMN LENGTH");
+      }
+      ComASSERT(pLikeOption->castToElemDDLLikeLimitColumnLength() != NULL);
+      ElemDDLLikeLimitColumnLength * limitColumnLength = 
+        pLikeOption->castToElemDDLLikeLimitColumnLength();
+      isLikeOptColumnLengthLimit_ = limitColumnLength->getColumnLengthLimit();
+      isLikeOptLimitColumnLengthSpec_ = TRUE;
+    }
+    break;
+
   default :
     NAAbort("ParDDLLikeOpts.C", __LINE__, "internal logic error");
     break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/parser/ParDDLLikeOptsCreateTable.h
----------------------------------------------------------------------
diff --git a/core/sql/parser/ParDDLLikeOptsCreateTable.h b/core/sql/parser/ParDDLLikeOptsCreateTable.h
index 448875a..32e2518 100644
--- a/core/sql/parser/ParDDLLikeOptsCreateTable.h
+++ b/core/sql/parser/ParDDLLikeOptsCreateTable.h
@@ -131,6 +131,12 @@ public:
     return isLikeOptWithoutDivision_;
   }
 
+  const UInt32
+  getIsLikeOptColumnLengthLimit() const
+  {
+    return isLikeOptColumnLengthLimit_;
+  }
+
   // mutators
 
   void setLikeOption(ElemDDLLikeOpt * pLikeOptParseNode);
@@ -177,6 +183,12 @@ public:
     isLikeOptWithoutDivision_ = setting;
   }
 
+  void
+  setIsLikeOptColumnLengthLimit(const UInt32 setting)
+  {
+    isLikeOptColumnLengthLimit_ = setting;
+  }
+
 
 
 private:
@@ -203,6 +215,7 @@ private:
   NABoolean isLikeOptWithoutSaltSpec_;
   NABoolean isLikeOptSaltClauseSpec_;
   NABoolean isLikeOptWithoutDivisionSpec_;
+  NABoolean isLikeOptLimitColumnLengthSpec_;
 
   // legal Like options in DDL Create Table statements
 
@@ -214,6 +227,7 @@ private:
   NABoolean isLikeOptWithoutSalt_;
   NAString * isLikeOptSaltClause_;
   NABoolean isLikeOptWithoutDivision_;
+  UInt32 isLikeOptColumnLengthLimit_;  // in bytes; max UInt32 if no limit specified
 
 }; // class ParDDLLikeOptsCreateTable
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/parser/sqlparser.y
----------------------------------------------------------------------
diff --git a/core/sql/parser/sqlparser.y b/core/sql/parser/sqlparser.y
index beea4d8..1338974 100755
--- a/core/sql/parser/sqlparser.y
+++ b/core/sql/parser/sqlparser.y
@@ -26190,6 +26190,11 @@ like_option : TOK_WITHOUT TOK_CONSTRAINTS
                                   $$ = new (PARSERHEAP())
                                     ElemDDLLikeSaltClause(saltClause);
                                 }
+                      | TOK_LIMIT TOK_COLUMN TOK_LENGTH TOK_TO unsigned_integer
+                                {
+                                  $$ = new (PARSERHEAP())
+                                    ElemDDLLikeLimitColumnLength($5);
+                                }
 
 /* type pElemDDL */
 optional_create_table_attribute_list : create_table_as_attr_list_start

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/regress/compGeneral/EXPECTED023
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED023 b/core/sql/regress/compGeneral/EXPECTED023
index 38dec55..40a7b98 100644
--- a/core/sql/regress/compGeneral/EXPECTED023
+++ b/core/sql/regress/compGeneral/EXPECTED023
@@ -54,6 +54,7 @@ SB_PERSISTENT_SAMPLES
 +>c1 char(12) not null,
 +>c2 char(12) not null,
 +>c3 char(12) not null,
++>bigcol varchar(1024) not null,
 +>PRIMARY KEY (C1 ASC)
 +>)
 +>SALT USING 4 PARTITIONS
@@ -66,7 +67,12 @@ SB_PERSISTENT_SAMPLES
 +>select 
 +>  x1 || x2 || x3 || x4 || x5,
 +>  x2 || x4 || x1,
-+>  x5 || x3
++>  x5 || x3,
++>  'Wow this is really big ' || x1 || x2 || x3 || x4 || x5 ||
++>  ' and now we concatenate lots more junk, more junk than you' ||
++>  ' can shake a stick at because we like to use up storage' ||
++>  ' and exercise code paths that result in string truncation.' ||
++>  ' And you thought you had better things to do.'
 +>-- the from clause below creates 100,000 rows, the cross product of
 +>-- 5 copies of { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' }
 +>  from (values('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h'),('i'),('j')) T(x1)
@@ -119,7 +125,7 @@ STEST_EMPTY
 OBJECT_NAME                                                                                                                                                                                                                                                       SAMPLE_NAME                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           REASON  LAST_WHERE_PREDICATE
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_82_1477517948_682882                                                                                                                                                                                                                                                                                                                                                                                                                                                        M                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                
+STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_85_1478041270_144085                                                                                                                                                                                                                                                                                                                                                                                                                                                        M                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                
 
 --- 1 row(s) selected.
 >>-- should see one row
@@ -135,7 +141,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_82_1477517948_682882
+TRAF_SAMPLE_85_1478041270_144085
 
 --- SQL operation complete.
 >> -- should be stest, stest_empty, stestc, sb_* tables + a sample table
@@ -159,7 +165,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_18_1477517986_660218
+TRAF_SAMPLE_28_1478041305_501828
 
 --- SQL operation complete.
 >> -- should be stest, stest_empty, stestc, sb_* tables + a different sample table
@@ -169,7 +175,7 @@ TRAF_SAMPLE_18_1477517986_660218
 OBJECT_NAME                                                                                                                                                                                                                                                       SAMPLE_NAME                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           REASON  LAST_WHERE_PREDICATE
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_18_1477517986_660218                                                                                                                                                                                                                                                                                                                                                                                                                                                        M                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                
+STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_28_1478041305_501828                                                                                                                                                                                                                                                                                                                                                                                                                                                        M                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                
 
 --- 1 row(s) selected.
 >>-- should see one row
@@ -216,7 +222,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_69_1477518014_950969
+TRAF_SAMPLE_44_1478041331_337044
 
 --- SQL operation complete.
 >> -- should be stest, stest_empty, stestc, sb_* tables + another sample table
@@ -226,7 +232,7 @@ TRAF_SAMPLE_69_1477518014_950969
 OBJECT_NAME                                                                                                                                                                                                                                                       SAMPLE_NAME                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           REASON  LAST_WHERE_PREDICATE
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_69_1477518014_950969                                                                                                                                                                                                                                                                                                                                                                                                                                                        I                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                
+STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_44_1478041331_337044                                                                                                                                                                                                                                                                                                                                                                                                                                                        I                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                
 
 --- 1 row(s) selected.
 >>-- should see one row
@@ -250,7 +256,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_36_1477518046_834836
+TRAF_SAMPLE_70_1478041361_924570
 
 --- SQL operation complete.
 >> -- should be stest, stest_empty, stestc, sb_* tables + another sample table
@@ -260,7 +266,7 @@ TRAF_SAMPLE_36_1477518046_834836
 OBJECT_NAME                                                                                                                                                                                                                                                       SAMPLE_NAME                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           REASON  LAST_WHERE_PREDICATE
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_36_1477518046_834836                                                                                                                                                                                                                                                                                                                                                                                                                                                        I                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                
+STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_70_1478041361_924570                                                                                                                                                                                                                                                                                                                                                                                                                                                        I                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                
 
 --- 1 row(s) selected.
 >>-- should see one row
@@ -321,7 +327,7 @@ STEST
 OBJECT_NAME                                                                                                                                                                                                                                                       SAMPLE_NAME                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           REASON  LAST_WHERE_PREDICATE
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_36_1477518046_834836                                                                                                                                                                                                                                                                                                                                                                                                                                                        I        c1 >= 100000                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                
+STEST                                                                                                                                                                                                                                                             TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_70_1478041361_924570                                                                                                                                                                                                                                                                                                                                                                                                                                                        I        c1 >= 100000                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                
 
 --- 1 row(s) selected.
 >>
@@ -330,36 +336,36 @@ STEST
 
 --- SQL operation complete.
 >>
->>insert into stestc values ('naaaa','abc','ba'),
-+>  ('naaab','abc','ba'),
-+>  ('naaac','abc','ba'),
-+>  ('naaad','abc','ba'),
-+>  ('naaae','abc','ba'),
-+>  ('naaaf','abc','ba'),
-+>  ('naaag','abc','ba'),
-+>  ('naaah','abc','ba'),
-+>  ('naaai','abc','ba'),
-+>  ('naaaj','abc','ba'),
-+>  ('naaba','bhe','ba'),
-+>  ('naabb','bhe','ba'),
-+>  ('naabc','bhe','ba'),
-+>  ('naabd','bhe','ba'),
-+>  ('naabe','bhe','ba'),
-+>  ('naabf','bhe','ba'),
-+>  ('naabg','bhe','ba'),
-+>  ('naabh','bhe','ba'),
-+>  ('naabi','bhe','ba'),
-+>  ('naabj','bhe','ba'),
-+>  ('naaca','fib','ba'),
-+>  ('naacb','fib','ba'),
-+>  ('naacc','fib','ba'),
-+>  ('naacd','fib','ba'),
-+>  ('naace','fib','ba'),
-+>  ('naacf','fib','ba'),
-+>  ('naacg','fib','ba'),
-+>  ('naach','fib','ba'),
-+>  ('naaci','fib','ba'),
-+>  ('naacj','fib','ba');
+>>insert into stestc values ('naaaa','abc','ba','Hava Nagila'),
++>  ('naaab','abc','ba','Le Marseillais'),
++>  ('naaac','abc','ba','some other song'),
++>  ('naaad','abc','ba','more data'),
++>  ('naaae','abc','ba','more data'),
++>  ('naaaf','abc','ba','more data'),
++>  ('naaag','abc','ba','more data'),
++>  ('naaah','abc','ba','more data'),
++>  ('naaai','abc','ba','more data'),
++>  ('naaaj','abc','ba','more data'),
++>  ('naaba','bhe','ba','more data'),
++>  ('naabb','bhe','ba','more data'),
++>  ('naabc','bhe','ba','more data'),
++>  ('naabd','bhe','ba','more data'),
++>  ('naabe','bhe','ba','more data'),
++>  ('naabf','bhe','ba','more data'),
++>  ('naabg','bhe','ba','Ha! caught you sleeping!'),
++>  ('naabh','bhe','ba','more data'),
++>  ('naabi','bhe','ba','more data'),
++>  ('naabj','bhe','ba','more data'),
++>  ('naaca','fib','ba','more data'),
++>  ('naacb','fib','ba','more data'),
++>  ('naacc','fib','ba','more data'),
++>  ('naacd','fib','ba','more data'),
++>  ('naace','fib','ba','more data'),
++>  ('naacf','fib','ba','more data'),
++>  ('naacg','fib','ba','more data'),
++>  ('naach','fib','ba','more data'),
++>  ('naaci','fib','ba','more data'),
++>  ('naacj','fib','ba','more data');
 
 --- 30 row(s) inserted.
 >>
@@ -378,8 +384,8 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_36_1477518046_834836
-TRAF_SAMPLE_92_1477518106_421392
+TRAF_SAMPLE_70_1478041361_924570
+TRAF_SAMPLE_85_1478041416_334585
 
 --- SQL operation complete.
 >>
@@ -388,7 +394,7 @@ TRAF_SAMPLE_92_1477518106_421392
 OBJECT_NAME                                                                                                                                                                                                                                                       SAMPLE_NAME                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           REASON  LAST_WHERE_PREDICATE
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ------  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
-STESTC                                                                                                                                                                                                                                                            TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_92_1477518106_421392                                                                                                                                                                                                                                                                                                                                                                                                                                                        I        c1 >= 'naaaa'                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                
+STESTC                                                                                                                                                                                                                                                            TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_85_1478041416_334585                                                                                                                                                                                                                                                                                                                                                                                                                                                        I        c1 >= 'naaaa'                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                
 
 --- 1 row(s) selected.
 >>
@@ -413,8 +419,8 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_36_1477518046_834836
-TRAF_SAMPLE_92_1477518106_421392
+TRAF_SAMPLE_70_1478041361_924570
+TRAF_SAMPLE_85_1478041416_334585
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables"
@@ -441,8 +447,8 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_36_1477518046_834836
-TRAF_SAMPLE_92_1477518106_421392
+TRAF_SAMPLE_70_1478041361_924570
+TRAF_SAMPLE_85_1478041416_334585
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables"
@@ -470,8 +476,8 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_36_1477518046_834836
-TRAF_SAMPLE_92_1477518106_421392
+TRAF_SAMPLE_70_1478041361_924570
+TRAF_SAMPLE_85_1478041416_334585
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables"
@@ -483,7 +489,7 @@ TRAF_SAMPLE_92_1477518106_421392
 
 *** ERROR[15001] A syntax error occurred at or before: 
 SELECT "C1", "C2", "C3", "_SALT_" FROM TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPL
-E_36_1477518046_834836 WHERE  1 FOR READ UNCOMMITTED ACCESS;
+E_70_1478041361_924570 WHERE  1 FOR READ UNCOMMITTED ACCESS;
                                         ^ (120 characters from start of SQL statement)
 
 *** ERROR[8822] The statement was not prepared.
@@ -501,8 +507,8 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_36_1477518046_834836
-TRAF_SAMPLE_92_1477518106_421392
+TRAF_SAMPLE_70_1478041361_924570
+TRAF_SAMPLE_85_1478041416_334585
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables"
@@ -512,7 +518,7 @@ TRAF_SAMPLE_92_1477518106_421392
 
 *** ERROR[9219] Incremental UPDATE STATISTICS: An operation failed, possibly due to an invalid WHERE clause.
 
-*** ERROR[4001] Column BADCOL is not found.  Tables in scope: TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_36_1477518046_834836.  Default schema: TRAFODION.SCH.
+*** ERROR[4001] Column BADCOL is not found.  Tables in scope: TRAFODION.COMPGENERAL_TEST023.TRAF_SAMPLE_70_1478041361_924570.  Default schema: TRAFODION.SCH.
 
 *** ERROR[8822] The statement was not prepared.
 
@@ -553,7 +559,7 @@ SB_PERSISTENT_SAMPLES
 STEST
 STESTC
 STEST_EMPTY
-TRAF_SAMPLE_36_1477518046_834836
+TRAF_SAMPLE_70_1478041361_924570
 
 --- SQL operation complete.
 >> -- should be the same as previous "get tables" except only one sample table

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/regress/compGeneral/TEST023
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/TEST023 b/core/sql/regress/compGeneral/TEST023
index e527c23..1a81ebb 100755
--- a/core/sql/regress/compGeneral/TEST023
+++ b/core/sql/regress/compGeneral/TEST023
@@ -70,6 +70,7 @@ CREATE TABLE stestc
 c1 char(12) not null,
 c2 char(12) not null,
 c3 char(12) not null,
+bigcol varchar(1024) not null,
 PRIMARY KEY (C1 ASC)
 )
 SALT USING 4 PARTITIONS
@@ -80,7 +81,12 @@ upsert using load into stestc
 select 
   x1 || x2 || x3 || x4 || x5,
   x2 || x4 || x1,
-  x5 || x3
+  x5 || x3,
+  'Wow this is really big ' || x1 || x2 || x3 || x4 || x5 ||
+  ' and now we concatenate lots more junk, more junk than you' ||
+  ' can shake a stick at because we like to use up storage' ||
+  ' and exercise code paths that result in string truncation.' ||
+  ' And you thought you had better things to do.'
 -- the from clause below creates 100,000 rows, the cross product of
 -- 5 copies of { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' }
   from (values('a'),('b'),('c'),('d'),('e'),('f'),('g'),('h'),('i'),('j')) T(x1)
@@ -195,36 +201,36 @@ execute s1 using 'STEST';
 -- similar tests, but using character data types
 update statistics for table stestc on every column sample random 10 percent persistent;
 
-insert into stestc values ('naaaa','abc','ba'),
-  ('naaab','abc','ba'),
-  ('naaac','abc','ba'),
-  ('naaad','abc','ba'),
-  ('naaae','abc','ba'),
-  ('naaaf','abc','ba'),
-  ('naaag','abc','ba'),
-  ('naaah','abc','ba'),
-  ('naaai','abc','ba'),
-  ('naaaj','abc','ba'),
-  ('naaba','bhe','ba'),
-  ('naabb','bhe','ba'),
-  ('naabc','bhe','ba'),
-  ('naabd','bhe','ba'),
-  ('naabe','bhe','ba'),
-  ('naabf','bhe','ba'),
-  ('naabg','bhe','ba'),
-  ('naabh','bhe','ba'),
-  ('naabi','bhe','ba'),
-  ('naabj','bhe','ba'),
-  ('naaca','fib','ba'),
-  ('naacb','fib','ba'),
-  ('naacc','fib','ba'),
-  ('naacd','fib','ba'),
-  ('naace','fib','ba'),
-  ('naacf','fib','ba'),
-  ('naacg','fib','ba'),
-  ('naach','fib','ba'),
-  ('naaci','fib','ba'),
-  ('naacj','fib','ba');
+insert into stestc values ('naaaa','abc','ba','Hava Nagila'),
+  ('naaab','abc','ba','Le Marseillais'),
+  ('naaac','abc','ba','some other song'),
+  ('naaad','abc','ba','more data'),
+  ('naaae','abc','ba','more data'),
+  ('naaaf','abc','ba','more data'),
+  ('naaag','abc','ba','more data'),
+  ('naaah','abc','ba','more data'),
+  ('naaai','abc','ba','more data'),
+  ('naaaj','abc','ba','more data'),
+  ('naaba','bhe','ba','more data'),
+  ('naabb','bhe','ba','more data'),
+  ('naabc','bhe','ba','more data'),
+  ('naabd','bhe','ba','more data'),
+  ('naabe','bhe','ba','more data'),
+  ('naabf','bhe','ba','more data'),
+  ('naabg','bhe','ba','Ha! caught you sleeping!'),
+  ('naabh','bhe','ba','more data'),
+  ('naabi','bhe','ba','more data'),
+  ('naabj','bhe','ba','more data'),
+  ('naaca','fib','ba','more data'),
+  ('naacb','fib','ba','more data'),
+  ('naacc','fib','ba','more data'),
+  ('naacd','fib','ba','more data'),
+  ('naace','fib','ba','more data'),
+  ('naacf','fib','ba','more data'),
+  ('naacg','fib','ba','more data'),
+  ('naach','fib','ba','more data'),
+  ('naaci','fib','ba','more data'),
+  ('naacj','fib','ba','more data');
 
 update statistics for table stestc on existing columns incremental where c1 >= 'naaaa';
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/regress/seabase/EXPECTED040
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED040 b/core/sql/regress/seabase/EXPECTED040
index 696e5f1..4443ee6 100644
--- a/core/sql/regress/seabase/EXPECTED040
+++ b/core/sql/regress/seabase/EXPECTED040
@@ -53,6 +53,41 @@ CREATE TABLE TRAFODION.T040SCH.T040NOSALT
 
 --- SQL operation complete.
 >>
+>>create table t040bigcols(a int not null,
++>                         b char(1000) character set iso88591,
++>                         c varchar(1001) character set iso88591,
++>                         d char(1002) character set utf8,
++>                         e varchar(1003) character set utf8,
++>                         f char(1004) character set ucs2,
++>                         g varchar(1005) character set ucs2,
++>                         primary key (a));
+
+--- SQL operation complete.
+>>
+>>showddl t040bigcols;
+
+CREATE TABLE TRAFODION.T040SCH.T040BIGCOLS
+  (
+    A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
+  , B                                CHAR(1000) CHARACTER SET ISO88591 COLLATE
+      DEFAULT DEFAULT NULL
+  , C                                VARCHAR(1001) CHARACTER SET ISO88591
+      COLLATE DEFAULT DEFAULT NULL
+  , D                                CHAR(1002 CHARS) CHARACTER SET UTF8
+      COLLATE DEFAULT DEFAULT NULL
+  , E                                VARCHAR(1003 CHARS) CHARACTER SET UTF8
+      COLLATE DEFAULT DEFAULT NULL
+  , F                                CHAR(1004) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , G                                VARCHAR(1005) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , PRIMARY KEY (A ASC)
+  )
+ ATTRIBUTES ALIGNED FORMAT
+;
+
+--- SQL operation complete.
+>>
 >>?section positive_tests
 >>
 >>-- positive tests
@@ -227,6 +262,122 @@ CREATE TABLE TRAFODION.T040SCH.T040NOSALTSAME
 
 --- SQL operation complete.
 >>
+>>create table t040limitedcols like t040bigcols 
++>limit column length to 256;
+
+--- SQL operation complete.
+>>
+>>showddl t040limitedcols;
+
+CREATE TABLE TRAFODION.T040SCH.T040LIMITEDCOLS
+  (
+    A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
+  , B                                CHAR(256) CHARACTER SET ISO88591 COLLATE
+      DEFAULT DEFAULT NULL
+  , C                                VARCHAR(256) CHARACTER SET ISO88591
+      COLLATE DEFAULT DEFAULT NULL
+  , D                                CHAR(256 BYTES) CHARACTER SET UTF8 COLLATE
+      DEFAULT DEFAULT NULL
+  , E                                VARCHAR(256 BYTES) CHARACTER SET UTF8
+      COLLATE DEFAULT DEFAULT NULL
+  , F                                CHAR(128) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , G                                VARCHAR(128) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , PRIMARY KEY (A ASC)
+  )
+ ATTRIBUTES ALIGNED FORMAT
+;
+
+--- SQL operation complete.
+>>
+>>create table t040somelimitedcols like t040bigcols 
++>limit column length to 1002;
+
+--- SQL operation complete.
+>>
+>>showddl t040somelimitedcols;
+
+CREATE TABLE TRAFODION.T040SCH.T040SOMELIMITEDCOLS
+  (
+    A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
+  , B                                CHAR(1000) CHARACTER SET ISO88591 COLLATE
+      DEFAULT DEFAULT NULL
+  , C                                VARCHAR(1001) CHARACTER SET ISO88591
+      COLLATE DEFAULT DEFAULT NULL
+  , D                                CHAR(1002 BYTES) CHARACTER SET UTF8
+      COLLATE DEFAULT DEFAULT NULL
+  , E                                VARCHAR(1002 BYTES) CHARACTER SET UTF8
+      COLLATE DEFAULT DEFAULT NULL
+  , F                                CHAR(501) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , G                                VARCHAR(501) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , PRIMARY KEY (A ASC)
+  )
+ ATTRIBUTES ALIGNED FORMAT
+;
+
+--- SQL operation complete.
+>>
+>>create table t040fewerlimitedcols like t040bigcols 
++>limit column length to 2010;
+
+--- SQL operation complete.
+>>
+>>showddl t040fewerlimitedcols;
+
+CREATE TABLE TRAFODION.T040SCH.T040FEWERLIMITEDCOLS
+  (
+    A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
+  , B                                CHAR(1000) CHARACTER SET ISO88591 COLLATE
+      DEFAULT DEFAULT NULL
+  , C                                VARCHAR(1001) CHARACTER SET ISO88591
+      COLLATE DEFAULT DEFAULT NULL
+  , D                                CHAR(2010 BYTES) CHARACTER SET UTF8
+      COLLATE DEFAULT DEFAULT NULL
+  , E                                VARCHAR(2010 BYTES) CHARACTER SET UTF8
+      COLLATE DEFAULT DEFAULT NULL
+  , F                                CHAR(1004) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , G                                VARCHAR(1005) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , PRIMARY KEY (A ASC)
+  )
+ ATTRIBUTES ALIGNED FORMAT
+;
+
+--- SQL operation complete.
+>>
+>>create table t040nolimitedcols like t040bigcols 
++>limit column length to 4012;
+
+--- SQL operation complete.
+>>
+>>showddl t040nolimitedcols;
+
+CREATE TABLE TRAFODION.T040SCH.T040NOLIMITEDCOLS
+  (
+    A                                INT NO DEFAULT NOT NULL NOT DROPPABLE
+  , B                                CHAR(1000) CHARACTER SET ISO88591 COLLATE
+      DEFAULT DEFAULT NULL
+  , C                                VARCHAR(1001) CHARACTER SET ISO88591
+      COLLATE DEFAULT DEFAULT NULL
+  , D                                CHAR(1002 CHARS) CHARACTER SET UTF8
+      COLLATE DEFAULT DEFAULT NULL
+  , E                                VARCHAR(1003 CHARS) CHARACTER SET UTF8
+      COLLATE DEFAULT DEFAULT NULL
+  , F                                CHAR(1004) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , G                                VARCHAR(1005) CHARACTER SET UCS2 COLLATE
+      DEFAULT DEFAULT NULL
+  , PRIMARY KEY (A ASC)
+  )
+ ATTRIBUTES ALIGNED FORMAT
+;
+
+--- SQL operation complete.
+>>
 >>?section negative_tests
 >>
 >>-- negative tests

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/regress/seabase/TEST040
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST040 b/core/sql/regress/seabase/TEST040
index 7940946..f8e8dcf 100644
--- a/core/sql/regress/seabase/TEST040
+++ b/core/sql/regress/seabase/TEST040
@@ -1,5 +1,4 @@
--- test for CREATE TABLE LIKE
---
+
 -- @@@ START COPYRIGHT @@@
 --
 -- Licensed to the Apache Software Foundation (ASF) under one
@@ -20,6 +19,9 @@
 -- under the License.
 --
 -- @@@ END COPYRIGHT @@@
+--
+-- test for CREATE TABLE LIKE
+--
 
 log LOG040 clear;
 
@@ -42,6 +44,17 @@ create table t040nosalt(a int not null, b int not null, c int, primary key (a,b)
 
 showddl t040nosalt;
 
+create table t040bigcols(a int not null,
+                         b char(1000) character set iso88591,
+                         c varchar(1001) character set iso88591,
+                         d char(1002) character set utf8,
+                         e varchar(1003) character set utf8,
+                         f char(1004) character set ucs2,
+                         g varchar(1005) character set ucs2,
+                         primary key (a));
+
+showddl t040bigcols;
+
 ?section positive_tests
 
 -- positive tests
@@ -82,6 +95,26 @@ create table t040nosaltsame like t040nosalt;
 
 showddl t040nosaltsame;
 
+create table t040limitedcols like t040bigcols 
+limit column length to 256;
+
+showddl t040limitedcols;
+
+create table t040somelimitedcols like t040bigcols 
+limit column length to 1002;
+
+showddl t040somelimitedcols;
+
+create table t040fewerlimitedcols like t040bigcols 
+limit column length to 2010;
+
+showddl t040fewerlimitedcols;
+
+create table t040nolimitedcols like t040bigcols 
+limit column length to 4012;
+
+showddl t040nolimitedcols;
+
 ?section negative_tests
 
 -- negative tests

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index 5ca0309..a8337ee 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -200,6 +200,7 @@ short CmpDescribeSeabaseTable (
                              NABoolean withPartns = FALSE,
                              NABoolean withoutSalt = FALSE,
                              NABoolean withoutDivisioning = FALSE,
+                             UInt32 columnLengthLimit = UINT_MAX,
                              NABoolean noTrailingSemi = FALSE,
 
                              // used to add,rem,alter column definition from col list.
@@ -2353,7 +2354,7 @@ short CmpDescribeHiveTable (
                                          type,
                                          dummyBuf, dummyLen, heap, 
                                          NULL, 
-                                         TRUE, FALSE, FALSE, TRUE,
+                                         TRUE, FALSE, FALSE, UINT_MAX, TRUE,
                                          NULL, 0, NULL, NULL, &space);
 
       outputShortLine(space, ";");
@@ -2379,7 +2380,9 @@ short cmpDisplayColumn(const NAColumn *nac,
                        NABoolean namesOnly,
                        NABoolean &identityCol,
                        NABoolean isExternalTable,
-                       NABoolean isAlignedRowFormat)
+                       NABoolean isAlignedRowFormat,
+                       UInt32 columnLengthLimit,
+                       NAList<const NAColumn *> * truncatedColumnList)
 {
   Space lSpace;
   
@@ -2443,6 +2446,26 @@ short cmpDisplayColumn(const NAColumn *nac,
   
   NAString nas;
   nat->getMyTypeAsText(&nas, FALSE);
+
+  // if it is a character type and it is longer than the length
+  // limit in bytes, then shorten the target type
+  
+  if ((nat->getTypeQualifier() == NA_CHARACTER_TYPE) &&
+      (!nat->isLob()) &&
+      (columnLengthLimit < UINT_MAX) &&
+      (truncatedColumnList))
+    {
+      const CharType * natc = (const CharType *)nat;
+      if (natc->getDataStorageSize() > columnLengthLimit)
+        {
+          CharType * newType = (CharType *)natc->newCopy(NULL);
+          newType->setDataStorageSize(columnLengthLimit);
+          nas.clear();
+          newType->getMyTypeAsText(&nas, FALSE);
+          delete newType;
+          truncatedColumnList->insert(nac);
+        }
+    }
   
   NAString attrStr;
   
@@ -2552,11 +2575,13 @@ short cmpDisplayColumns(const NAColumnArray & naColArr,
                         NABoolean namesOnly,
                         Lng32 &identityColPos,
                         NABoolean isExternalTable,
-			NABoolean isAlignedRowFormat,
+                        NABoolean isAlignedRowFormat,
                         char * inColName = NULL,
                         short ada = 0, // 0,add. 1,drop. 2,alter
                         const NAColumn * nacol = NULL,
-                        const NAType * natype = NULL)
+                        const NAType * natype = NULL,
+                        UInt32 columnLengthLimit = UINT_MAX,
+                        NAList<const NAColumn *> * truncatedColumnList = NULL)
 {
   Lng32 ii = 0;
   identityColPos = -1;
@@ -2583,13 +2608,13 @@ short cmpDisplayColumns(const NAColumnArray & naColArr,
           (ada == 2) && (nacol) && (natype))
         {
           if (cmpDisplayColumn(nac, NULL, natype, displayType, &space, buf, ii, namesOnly, identityCol, 
-                               isExternalTable, isAlignedRowFormat))
+                               isExternalTable, isAlignedRowFormat, columnLengthLimit, truncatedColumnList))
             return -1;
         }
       else
         {
           if (cmpDisplayColumn(nac, NULL, NULL, displayType, &space, buf, ii, namesOnly, identityCol, 
-                               isExternalTable, isAlignedRowFormat))
+                               isExternalTable, isAlignedRowFormat, columnLengthLimit, truncatedColumnList))
             return -1;
         }
 
@@ -2602,7 +2627,7 @@ short cmpDisplayColumns(const NAColumnArray & naColArr,
   if ((inColName) && (ada == 0) && (nacol))
     {
       if (cmpDisplayColumn(nacol, NULL, NULL, displayType, &space, buf, ii, namesOnly, identityCol, 
-                           isExternalTable, isAlignedRowFormat))
+                           isExternalTable, isAlignedRowFormat, columnLengthLimit, truncatedColumnList))
         return -1;
     }
 
@@ -2697,6 +2722,7 @@ short CmpDescribeSeabaseTable (
                                NABoolean withPartns,
                                NABoolean withoutSalt,
                                NABoolean withoutDivisioning,
+                               UInt32 columnLengthLimit,
                                NABoolean noTrailingSemi,
                                char * colName,
                                short ada,
@@ -2913,6 +2939,7 @@ short CmpDescribeSeabaseTable (
 
   Lng32 identityColPos = -1;
   NABoolean closeParan = FALSE;
+  NAList<const NAColumn *> truncatedColumnList(heap);
   if ((NOT isExternalTable) ||
       ((isExternalTable) && 
        ((isExternalHbaseTable && (type == 1)) ||
@@ -2926,12 +2953,15 @@ short CmpDescribeSeabaseTable (
                         FALSE,
                         identityColPos,
                         isExternalTable, naTable->isSQLMXAlignedTable(),
-                        colName, ada, nacol, natype);
+                        colName, ada, nacol, natype,
+                        columnLengthLimit,
+                        &truncatedColumnList);
       closeParan = TRUE;
     }
 
   Int32 nonSystemKeyCols = 0;
   NABoolean isStoreBy = FALSE;
+  NABoolean forceStoreBy = FALSE;
   NABoolean isSalted = FALSE;
   NABoolean isDivisioned = FALSE;
   ItemExpr *saltExpr;
@@ -2967,10 +2997,23 @@ short CmpDescribeSeabaseTable (
             nonSystemKeyCols++;
           else if (nac->isSyskeyColumn())
             isStoreBy = TRUE;
+
+          // if we are shortening a column, set isStoreBy to TRUE since truncating
+          // a character string may cause formerly distinct values to become equal
+          // (that is, we want to change PRIMARY KEY to STORE BY)
+          for (Lng32 j = 0; j < truncatedColumnList.entries(); j++)
+            {
+              const NAColumn * truncatedColumn = truncatedColumnList[j];
+              if (nac->getColName() == truncatedColumn->getColName())
+                {
+                  isStoreBy = TRUE;
+                  forceStoreBy = TRUE;
+                }
+            }
         }
     }
   
-  if (nonSystemKeyCols == 0)
+  if ((nonSystemKeyCols == 0) && (!forceStoreBy))
     isStoreBy = FALSE;
 
   if (type == 1)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
index 44a85df..7f2b045 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp
@@ -66,6 +66,7 @@ extern short CmpDescribeSeabaseTable (
                              NABoolean withPartns = FALSE,
                              NABoolean withoutSalt = FALSE,
                              NABoolean withoutDivisioning = FALSE,
+                             UInt32 columnLengthLimit = UINT_MAX,
                              NABoolean noTrailingSemi = FALSE,
 
                              // used to add,rem,alter column definition from col list.
@@ -88,7 +89,9 @@ extern short cmpDisplayColumn(const NAColumn *nac,
                               NABoolean namesOnly,
                               NABoolean &identityCol,
                               NABoolean isExternalTable,
-                              NABoolean isAlignedRowFormat);
+                              NABoolean isAlignedRowFormat,
+                              UInt32 columnLengthLimit,
+                              NAList<const NAColumn *> * truncatedColumnList);
 
 extern short cmpDisplayPrimaryKey(const NAColumnArray & naColArr,
                                   Lng32 numKeys,
@@ -347,6 +350,7 @@ void CmpSeabaseDDL::createSeabaseTableLike(
                                     likeOptions.getIsWithHorizontalPartitions(),
                                     likeOptions.getIsWithoutSalt(),
                                     likeOptions.getIsWithoutDivision(),
+                                    likeOptions.getIsLikeOptColumnLengthLimit(),
                                     TRUE);
   if (retcode)
     return;
@@ -4624,6 +4628,7 @@ short CmpSeabaseDDL::createSeabaseTableLike2(
   retcode = CmpDescribeSeabaseTable(cn, 3/*createlike*/, buf, buflen, STMTHEAP,
                                     NULL,
                                     withPartns, withoutSalt, withoutDivision,
+                                    UINT_MAX,
                                     TRUE);
   if (retcode)
     return -1;
@@ -6641,7 +6646,7 @@ short CmpSeabaseDDL::hbaseFormatTableAlterColumnAttr(
   dispBuf[0] = 0;
   if (cmpDisplayColumn(nac, (char*)tempCol.data(), newType, 3, NULL, dispBuf, 
                        ii, FALSE, identityCol, 
-                       FALSE, FALSE))
+                       FALSE, FALSE, UINT_MAX, NULL))
     return -1;
   
   Int64 tableUID = naTable->objectUid().castToInt64();

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/sqlcomp/DefaultConstants.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/DefaultConstants.h b/core/sql/sqlcomp/DefaultConstants.h
index 971ef24..51f8d55 100644
--- a/core/sql/sqlcomp/DefaultConstants.h
+++ b/core/sql/sqlcomp/DefaultConstants.h
@@ -2502,6 +2502,10 @@ enum DefaultConstants
   // Histogram boundary value maximum length.
   USTAT_MAX_CHAR_BOUNDARY_LEN,
 
+  // When update statistics computes UECs on character columns or
+  // creates a sample table, it limits them to this size in bytes.
+  USTAT_MAX_CHAR_COL_LENGTH_IN_BYTES,
+
   // Maximum number of MC histograms to create for any one MC key.
   USTAT_NUM_MC_GROUPS_FOR_KEYS,
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/sqlcomp/nadefaults.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/nadefaults.cpp b/core/sql/sqlcomp/nadefaults.cpp
index 0117ac6..e8d7cfa 100644
--- a/core/sql/sqlcomp/nadefaults.cpp
+++ b/core/sql/sqlcomp/nadefaults.cpp
@@ -3559,6 +3559,7 @@ XDDkwd__(SUBQUERY_UNNESTING,			"ON"),
   DDkwd__(USTAT_LOCK_HIST_TABLES,               "OFF"),
   DD_____(USTAT_LOG,                            "ULOG"),
   DDui30_246(USTAT_MAX_CHAR_BOUNDARY_LEN,       "30"),   // Values can be 30-246.
+  DDui___(USTAT_MAX_CHAR_COL_LENGTH_IN_BYTES,   "256"),  // When computing UECs, char cols are limited to this many bytes
   DDflt0_   (USTAT_MAX_CHAR_DATASIZE_FOR_IS,    "1000"),  // max data size in MB for char type to use 
  XDDui___(USTAT_MAX_READ_AGE_IN_MIN,            "5760"),
   DDui___(USTAT_MAX_SAMPLE_AGE,                 "365"),  // For R2.5 set to a year so user created samples won't be removed.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/ustat/hs_cli.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_cli.cpp b/core/sql/ustat/hs_cli.cpp
index 26e5958..c4a5de5 100644
--- a/core/sql/ustat/hs_cli.cpp
+++ b/core/sql/ustat/hs_cli.cpp
@@ -71,6 +71,7 @@
 #include "SqlciError.h"
 #include "ExpErrorEnums.h"
 #include "CmpSeabaseDDL.h" // call to createHistogramTables
+#include "ComMisc.h"   // to get ComTrafReservedColName
 
 // -----------------------------------------------------------------------
 // Class to deallocate statement and descriptor.
@@ -531,50 +532,34 @@ Lng32 HSSample::create(NAString& tblName, NABoolean unpartitioned, NABoolean isP
         // Rather, the SALT USING clause will be used. 
         if ( !isNativeTable ) 
            tableOptions = " WITH PARTITIONS";
-        // If a transaction is running, the table needs to be created as audited.
-        // Otherwise, create table as non-audited.
-        /* TEMPTEMP. Dave need to validate this change.
-        if (TM->InTransaction())
-          tableOptions += " ATTRIBUTE AUDIT";
-        else
-          tableOptions += " ATTRIBUTE NO AUDIT";
-
-        tableOptions += getTempTablePartitionInfo(unpartitioned, isPersSample);
-        */
+        if (hs_globals->hasOversizedColumns)
+          {
+            // We will be truncating some columns when populating the sample table,
+            // trading off accuracy in UEC against performance. Add a clause to
+            // the table options limiting column lengths to the desired maximum.
+            tableOptions += " LIMIT COLUMN LENGTH TO ";
+            char temp[20];  // long enough for 32-bit integer
+            sprintf(temp,"%d",hs_globals->maxCharColumnLengthInBytes);
+            tableOptions += temp;
+          }
 
         ddl  = "CREATE TABLE ";
         ddl += tempTabName;
-        if (hs_globals->hasOversizedColumns)
+        ddl += " LIKE ";
+
+        // is this an MV LOG table?
+        if (objDef->getNameSpace() == COM_IUD_LOG_TABLE_NAME)
           {
-            // Use CREATE TABLE AS SELECT when we have to modify the column lengths
-            // (this happens for tables having very long chars/varchars). One 
-            // peculiarity: We have to use the native version of the name
-            // (e.g. HIVE.whatever.whatever for Hive tables) instead of the external
-            // table name (e.g. TRAFODION._HV_whatever.whatever) in the SELECT.
-            ddl += " NO LOAD AS SELECT ";
-            addTruncatedSelectList(ddl);
-            ddl += " FROM ";
-            ddl += objDef->getObjectFullName().data();  // e.g. HIVE.whatever.whatever
-            // ddl += tableOptions;  unfortunately not supported with CREATE TABLE AS SELECT
+            ddl += "TABLE (IUD_LOG_TABLE ";
+            ddl += userTabName;
+            ddl += ") ";
           }
         else
           {
-            ddl += " LIKE ";
-
-            // is this an MV LOG table?
-            if (objDef->getNameSpace() == COM_IUD_LOG_TABLE_NAME)
-              {
-                ddl += "TABLE (IUD_LOG_TABLE ";
-                ddl += userTabName;
-                ddl += ") ";
-              }
-            else
-              {
-                ddl += userTabName;
-              }
-
-            ddl += tableOptions;    
+            ddl += userTabName;
           }
+
+        ddl += tableOptions;    
         tableType = ANSI_TABLE;
         sampleName = new(STMTHEAP) ComObjectName(tempTabName,
                                                  COM_UNKNOWN_NAME,
@@ -5442,12 +5427,17 @@ NAString HSSample::getTempTablePartitionInfo(NABoolean unpartitionedSample,
 //
 void HSSample::addTruncatedSelectList(NAString & qry)
   {
+    bool first = true;
     for (Lng32 i = 0; i < objDef->getNumCols(); i++)
       {
-        if (i)
-          qry += ", ";
+        if (!ComTrafReservedColName(*objDef->getColInfo(i).colname))
+          {
+            if (!first)
+              qry += ", ";
 
-        addTruncatedColumnReference(qry,objDef->getColInfo(i));
+            addTruncatedColumnReference(qry,objDef->getColInfo(i));
+            first = false;
+          }
       }
   }
 
@@ -5467,18 +5457,34 @@ void HSSample::addTruncatedSelectList(NAString & qry)
 //
 void HSSample::addTruncatedColumnReference(NAString & qry,HSColumnStruct & colInfo)
   {
-    Lng32 maxLengthInBytes = MAX_SUPPORTED_CHAR_LENGTH;
+    HSGlobalsClass *hs_globals = GetHSContext();
+    Lng32 maxLengthInBytes = hs_globals->maxCharColumnLengthInBytes;
     bool isOverSized = DFS2REC::isAnyCharacter(colInfo.datatype) &&
                            (colInfo.length > maxLengthInBytes);
     if (isOverSized)
       {
+        // Note: The result data type of SUBSTRING is VARCHAR, always.
+        // But if the column is CHAR, many places in the ustat code are not
+        // expecting a VARCHAR. So, we stick a CAST around it to convert
+        // it back to a CHAR in these cases.
+
+        NABoolean isFixedChar = DFS2REC::isSQLFixedChar(colInfo.datatype);
+        if (isFixedChar)
+          qry += "CAST(";
         qry += "SUBSTRING(";
         qry += colInfo.externalColumnName->data();
         qry += " FOR ";
         
-        char temp[20];  // big enough for "nnnnnn) AS "
-        sprintf(temp,"%d) AS ", maxLengthInBytes / CharInfo::maxBytesPerChar(colInfo.charset));
+        char temp[20];  // big enough for "nnnnnn)"
+        sprintf(temp,"%d)", maxLengthInBytes / CharInfo::maxBytesPerChar(colInfo.charset));
         qry += temp;
+        if (isFixedChar)
+          {
+            qry += " AS CHAR(";
+            qry += temp;
+            qry += ")";
+          }
+        qry += " AS ";
         qry += colInfo.externalColumnName->data();
       }
     else

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/ustat/hs_globals.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.cpp b/core/sql/ustat/hs_globals.cpp
index a7fc374..b0dbfef 100644
--- a/core/sql/ustat/hs_globals.cpp
+++ b/core/sql/ustat/hs_globals.cpp
@@ -2894,7 +2894,9 @@ HSGlobalsClass::HSGlobalsClass(ComDiagsArea &diags)
     jitLogThreshold(0),
     stmtStartTime(0),
     jitLogOn(FALSE),
-    isUpdatestatsStmt(FALSE)
+    isUpdatestatsStmt(FALSE),
+    maxCharColumnLengthInBytes(ActiveSchemaDB()->getDefaults().
+               getAsLong(USTAT_MAX_CHAR_COL_LENGTH_IN_BYTES))
   {
     // Must add the context first in the constructor.
     contID_ = AddHSContext(this);
@@ -4893,14 +4895,17 @@ static void mapInternalSortTypes(HSColGroupStruct *groupList, NABoolean forHive
       // values won't matter, or no encoding is needed, in which case the
       // fields for the sorted type are the same as those for the original type.
       default:
-        group->ISdatatype = col.datatype;
-        group->ISlength = col.length;
-        if (group->ISlength > MAX_SUPPORTED_CHAR_LENGTH)
-          group->ISlength = MAX_SUPPORTED_CHAR_LENGTH;
-        group->ISprecision = col.precision;
-        group->ISscale = col.scale;
-        // the method below handles adding SUBSTRING for over-size char/varchars
-        HSSample::addTruncatedColumnReference(group->ISSelectExpn,col);
+        {
+          HSGlobalsClass *hs_globals = GetHSContext();
+          group->ISdatatype = col.datatype;
+          group->ISlength = col.length;
+          if (group->ISlength > hs_globals->maxCharColumnLengthInBytes)
+            group->ISlength = hs_globals->maxCharColumnLengthInBytes;
+          group->ISprecision = col.precision;
+          group->ISscale = col.scale;
+          // the method below handles adding SUBSTRING for over-size char/varchars
+          HSSample::addTruncatedColumnReference(group->ISSelectExpn,col);
+        }
         break;
      } // switch
      group = group->next;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/ustat/hs_globals.h
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_globals.h b/core/sql/ustat/hs_globals.h
index b372bee..90aeac9 100644
--- a/core/sql/ustat/hs_globals.h
+++ b/core/sql/ustat/hs_globals.h
@@ -84,16 +84,6 @@ Lng32 setBufferValue(T& value,
                       HSDataBuffer &boundary);
 
 
-
-// This is the max supported length of character strings in UPDATE STATISTICS.
-// We will process longer columns, but we truncate their values to this length
-// during the processing. As a result, we may underestimate UEC, if, for 
-// example, the first 32767 bytes are identical but some difference occurs
-// afterwards. If we someday wish to support longer lengths, at the very least
-// the ISVarChar class needs to change to use a longer length field for varchar
-// values.
-enum { MAX_SUPPORTED_CHAR_LENGTH = 32767 };
-
 // An instance of ISFixedChar represents a value of a fixed-length character
 // string (either single or double-byte) retrieved into memory for use by
 // internal sort. A pointer to the actual string is maintained, and definitions
@@ -1668,6 +1658,8 @@ public:
 
      NABoolean            sample_I_generated;
 
+    Lng32          maxCharColumnLengthInBytes;   /* the value of USTAT_MAX_CHAR_COL_LENGTH_IN_BYTES */
+
 private:
     //++ MV
     // special parser flags (see contr. and destr.)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/ustat/hs_parser.cpp
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_parser.cpp b/core/sql/ustat/hs_parser.cpp
index d9f5f03..dfc2927 100644
--- a/core/sql/ustat/hs_parser.cpp
+++ b/core/sql/ustat/hs_parser.cpp
@@ -521,7 +521,7 @@ HSColGroupStruct* AddSingleColumn(const Lng32 colNumber, HSColGroupStruct*& grou
     HSColumnStruct   newColumn = HSColumnStruct(hs_globals->objDef->getColInfo(colNumber));
 
     bool isOverSized = DFS2REC::isAnyCharacter(newColumn.datatype) &&
-              (newColumn.length > MAX_SUPPORTED_CHAR_LENGTH);
+              (newColumn.length > hs_globals->maxCharColumnLengthInBytes);
     if (isOverSized)
       {
         hs_globals->hasOversizedColumns = TRUE;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/dfaaa41b/core/sql/ustat/hs_yacc.y
----------------------------------------------------------------------
diff --git a/core/sql/ustat/hs_yacc.y b/core/sql/ustat/hs_yacc.y
index aaca423..6b86a4d 100644
--- a/core/sql/ustat/hs_yacc.y
+++ b/core/sql/ustat/hs_yacc.y
@@ -363,6 +363,11 @@ histogram_options : CLEAR
                           }
 
                         hs_globals_y->optFlags |= CREATE_SAMPLE_OPT;
+
+                        // read the column groups so we can truncate columns if needed
+                        hs_globals_y->optFlags |= EVERYCOL_OPT;
+                        if (Lng32 retcode = AddEveryColumn())
+                          HSHandleError(retcode);
                       }
                  |  REMOVE SAMPLE
                       {


[2/2] incubator-trafodion git commit: Merge [TRAFODION-2322] PR 811 Improve UPD STATS perf on long char cols

Posted by db...@apache.org.
Merge [TRAFODION-2322] PR 811 Improve UPD STATS perf on long char cols


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

Branch: refs/heads/master
Commit: af79ac47c887e20272c1f3331b2df2b0cc3717da
Parents: 294b8c6 dfaaa41
Author: Dave Birdsall <db...@apache.org>
Authored: Thu Nov 3 23:08:23 2016 +0000
Committer: Dave Birdsall <db...@apache.org>
Committed: Thu Nov 3 23:08:23 2016 +0000

----------------------------------------------------------------------
 core/sql/common/NAMemory.cpp                |   5 +
 core/sql/common/NAMemory.h                  |   8 +-
 core/sql/common/OperTypeEnum.h              |   1 +
 core/sql/export/NAStringDef.cpp             |   7 ++
 core/sql/export/NAStringDef.h               |   1 +
 core/sql/parser/ElemDDLLikeOptions.cpp      |  25 ++++
 core/sql/parser/ElemDDLLikeOptions.h        |  34 +++++
 core/sql/parser/ElemDDLNode.cpp             |   5 +
 core/sql/parser/ElemDDLNode.h               |   2 +
 core/sql/parser/ParDDLLikeOpts.cpp          |  20 +++
 core/sql/parser/ParDDLLikeOptsCreateTable.h |  14 +++
 core/sql/parser/sqlparser.y                 |   5 +
 core/sql/regress/compGeneral/EXPECTED023    | 114 +++++++++--------
 core/sql/regress/compGeneral/TEST023        |  68 +++++-----
 core/sql/regress/seabase/EXPECTED040        | 151 +++++++++++++++++++++++
 core/sql/regress/seabase/TEST040            |  37 +++++-
 core/sql/sqlcomp/CmpDescribe.cpp            |  61 +++++++--
 core/sql/sqlcomp/CmpSeabaseDDLtable.cpp     |   9 +-
 core/sql/sqlcomp/DefaultConstants.h         |   4 +
 core/sql/sqlcomp/nadefaults.cpp             |   1 +
 core/sql/ustat/hs_cli.cpp                   |  90 +++++++-------
 core/sql/ustat/hs_globals.cpp               |  23 ++--
 core/sql/ustat/hs_globals.h                 |  12 +-
 core/sql/ustat/hs_parser.cpp                |   2 +-
 core/sql/ustat/hs_yacc.y                    |   5 +
 25 files changed, 543 insertions(+), 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/af79ac47/core/sql/ustat/hs_cli.cpp
----------------------------------------------------------------------