浏览代码

HPCC-8878 Improve the error message if MAXLENGTH is too small

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 12 年之前
父节点
当前提交
9615f8692e
共有 3 个文件被更改,包括 31 次插入1 次删除
  1. 3 0
      ecl/hqlcpp/hqlcerrors.hpp
  2. 3 1
      ecl/hqlcpp/hqlhtcpp.cpp
  3. 25 0
      ecl/regress/maxlength6.ecl

+ 3 - 0
ecl/hqlcpp/hqlcerrors.hpp

@@ -207,6 +207,7 @@
 #define HQLERR_KeyedJoinNoRightIndex_X          4185
 #define HQLERR_ScalarOutputWithinApply          4186
 #define HQLERR_EmbeddedTypeNotSupported_X       4187
+#define HQLERR_MaximumSizeLessThanMinimum_XY    4188
 
 //Warnings....
 #define HQLWRN_PersistDataNotLikely             4500
@@ -486,6 +487,8 @@
 #define HQLERR_ScalarOutputWithinApply_Text     "A scalar output within an APPLY is undefined and may fail.  Use OUTPUT(dataset,EXTEND) instead."
 #define HQLERR_KeyedJoinNoRightIndex_X_Text     "Right dataset (%s) for a keyed join isn't a key"
 #define HQLERR_EmbeddedTypeNotSupported_X_Text  "Type %s not supported for embedded/external scripts"
+#define HQLERR_MaximumSizeLessThanMinimum_XY_Text "Maximum size (%u) for this record is lower than the minimum (%u)"
+
 //Warnings.
 #define HQLWRN_CannotRecreateDistribution_Text  "Cannot recreate the distribution for a persistent dataset"
 #define HQLWRN_RecursiveDependendencies_Text    "Recursive filename dependency"

+ 3 - 1
ecl/hqlcpp/hqlhtcpp.cpp

@@ -4129,7 +4129,9 @@ void HqlCppTranslator::buildMetaInfo(MetaInstance & instance)
             {
                 unsigned minSize = getMinRecordSize(record);
                 unsigned maxLength = map->getMaxSize();
-                assertex(maxLength >= minSize);
+                if (maxLength < minSize)
+                    reportError(queryLocation(record), ECODETEXT(HQLERR_MaximumSizeLessThanMinimum_XY), maxLength, minSize);
+                    
 #ifdef _DEBUG
                 //Paranoia check to ensure the two methods agree.
                 unsigned calcMinSize = map->getTotalMinimumSize();

+ 25 - 0
ecl/regress/maxlength6.ecl

@@ -0,0 +1,25 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2012 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.
+############################################################################## */
+
+//Check the maximum length is never less than the minimum
+r1 := RECORD,MAXLENGTH(10)
+    string20 f1;
+    string f2;
+END;
+  
+ds := dataset('d1', r1, thor);
+output(ds);