Browse Source

HPCC-18633 Regress HPCC-17269 due to issues with variable length strings

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 7 years ago
parent
commit
28a362f991

+ 6 - 1
ecl/hqlcpp/hqlcppcase.cpp

@@ -426,6 +426,7 @@ IHqlExpression * HqlCppCaseInfo::buildIndexedMap(BuildCtx & ctx, const CHqlBound
         translator.ensureSimpleExpr(ctx, indexExpr);
 
     OwnedHqlExpr mapped;
+    OwnedHqlExpr castDefaultValue = ensureExprType(defaultValue, resultType);
     ITypeInfo * retType = resultType;
     //if num == pairs.ordinality() and all results are identical, avoid the table lookup.
     if (allResultsMatch && (num == pairs.ordinality()))
@@ -473,7 +474,7 @@ IHqlExpression * HqlCppCaseInfo::buildIndexedMap(BuildCtx & ctx, const CHqlBound
         for (idx = 0; idx < num; idx++)
         {
             if (&values.item(idx) == dft)
-                values.replace(*defaultValue.getLink(),idx);
+                values.replace(*LINK(castDefaultValue),idx);
         }
 
         // use a var string type to get better C++ generated...
@@ -1137,6 +1138,9 @@ bool HqlCppCaseInfo::canBuildArrayLookup(const CHqlBoundExpr & test)
         }
     }
 
+#if 0
+    //Currently removed because it revealed inconsistencies in the implementation - HPCC-18745
+    //is opened to address that later.
     if (condType->isInteger() && !isUnknownSize(resultType))
     {
         unsigned __int64 range = getIntValue(highestCompareExpr, 0) - getIntValue(lowestCompareExpr, 0) + 1;
@@ -1148,6 +1152,7 @@ bool HqlCppCaseInfo::canBuildArrayLookup(const CHqlBoundExpr & test)
             return true;
         }
     }
+#endif
 
     return false;
 }

+ 11 - 0
testing/regress/ecl/issue18633.ecl

@@ -39,3 +39,14 @@ END;
 dsScrubs := NORMALIZE(dsTest, 3, xNorm(LEFT, COUNTER));
 
 OUTPUT(dsScrubs);
+
+z(string x) := '?' + x;
+
+dsTest2 := DATASET([2, 0, 1, 3, 4, 7], { unsigned id});
+
+{ string msg } xNorm2(INTEGER c) := TRANSFORM
+      SELF.msg := CASE(c, 1=>'One', 2=>'Two', 4=>'Four', 5=>'Five', z('?'));
+END;
+
+dsScrubs2 := PROJECT(nofold(dsTest2), xNorm2(LEFT.id));
+OUTPUT(dsScrubs2);

+ 9 - 1
testing/regress/ecl/key/issue18633.xml

@@ -1,5 +1,13 @@
 <Dataset name='Result 1'>
- <Row><errormessage>Fields with errors   </errormessage><rulecnt>2</rulecnt></Row>
+ <Row><errormessage>Fields with errors</errormessage><rulecnt>2</rulecnt></Row>
  <Row><errormessage>Fields without errors</errormessage><rulecnt>0</rulecnt></Row>
  <Row><errormessage>Length was not in:1..</errormessage><rulecnt>1</rulecnt></Row>
 </Dataset>
+<Dataset name='Result 2'>
+ <Row><msg>Two</msg></Row>
+ <Row><msg>??</msg></Row>
+ <Row><msg>One</msg></Row>
+ <Row><msg>??</msg></Row>
+ <Row><msg>Four</msg></Row>
+ <Row><msg>??</msg></Row>
+</Dataset>