Просмотр исходного кода

Merge pull request #10708 from ghalliday/issue18805

HPCC-18805 Ensure the LHS of a FETCH is in the serialized format

Reviewed-By: Shamser Ahmed <shamser.ahmed@lexisnexis.co.uk>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 7 лет назад
Родитель
Сommit
66c58ddcac
3 измененных файлов с 20 добавлено и 0 удалено
  1. 12 0
      ecl/hql/hqlopt.cpp
  2. 2 0
      ecl/hqlcpp/hqlcerrors.hpp
  3. 6 0
      ecl/hqlcpp/hqlsource.cpp

+ 12 - 0
ecl/hql/hqlopt.cpp

@@ -3786,6 +3786,18 @@ IHqlExpression * CTreeOptimizer::doCreateTransformed(IHqlExpression * transforme
             node_operator childOp = child->getOperator();
             switch(childOp)
             {
+            //None of the following change the format of the left hand side, and since the fetch is on the underlying
+            //dataset they can all be removed.  If they remain the disk file can be treated as if it is in memory format.
+            case no_preload:
+            case no_nofold:
+            case no_nocombine:
+            case no_dedup:
+            case no_group:
+            case no_compound_diskread:
+            case no_filter:
+            case no_sort:
+            case no_sorted:
+                return replaceChild(transformed, child->queryChild(0));
             case no_newusertable:
                 if (isAggregateDataset(child))
                     break;

+ 2 - 0
ecl/hqlcpp/hqlcerrors.hpp

@@ -225,6 +225,7 @@
 #define HQLERR_DedupBestWithKeepn               4206
 #define HQLERR_HashStoredDuplication            4207
 #define HQLERR_DatafileRequiresSigned           4208
+#define HQLERR_ExpectedFileLhsFetch             4209
 
 //Warnings....
 #define HQLWRN_PersistDataNotLikely             4500
@@ -529,6 +530,7 @@
 #define HQLERR_DedupBestWithKeepn_Text          "DEDUP with BEST does not support KEEP"
 #define HQLERR_HashStoredDuplication_Text       "Inconsistent #%s(%s, %s) and #%s(%s, %s)"
 #define HQLERR_DatafileRequiresSigned_Text      "Insufficient access rights to use datafiles"
+#define HQLERR_ExpectedFileLhsFetch_Text        "The first argument of FETCH must be a disk file (had %s)"
 
 //Warnings.
 #define HQLWRN_CannotRecreateDistribution_Text  "Cannot recreate the distribution for a persistent dataset"

+ 6 - 0
ecl/hqlcpp/hqlsource.cpp

@@ -7253,6 +7253,12 @@ ABoundActivity * HqlCppTranslator::doBuildActivityFetch(BuildCtx & ctx, IHqlExpr
         OwnedHqlExpr simple = replaceFetchInput(expr, null, no_right);
         OwnedHqlExpr transformed = replaceExpression(simple, tableExpr, projected);
         OwnedHqlExpr optSimple = optimizeHqlExpression(queryErrorProcessor(), transformed, optFlags);
+        IHqlExpression * newFetch = queryFetch(optSimple);
+        assertex(newFetch);
+        IHqlExpression * lhs = newFetch->queryChild(0);
+        if (lhs->getOperator() != no_table)
+            throwError1(HQLERR_ExpectedFileLhsFetch, getOpString(lhs->getOperator()));
+
         OwnedHqlExpr optimized = replaceFetchInput(optSimple, fetchRhs, no_right);
         return doBuildActivityFetch(ctx, optimized);
     }