Browse Source

HPCC-18670 Fix assert from recent change to createPhysicalIndexRecord()

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 7 years ago
parent
commit
99fc126e99
4 changed files with 33 additions and 15 deletions
  1. 27 8
      ecl/hqlcpp/hqlckey.cpp
  2. 2 4
      ecl/hqlcpp/hqlhtcpp.cpp
  3. 1 0
      ecl/hqlcpp/hqlhtcpp.ipp
  4. 3 3
      ecl/hqlcpp/hqlsource.cpp

+ 27 - 8
ecl/hqlcpp/hqlckey.cpp

@@ -110,10 +110,9 @@ bool isKeyableType(ITypeInfo * type)
 }
 
 
-IHqlExpression * getHozedKeyValue(IHqlExpression * _value)
+ITypeInfo * getHozedKeyType(IHqlExpression * expr)
 {
-    HqlExprAttr value = _value;
-    Linked<ITypeInfo> type = _value->queryType()->queryPromotedType();
+    Linked<ITypeInfo> type = expr->queryType();
 
     type_t tc = type->getTypeCode();
     switch (tc)
@@ -125,11 +124,7 @@ IHqlExpression * getHozedKeyValue(IHqlExpression * _value)
     case type_int:
     case type_swapint:
         if (type->isSigned())
-        {
             type.setown(makeIntType(type->getSize(), false));
-            value.setown(ensureExprType(value, type));
-            value.setown(createValue(no_add, LINK(type), LINK(value), getHozedBias(type)));
-        }
         if ((type->getTypeCode() == type_littleendianint) && (type->getSize() != 1))
             type.setown(makeSwapIntType(type->getSize(), false));
         break;
@@ -150,7 +145,31 @@ IHqlExpression * getHozedKeyValue(IHqlExpression * _value)
         break;
     }
 
-    return ensureExprType(value, type);
+    return type.getClear();
+}
+
+
+IHqlExpression * getHozedKeyValue(IHqlExpression * _value)
+{
+    HqlExprAttr value = _value;
+    Linked<ITypeInfo> type = _value->queryType()->queryPromotedType();
+    Owned<ITypeInfo> hozedType = getHozedKeyType(value);
+
+    type_t tc = type->getTypeCode();
+    switch (tc)
+    {
+    case type_int:
+    case type_swapint:
+        if (type->isSigned())
+        {
+            type.setown(makeIntType(type->getSize(), false));
+            value.setown(ensureExprType(value, type));
+            value.setown(createValue(no_add, LINK(type), LINK(value), getHozedBias(type)));
+        }
+        break;
+    }
+
+    return ensureExprType(value, hozedType);
 }
 
 

+ 2 - 4
ecl/hqlcpp/hqlhtcpp.cpp

@@ -10006,10 +10006,8 @@ static void createOutputIndexRecord(HqlMapTransformer & mapper, HqlExprArray & f
                 }
                 else
                 {
-                    OwnedHqlExpr select = createSelectExpr(getActiveTableSelector(), LINK(cur));
-                    OwnedHqlExpr value = getHozedKeyValue(select);
-                    ITypeInfo * newType = value->getType();
-                    newField = createField(cur->queryId(), newType, NULL, extractFieldAttrs(cur));
+                    ITypeInfo * hozedType = getHozedKeyType(cur);
+                    newField = createField(cur->queryId(), hozedType, NULL, extractFieldAttrs(cur));
 
                     //Now set up the mappings for ifblocks
                     OwnedHqlExpr selfSelect = createSelectExpr(LINK(querySelfReference()), LINK(cur));

+ 1 - 0
ecl/hqlcpp/hqlhtcpp.ipp

@@ -237,6 +237,7 @@ public:
 
 
 unsigned getVirtualFieldSize(IHqlExpression * record);
+ITypeInfo * getHozedKeyType(IHqlExpression * expr);
 IHqlExpression * getHozedKeyValue(IHqlExpression * _value);
 IHqlExpression * getHozedBias(ITypeInfo * type);
 IHqlExpression * convertIndexPhysical2LogicalValue(IHqlExpression * cur, IHqlExpression * physicalSelect, bool allowTranslate);

+ 3 - 3
ecl/hqlcpp/hqlsource.cpp

@@ -501,11 +501,11 @@ static IHqlExpression * createPhysicalIndexRecord(HqlMapTransformer & mapper, IH
             }
             else
             {
-                OwnedHqlExpr hozed = getHozedKeyValue(cur);
-                if (hozed->queryType() == cur->queryType())
+                Owned<ITypeInfo> hozedType = getHozedKeyType(cur);
+                if (hozedType == cur->queryType())
                     newField = LINK(cur);
                 else
-                    newField = createField(cur->queryId(), hozed->getType(), extractFieldAttrs(cur));
+                    newField = createField(cur->queryId(), hozedType.getClear(), extractFieldAttrs(cur));
             }
         }