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/10/21 00:47:15 UTC

[2/3] incubator-trafodion git commit: rework for fix to JIRA461

rework for fix to JIRA461


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

Branch: refs/heads/master
Commit: f31ddf6bc2e0561e4df9d470bbbc58df90dcd4ae
Parents: 6b06768
Author: Qifan Chen <qf...@dev02.trafodion.org>
Authored: Tue Oct 20 19:55:10 2015 +0000
Committer: Qifan Chen <qf...@dev02.trafodion.org>
Committed: Tue Oct 20 19:55:10 2015 +0000

----------------------------------------------------------------------
 core/sql/optimizer/ItemColRef.h  |  2 ++
 core/sql/optimizer/ItemExpr.cpp  | 23 ++++++++++++++++++-----
 core/sql/optimizer/ItemExpr.h    |  4 ++--
 core/sql/optimizer/NAFileSet.cpp |  2 +-
 core/sql/optimizer/NATable.cpp   |  2 +-
 core/sql/optimizer/PartFunc.cpp  |  8 ++++++--
 core/sql/optimizer/RelExpr.cpp   |  4 ++--
 core/sql/optimizer/RelScan.h     |  6 +++---
 core/sql/optimizer/ValueDesc.cpp |  9 +++++++--
 9 files changed, 42 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/ItemColRef.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemColRef.h b/core/sql/optimizer/ItemColRef.h
index 0382f1a..b43ff50 100644
--- a/core/sql/optimizer/ItemColRef.h
+++ b/core/sql/optimizer/ItemColRef.h
@@ -838,6 +838,8 @@ public:
   void setIsCachedParam(NABoolean isCachedParam = TRUE)  
   { isCachedParam_ = isCachedParam; }
 
+  NABoolean isSystemGeneratedOutputHV() const;
+
   NAString& getPrototypeValue() 	   { return prototypeValue_; }
   const NAString& getPrototypeValue() const { return prototypeValue_; } // LCOV_EXCL_LINE
   NABoolean hasPrototypeValue() const	   { return !prototypeValue_.isNull(); }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/ItemExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.cpp b/core/sql/optimizer/ItemExpr.cpp
index 8dbddc0..3bc1dcd 100644
--- a/core/sql/optimizer/ItemExpr.cpp
+++ b/core/sql/optimizer/ItemExpr.cpp
@@ -874,6 +874,12 @@ NABoolean ItemExpr::doesExprEvaluateToConstant(NABoolean strict,
 		  return TRUE;
 
 		case ITM_HOSTVAR:
+                 {
+                     HostVar* hv = (HostVar*)this;
+                     if ( hv->isSystemGeneratedOutputHV() )
+                        return TRUE;
+                 }
+
 		case ITM_DYN_PARAM:
 		case ITM_CACHE_PARAM:
 		case ITM_CURRENT_USER:
@@ -14459,6 +14465,12 @@ HostVar::setPMOrdPosAndIndex( ComColumnDirection paramMode,
     hvIndex_ = index;
 }
 
+NABoolean HostVar::isSystemGeneratedOutputHV() const
+{  
+  return (isSystemGenerated() &&
+           getName() == "_sys_ignored_CC_convErrorFlag"); 
+}
+
 void
 DynamicParam::setPMOrdPosAndIndex( ComColumnDirection paramMode,
 				   Int32 ordinalPosition,
@@ -14906,9 +14918,9 @@ NABoolean LOBoper::isCovered
   return FALSE;
 }
 
-// Compute the exprssion at compile time. Assume all operands are constants.
+// Evalaute the exprssion at compile time. Assume all operands are constants.
 // Return NULL if the computation fails and CmpCommon::diags() may be side-affected.
-ConstValue* ItemExpr::compute(CollHeap* heap)
+ConstValue* ItemExpr::evaluate(CollHeap* heap)
 {
   ValueIdList exprs;
   exprs.insert(getValueId());
@@ -14923,9 +14935,10 @@ ConstValue* ItemExpr::compute(CollHeap* heap)
   char* decodeBuf = staticDecodeBuf;
   Lng32 decodeBufLen = staticDecodeBufLen;
 
-  // For character types, multiplying by 8 to deal with conversions between
-  // any two known character sets supported.  
-  Lng32 factor = (DFS2REC::isAnyCharacter(dataType.getFSDatatype())) ? 8 : 1;
+  // For character types, multiplying by 6 to deal with conversions between
+  // any two known character sets allowed. See CharInfo::maxBytesPerChar()
+  // for a list of max bytes per char for each supported character set.  
+  Lng32 factor = (DFS2REC::isAnyCharacter(dataType.getFSDatatype())) ? 6 : 1;
 
   if ( staticDecodeBufLen < decodedValueLen * factor) {
     decodeBufLen = decodedValueLen * factor;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/ItemExpr.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ItemExpr.h b/core/sql/optimizer/ItemExpr.h
index b0ced2a..71518e4 100644
--- a/core/sql/optimizer/ItemExpr.h
+++ b/core/sql/optimizer/ItemExpr.h
@@ -1048,9 +1048,9 @@ public:
   //  Utility methods
   // ---------------------------------------------------------------------
   
-  // compute the exprssion at compile time. Assume all operands are constants.
+  // Evaluate the exprssion at compile time. Assume all operands are constants.
   // Return NULL if the computation fails and CmpCommon::diags() may be side-affected.
-  ConstValue* compute(CollHeap* heap);
+  ConstValue* evaluate(CollHeap* heap);
 
   // produce an ascii-version of the object (for display or saving into a file)
   virtual void unparse(NAString &result,

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/NAFileSet.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NAFileSet.cpp b/core/sql/optimizer/NAFileSet.cpp
index 4551834..f54fc77 100644
--- a/core/sql/optimizer/NAFileSet.cpp
+++ b/core/sql/optimizer/NAFileSet.cpp
@@ -169,7 +169,7 @@ Lng32 NAFileSet::getEncodedKeyLength()
 
 	for(CollIndex i=0;i<indexKeyColumns_.entries();i++)
 	{
-		encodedKeyLength_ += indexKeyColumns_[i]->getType()->getNominalSize();
+		encodedKeyLength_ += indexKeyColumns_[i]->getType()->getEncodedKeyLength();
 	}
 	return encodedKeyLength_;
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/NATable.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NATable.cpp b/core/sql/optimizer/NATable.cpp
index c6ff78c..520a514 100644
--- a/core/sql/optimizer/NATable.cpp
+++ b/core/sql/optimizer/NATable.cpp
@@ -1756,7 +1756,7 @@ static ItemExpr * getRangePartitionBoundaryValuesFromEncodedKeys(
 
             keyColVal->synthTypeAndValueId();
 
-            keyColVal = keyColVal->compute(heap);
+            keyColVal = keyColVal->evaluate(heap);
 
             if ( !keyColVal ) 
               return NULL;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/PartFunc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/PartFunc.cpp b/core/sql/optimizer/PartFunc.cpp
index ff552a9..377c9d9 100644
--- a/core/sql/optimizer/PartFunc.cpp
+++ b/core/sql/optimizer/PartFunc.cpp
@@ -5053,7 +5053,7 @@ Int32 RangePartitionBoundaries::findBeginBoundary(char* encodedKey, Int32 keyLen
                                                   compFuncPtrT compFunc) const
 {
    // boundaries are stored in entries in the range [0, partitionCount_] 
-   for (Lng32 i=partitionCount_-1; i>= 0; i--) {
+   for (Lng32 i=0; i<=partitionCount_-1; i++ ) {
 
        const char* low = getBinaryBoundaryValue(i);
        const char* high = getBinaryBoundaryValue(i+1);
@@ -5072,7 +5072,7 @@ Int32 RangePartitionBoundaries::findEndBoundary(char* encodedKey, Int32 keyLen,
                                                 compFuncPtrT compFunc) const
 {
    // boundaries are stored in entries in the range [0, partitionCount_] 
-   for (Lng32 i=0; i<partitionCount_-1; i++ ) {
+   for (Lng32 i=partitionCount_-1; i>= 0; i--) {
 
        const char* low = getBinaryBoundaryValue(i);
        const char* high = getBinaryBoundaryValue(i+1);
@@ -5095,6 +5095,10 @@ RangePartitioningFunction::computeNumOfActivePartitions(SearchKey* skey, const T
    Int32 bIndex = 0;
 
    const NATable* naTable = tDesc->getNATable();
+
+   if ( naTable->isHiveTable() )
+     return origPartitions;  
+
    NABoolean isNativeHbase = (naTable->isHbaseCellTable() || naTable->isHbaseRowTable());
    compFuncPtrT compFuncPtr = ( isNativeHbase ) ? compareAsciiKey: compareEncodedKey;
   

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/RelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExpr.cpp b/core/sql/optimizer/RelExpr.cpp
index 4fb8b8b..9f031de 100644
--- a/core/sql/optimizer/RelExpr.cpp
+++ b/core/sql/optimizer/RelExpr.cpp
@@ -9516,7 +9516,7 @@ FileScan::FileScan(const CorrName& tableName,
      mdamFlag_(UNDECIDED),
      skipRowsToPreventHalloween_(FALSE),
      doUseSearchKey_(TRUE),
-     computedNumOfActivePartiions_(-1)
+     computedNumOfActivePartitions_(-1)
 {
   // Set the filescan properties:
 
@@ -9561,7 +9561,7 @@ FileScan::FileScan(const CorrName& tableName,
          const RangePartitioningFunction* rangePartFunc =
               indexDesc_->getPartitioningFunction()->castToRangePartitioningFunction();
 
-         computedNumOfActivePartiions_ = 
+         computedNumOfActivePartitions_ = 
              rangePartFunc->computeNumOfActivePartitions(partKeys_, tableDescPtr);
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/RelScan.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelScan.h b/core/sql/optimizer/RelScan.h
index 6b14d8b..5fbaf7f 100644
--- a/core/sql/optimizer/RelScan.h
+++ b/core/sql/optimizer/RelScan.h
@@ -814,7 +814,7 @@ public:
     duplicateSuccProbes_(0),
     failedProbes_(0),
     tuplesProcessed_(0),
-    computedNumOfActivePartiions_(-1)
+    computedNumOfActivePartitions_(-1)
   {}
 
   // destructor
@@ -1021,7 +1021,7 @@ public:
            const ValueIdList& partitioningKeyColumnsList,
            const ValueIdList& partitioningKeyColumnsOrder);
 
-  Int32 getComputedNumOfActivePartiions()  const { return computedNumOfActivePartiions_; }
+  Int32 getComputedNumOfActivePartiions()  const { return computedNumOfActivePartitions_; }
 
 private:
 
@@ -1111,7 +1111,7 @@ private:
 
   // number of active partitions computed only from the Range Part Func
   // and the search key (partKey_)
-  Int32 computedNumOfActivePartiions_;
+  Int32 computedNumOfActivePartitions_;
 
 }; // class FileScan
 

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/f31ddf6b/core/sql/optimizer/ValueDesc.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/ValueDesc.cpp b/core/sql/optimizer/ValueDesc.cpp
index edb5de1..a23d2c9 100644
--- a/core/sql/optimizer/ValueDesc.cpp
+++ b/core/sql/optimizer/ValueDesc.cpp
@@ -6444,8 +6444,13 @@ ValueIdList::computeEncodedKey(const TableDesc* tDesc, NABoolean isMaxKey,
       ItemExpr* ie = vid.getItemExpr();
 
       if ( ie->getOperatorType() != ITM_CONSTANT ) {
-          ConstValue* value = ie->compute(STMTHEAP);
-          if ( !value )
+          
+          ConstValue* value = NULL;
+          if ( ie->doesExprEvaluateToConstant(TRUE, TRUE) ) {
+             value = ie->evaluate(STMTHEAP);
+             if ( !value )
+                return NULL;
+          } else
              return NULL;
 
           inputStrings[j] = new (STMTHEAP) NAString(value->getConstStr(FALSE));