Browse Source

HPCC-15246 Improve error message passing a dataset to a datarow

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 9 years ago
parent
commit
af83e943f4
2 changed files with 10 additions and 5 deletions
  1. 2 0
      ecl/hqlcpp/hqlcerrors.hpp
  2. 8 5
      ecl/hqlcpp/hqlcpp.cpp

+ 2 - 0
ecl/hqlcpp/hqlcerrors.hpp

@@ -222,6 +222,7 @@
 #define HQLERR_AggregateDynamicOffset           4202
 #define HQLERR_ServiceDefinitionNotAllowed      4203
 #define HQLERR_BodyNotAllowedWithInline         4204
+#define HQLERR_DatasetPassedToRowArg            4205
 
 //Warnings....
 #define HQLWRN_PersistDataNotLikely             4500
@@ -519,6 +520,7 @@
 #define HQLERR_AggregateDynamicOffset_Text      "Aggregate assignment to '%s' cannot follow variable size aggregate"
 #define HQLERR_ServiceDefinitionNotAllowed_Text "Insufficient access rights to use SERVICE"
 #define HQLERR_BodyNotAllowedWithInline_Text    "#body not supported with INLINE attribute"
+#define HQLERR_DatasetPassedToRowArg_Text       "Cannot pass a dataset to row argument %s"
 
 //Warnings.
 #define HQLWRN_CannotRecreateDistribution_Text  "Cannot recreate the distribution for a persistent dataset"

+ 8 - 5
ecl/hqlcpp/hqlcpp.cpp

@@ -5559,7 +5559,7 @@ void HqlCppTranslator::doBuildAssignCatch(BuildCtx & ctx, const CHqlBoundTarget
 //---------------------------------------------------------------------------
 //-- no_externalcall --
 
-IHqlExpression * getCastParameter(IHqlExpression * curParam, ITypeInfo * argType)
+static IHqlExpression * getCastParameter(IHqlExpression * curParam, ITypeInfo * argType, const char * argName)
 {
     type_t atc = argType->getTypeCode();
 
@@ -5580,7 +5580,7 @@ IHqlExpression * getCastParameter(IHqlExpression * curParam, ITypeInfo * argType
 
     ITypeInfo * paramType = curParam->queryType();
     type_t ptc = paramType->getTypeCode();
-    if ((atc != ptc) && !(atc == type_row && ptc == type_table))
+    if (atc != ptc)
     {
         switch (atc)
         {
@@ -5593,8 +5593,11 @@ IHqlExpression * getCastParameter(IHqlExpression * curParam, ITypeInfo * argType
                 ((ptc == type_varstring) && (argType->queryCharset() == paramType->queryCharset())))
                 return LINK(curParam);
             break;
-        case type_dictionary:
         case type_row:
+            if (curParam->isDataset())
+                throwError1(HQLERR_DatasetPassedToRowArg, argName);
+            // fallthrough
+        case type_dictionary:
         case type_table:
         case type_groupedtable:
             {
@@ -6026,7 +6029,7 @@ void HqlCppTranslator::doBuildCall(BuildCtx & ctx, const CHqlBoundTarget * tgt,
         IHqlExpression * curArg = formals->queryChild(arg);
         ITypeInfo * argType = curArg->queryType();
 
-        OwnedHqlExpr castParam = getCastParameter(curParam, argType);
+        OwnedHqlExpr castParam = getCastParameter(curParam, argType, curArg->queryId()->queryStr());
 
         type_t atc = argType->getTypeCode();
         switch (atc)
@@ -7041,7 +7044,7 @@ void HqlCppTranslator::buildConcatFArgs(HqlExprArray & args, BuildCtx & ctx, con
     ForEachItemIn(idx, values)
     {
         IHqlExpression * cur = &values.item(idx);
-        OwnedHqlExpr value = getCastParameter(cur, argType);
+        OwnedHqlExpr value = getCastParameter(cur, argType, "");
         CHqlBoundExpr bound;
         buildCachedExpr(ctx, value, bound);