Browse Source

HPCC-10230 Fix issues highlighted in code review

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 11 years ago
parent
commit
116028bd28
4 changed files with 10 additions and 5 deletions
  1. 1 1
      ecl/hql/hqlexpr.cpp
  2. 4 1
      ecl/hqlcpp/hqlhtcpp.cpp
  3. 2 2
      ecl/hqlcpp/hqlsource.cpp
  4. 3 1
      ecl/regress/issue10230f.ecl

+ 1 - 1
ecl/hql/hqlexpr.cpp

@@ -15354,7 +15354,7 @@ static bool getBoolAttributeValue(IHqlExpression * attr)
     if (value->queryValue())
         return getBoolValue(value, true);
 
-    //Not a constant => fold th expression
+    //Not a constant => fold the expression
     OwnedHqlExpr folded = foldHqlExpression(value);
     if (folded->queryValue())
         return getBoolValue(folded, true);

+ 4 - 1
ecl/hqlcpp/hqlhtcpp.cpp

@@ -9719,11 +9719,14 @@ void HqlCppTranslator::buildFormatCrcFunction(BuildCtx & ctx, const char * name,
     IHqlExpression * payload = expr ? expr->queryAttribute(_payload_Atom) : NULL;
     OwnedHqlExpr exprToCrc = getSerializedForm(dataset->queryRecord(), diskAtom);
 
-    //MORE: Should this take FILEPOSITION(FALSE) into account?
     unsigned payloadSize = 1;
     if (payload)
         payloadSize = (unsigned)getIntValue(payload->queryChild(0)) + payloadDelta;
 
+    //FILEPOSITION(FALSE) means we have counted 1 too many in the payload
+    if (!getBoolAttribute(expr, filepositionAtom, true))
+        payloadSize--;
+
     exprToCrc.setown(createComma(exprToCrc.getClear(), getSizetConstant(payloadSize)));
 
     traceExpression("crc:", exprToCrc);

+ 2 - 2
ecl/hqlcpp/hqlsource.cpp

@@ -458,10 +458,10 @@ static IHqlExpression * mapIfBlock(HqlMapTransformer & mapper, IHqlExpression *
 }
 
 
-static IHqlExpression * createPhysicalIndexRecord(HqlMapTransformer & mapper, IHqlExpression * tableExpr, IHqlExpression * record, bool hasWeirdFileposition, bool allowTranslate)
+static IHqlExpression * createPhysicalIndexRecord(HqlMapTransformer & mapper, IHqlExpression * tableExpr, IHqlExpression * record, bool hasInternalFileposition, bool allowTranslate)
 {
     HqlExprArray physicalFields;
-    unsigned max = record->numChildren() - (hasWeirdFileposition ? 1 : 0);
+    unsigned max = record->numChildren() - (hasInternalFileposition ? 1 : 0);
     for (unsigned idx=0; idx < max; idx++)
     {
         IHqlExpression * cur = record->queryChild(idx);

+ 3 - 1
ecl/regress/issue10230f.ecl

@@ -17,6 +17,8 @@
 
 d := dataset('~people', { string15 name, unsigned8 dob }, flat);
 
-// The parameter can be any compile-time constant?  It should be supported, but isn't currently
+// The parameter can be any compile-time constant?  It "could" be supported, but isn't currently
+//If you really need something like this it will need to use a macro.
+//It is an example of a function needing to have a fixed output record format.
 i(boolean hasFileposition) := index(d, { name, dob }, 'peopleIndex', FILEPOSITION(hasFileposition)); // dob goes into the keyed portion, not filepos
 output(i(false)(name = 'Gavin' and dob != 0));