Prechádzať zdrojové kódy

HPCC-13429 Generate a compile error for scalar output inside a child query

It makes little sense to output a scalar inside a child query - which
iteration of the child query should generate the result?  Report it as
an error, but allow it to be downgraded to a warning via #ONWARNING.

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 10 rokov pred
rodič
commit
8709a991c2
2 zmenil súbory, kde vykonal 16 pridanie a 0 odobranie
  1. 2 0
      ecl/hqlcpp/hqlcerrors.hpp
  2. 14 0
      ecl/hqlcpp/hqlhtcpp.cpp

+ 2 - 0
ecl/hqlcpp/hqlcerrors.hpp

@@ -263,6 +263,7 @@
 #define HQLWRN_NoThorContextDependent           4544
 #define HQLWRN_OnlyLocalMergeJoin               4545
 #define HQLWRN_WorkflowDependParameter          4546
+#define HQLWRN_OutputScalarInsideChildQuery     4547
 
 //Temporary errors
 #define HQLERR_OrderOnVarlengthStrings          4601
@@ -542,6 +543,7 @@
 #define HQLWRN_NoThorContextDependent_Text      "NOTHOR expression%s appears to access a parent dataset - this may cause a dataset not active error"
 #define HQLWRN_OnlyLocalMergeJoin_Text          "Only LOCAL versions of %s are currently supported on THOR"
 #define HQLWRN_WorkflowDependParameter_Text     "Workflow action %s appears to be dependent upon a parameter"
+#define HQLWRN_OutputScalarInsideChildQuery_Text "Output(%s) of single value inside a child query has undefined behaviour"
 
 #define HQLERR_DistributionVariableLengthX_Text "DISTRIBUTION does not support variable length field '%s'"
 #define HQLERR_DistributionUnsupportedTypeXX_Text "DISTRIBUTION does not support field '%s' with type %s"

+ 14 - 0
ecl/hqlcpp/hqlhtcpp.cpp

@@ -7635,6 +7635,13 @@ void HqlCppTranslator::doBuildStmtSetResult(BuildCtx & ctx, IHqlExpression * exp
         graphLabel.set(text.str());
     }
 
+    if (insideChildQuery(ctx))
+    {
+        StringBuffer description;
+        getStoredDescription(description, seq, name, true);
+        reportWarning(CategoryUnusual, SeverityError, queryLocation(expr), ECODETEXT(HQLWRN_OutputScalarInsideChildQuery), description.str());
+    }
+
     if (cluster)
         pushCluster(subctx, cluster->queryChild(0));
 
@@ -17852,6 +17859,13 @@ ABoundActivity * HqlCppTranslator::doBuildActivitySetResult(BuildCtx & ctx, IHql
 
     buildInstancePrefix(instance);
 
+    if (insideChildQuery(ctx))
+    {
+        StringBuffer description;
+        getStoredDescription(description, sequence, name, true);
+        reportWarning(CategoryUnusual, SeverityError, queryLocation(expr), ECODETEXT(HQLWRN_OutputScalarInsideChildQuery), description.str());
+    }
+
     noteResultDefined(ctx, instance, sequence, name, isRoot);
     if (attribute->isDatarow())
         attribute.setown(::ensureSerialized(attribute, diskAtom));