Forráskód Böngészése

HPCC-17018 When normalizing filenames do not lowercase string constants within comparisons

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 8 éve
szülő
commit
8a838021a4
2 módosított fájl, 54 hozzáadás és 2 törlés
  1. 28 2
      ecl/hql/hqlfold.cpp
  2. 26 0
      ecl/regress/issue17018.ecl

+ 28 - 2
ecl/hql/hqlfold.cpp

@@ -7075,15 +7075,41 @@ public:
 
     virtual IHqlExpression * createTransformed(IHqlExpression * expr)
     {
-        switch (expr->getOperator())
+        node_operator op = expr->getOperator();
+        switch (op)
         {
         case no_constant:
             return getLowerCaseConstant(expr);
+        case no_cast:
+        case no_implicitcast:
+        case no_concat:
+        case no_nofold:
+        case no_nocombine:
+        case no_nohoist:
+        case no_alias:
+        case no_globalscope:
+        case no_map:
+        case no_trim:
+            return NewHqlTransformer::createTransformed(expr);
+        case no_if:
+        case no_mapto:
+        case no_case:
+            break;
+        default:
+            return LINK(expr);
         }
-        return NewHqlTransformer::createTransformed(expr);
+
+        HqlExprArray args;
+        args.append(*LINK(expr->queryChild(0)));
+        return completeTransform(expr, args);
     }
 };
 
+/*
+ * The purpose of this function is to normalize a filename as much as possible, so that differences in case for
+ * string constants do not prevent a write to a file, and a subsequent read from the same file to be treated as
+ * the same filenames.  It doesn't aim to be perfect, but to avoid the most common problems.
+ */
 IHqlExpression * lowerCaseHqlExpr(IHqlExpression * expr)
 {
     if (expr->getOperator() == no_constant)

+ 26 - 0
ecl/regress/issue17018.ecl

@@ -0,0 +1,26 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2017 HPCC Systems®.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+string option := 'Y' : stored('option');
+
+filename := IF(option = 'Y', 'hello', 'goodbye');
+
+ds := DATASET(filename, { unsigned id } , THOR);
+
+p := ds : PERSIST('ds');
+
+OUTPUT(COUNT(p));