Kaynağa Gözat

Merge branch 'candidate-5.2.0'

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>

Conflicts:
	common/workunit/workunit.cpp
	common/workunit/workunit.hpp
Gavin Halliday 10 yıl önce
ebeveyn
işleme
7e20166c68

+ 48 - 4
common/workunit/workunit.cpp

@@ -912,7 +912,7 @@ const char * getWorkunitStateStr(WUState state)
     return states[state].str; // MORE - should be using getEnumText, or need to take steps to ensure values remain contiguous and in order.
 }
 
-const char *getEnumText(int value, mapEnums *map)
+const char *getEnumText(int value, const mapEnums *map)
 {
     const char *defval = map->str;
     while (map->str)
@@ -925,7 +925,7 @@ const char *getEnumText(int value, mapEnums *map)
     return defval;
 }
 
-void setEnum(IPropertyTree *p, const char *propname, int value, mapEnums *map)
+void setEnum(IPropertyTree *p, const char *propname, int value, const mapEnums *map)
 {
     const char *defval = map->str;
     while (map->str)
@@ -941,7 +941,7 @@ void setEnum(IPropertyTree *p, const char *propname, int value, mapEnums *map)
     p->setProp(propname, defval);
 }
 
-static int getEnum(const char *v, mapEnums *map)
+static int getEnum(const char *v, const mapEnums *map)
 {
     if (v)
     {
@@ -956,7 +956,7 @@ static int getEnum(const char *v, mapEnums *map)
     return 0;
 }
 
-static int getEnum(const IPropertyTree *p, const char *propname, mapEnums *map)
+static int getEnum(const IPropertyTree *p, const char *propname, const mapEnums *map)
 {
     return getEnum(p->queryProp(propname),map);
 }
@@ -1319,6 +1319,8 @@ public:
             { return c->getSnapshot(str); } 
     virtual const char *queryUser() const
             { return c->queryUser(); }
+    virtual ErrorSeverity getWarningSeverity(unsigned code, ErrorSeverity defaultSeverity) const
+            { return c->getWarningSeverity(code, defaultSeverity); }
     virtual IStringVal & getWuScope(IStringVal & str) const
             { return c->getWuScope(str); }
     virtual const char *queryWuid() const
@@ -1497,6 +1499,8 @@ public:
 
     virtual void setSnapshot(const char * value)
             { c->setSnapshot(value); }
+    virtual void setWarningSeverity(unsigned code, ErrorSeverity severity)
+            { c->setWarningSeverity(code, severity); }
     virtual void setTimeScheduled(const IJlibDateTime &val)
             { c->setTimeScheduled(val); }
     virtual void setDebugAgentListenerPort(unsigned port)
@@ -4753,6 +4757,45 @@ void CLocalWorkUnit::setSnapshot(const char * val)
     p->setProp("SNAPSHOT", val);
 }
 
+const static mapEnums warningSeverityMap[] =
+{
+    { SeverityIgnore, "ignore" },
+    { SeverityInfo, "info" },
+    { SeverityWarning, "warning" },
+    { SeverityError, "error" },
+    { SeverityFatal, "fatal" },
+    { SeverityUnknown, NULL }
+};
+
+
+ErrorSeverity CLocalWorkUnit::getWarningSeverity(unsigned code, ErrorSeverity defaultSeverity) const
+{
+    StringBuffer xpath;
+    xpath.append("OnWarnings/OnWarning[@code='").append(code).append("']");
+    CriticalBlock block(crit);
+    IPropertyTree * mapping = p->queryPropTree(xpath);
+    if (mapping)
+        return (ErrorSeverity) getEnum(mapping, "@severity", warningSeverityMap);
+    return defaultSeverity;
+}
+
+void CLocalWorkUnit::setWarningSeverity(unsigned code, ErrorSeverity severity)
+{
+    StringBuffer xpath;
+    xpath.append("OnWarnings/OnWarning[@code='").append(code).append("']");
+
+    CriticalBlock block(crit);
+    IPropertyTree * mapping = p->queryPropTree(xpath);
+    if (!mapping)
+    {
+        IPropertyTree * onWarnings = ensurePTree(p, "OnWarnings");
+        mapping = onWarnings->addPropTree("OnWarning", createPTree());
+        mapping->setPropInt("@code", code);
+    }
+
+    setEnum(mapping, "@severity", severity, warningSeverityMap);
+}
+
 static int comparePropTrees(IInterface * const *ll, IInterface * const *rr)
 {
     IPropertyTree *l = (IPropertyTree *) *ll;
@@ -4857,6 +4900,7 @@ void CLocalWorkUnit::copyWorkUnit(IConstWorkUnit *cached, bool all)
         else
             p->setPropTree("Debug", LINK(pt));
     }
+    copyTree(p, fromP, "OnWarnings");
     copyTree(p, fromP, "Plugins");
     copyTree(p, fromP, "Libraries");
     copyTree(p, fromP, "Results");

+ 2 - 0
common/workunit/workunit.hpp

@@ -1060,6 +1060,7 @@ interface IConstWorkUnit : extends IConstWorkUnitInfo
     virtual bool getCloneable() const = 0;
     virtual IUserDescriptor * queryUserDescriptor() const = 0;
     virtual IStringVal & getSnapshot(IStringVal & str) const = 0;
+    virtual ErrorSeverity getWarningSeverity(unsigned code, ErrorSeverity defaultSeverity) const = 0;
     virtual IPropertyTreeIterator & getFilesReadIterator() const = 0;
     virtual void protect(bool protectMode) = 0;
     virtual IStringVal & getAllowedClusters(IStringVal & str) const = 0;
@@ -1114,6 +1115,7 @@ interface IWorkUnit : extends IConstWorkUnit
     virtual void setUser(const char * value) = 0;
     virtual void setWuScope(const char * value) = 0;
     virtual void setSnapshot(const char * value) = 0;
+    virtual void setWarningSeverity(unsigned code, ErrorSeverity severity) = 0;
     virtual IWorkflowItemIterator * updateWorkflowItems() = 0;
     virtual void syncRuntimeWorkflow(IWorkflowItemArray * array) = 0;
     virtual IWorkflowItem * addWorkflowItem(unsigned wfid, WFType type, WFMode mode, unsigned success, unsigned failure, unsigned recovery, unsigned retriesAllowed, unsigned contingencyFor) = 0;

+ 2 - 0
common/workunit/workunit.ipp

@@ -279,6 +279,7 @@ public:
     virtual IStringIterator *getProcesses(const char *type) const;
     virtual IPropertyTreeIterator* getProcesses(const char *type, const char *instance) const;
     virtual IStringVal & getSnapshot(IStringVal & str) const;
+    virtual ErrorSeverity getWarningSeverity(unsigned code, ErrorSeverity defaultSeverity) const;
 
     virtual const char *queryUser() const;
     virtual IStringVal & getWuScope(IStringVal & str) const;
@@ -338,6 +339,7 @@ public:
     void setTracingValue(const char * propname, const char * value);
     void setTracingValueInt(const char * propname, int value);
     void setUser(const char * value);
+    void setWarningSeverity(unsigned code, ErrorSeverity severity);
     void setWuScope(const char * value);
     void setSnapshot(const char * value);
     void setDebugAgentListenerPort(unsigned port);

+ 7 - 0
ecl/hql/hqlerror.hpp

@@ -23,12 +23,14 @@
 
 #define HQLERR_ErrorAlreadyReported             4799            // special case...
 
+interface IWorkUnit;
 interface HQL_API IErrorReceiver : public IInterface
 {
     virtual void report(IError* error) = 0;
     virtual IError * mapError(IError * error) = 0;
     virtual size32_t errCount() = 0;
     virtual size32_t warnCount() = 0;
+    virtual void exportMappings(IWorkUnit * wu) const = 0;
 
     //global helper functions
     void reportError(int errNo, const char *msg, const char *filename, int lineno, int column, int pos);
@@ -46,6 +48,7 @@ public:
     ErrorReceiverSink() { errs = warns = 0; }
 
     virtual IError * mapError(IError * error) { return LINK(error); }
+    virtual void exportMappings(IWorkUnit * wu) const { }
     virtual void report(IError* err);
     virtual size32_t errCount() { return errs; }
     virtual size32_t warnCount() { return warns; }
@@ -78,6 +81,10 @@ public:
     {
         return prevErrorProcessor->warnCount();
     }
+    virtual void exportMappings(IWorkUnit * wu) const
+    {
+        prevErrorProcessor->exportMappings(wu);
+    }
 
 protected:
     Linked<IErrorReceiver> prevErrorProcessor;

+ 1 - 0
ecl/hql/hqlgram.hpp

@@ -590,6 +590,7 @@ public:
     virtual void reportError(int errNo, const char *msg, const char *filename=NULL, int lineno=0, int column=0, int pos=0);
     virtual void report(IError * error);
     virtual IError * mapError(IError * error);
+    virtual void exportMappings(IWorkUnit * wu) const;
     void reportWarning(WarnErrorCategory category, int warnNo, const char *msg, const char *filename=NULL, int lineno=0, int column=0, int pos=0);
     virtual size32_t errCount();
     virtual size32_t warnCount();

+ 5 - 0
ecl/hql/hqlgram2.cpp

@@ -5956,6 +5956,11 @@ IError * HqlGram::mapError(IError * error)
     return errorHandler->mapError(error);
 }
 
+void HqlGram::exportMappings(IWorkUnit * wu) const
+{
+    return errorHandler->exportMappings(wu);
+}
+
 void HqlGram::report(IError* error)
 {
     if (errorHandler && !errorDisabled)

+ 13 - 0
ecl/hql/hqlutil.cpp

@@ -6715,6 +6715,19 @@ void ErrorSeverityMapper::restoreState(const ErrorSeverityMapperState & saved)
     activeSymbol = saved.symbol;
 }
 
+void ErrorSeverityMapper::exportMappings(IWorkUnit * wu) const
+{
+    IndirectErrorReceiver::exportMappings(wu);
+
+    const unsigned max = severityMappings.ordinality();
+    for (unsigned i=firstActiveMapping; i < max; i++)
+    {
+        IHqlExpression & cur = severityMappings.item(i);
+        wu->setWarningSeverity(getIntValue(cur.queryChild(0)), getCheckSeverity(cur.queryChild(1)->queryName()));
+    }
+}
+
+
 IError * ErrorSeverityMapper::mapError(IError * error)
 {
     //An error that is fatal cannot be mapped.

+ 1 - 0
ecl/hql/hqlutil.hpp

@@ -556,6 +556,7 @@ public:
     ErrorSeverityMapper(IErrorReceiver & errorProcessor);
 
     virtual IError * mapError(IError * error);
+    virtual void exportMappings(IWorkUnit * wu) const;
 
     bool addCommandLineMapping(const char * mapping);
     bool addMapping(const char * category, const char * value);

+ 4 - 0
ecl/hql/hqlwuerr.cpp

@@ -109,6 +109,10 @@ public:
         assertex(mappedError == error); // should not expect any mapping below a compound.
         return mappedError.getClear();
     }
+    virtual void exportMappings(IWorkUnit * wu) const
+    {
+        // should not expect any mapping below a compound.
+    }
     virtual void report(IError* err)
     {
         primary->report(err);

+ 1 - 0
ecl/hql/hqlwuerr.hpp

@@ -27,6 +27,7 @@ public:
     IMPLEMENT_IINTERFACE;
 
     virtual IError * mapError(IError * error);
+    virtual void exportMappings(IWorkUnit * wu) const { }
     virtual void report(IError*);
     virtual size32_t errCount();
     virtual size32_t warnCount();

+ 5 - 0
ecl/hqlcpp/hqlcpp.cpp

@@ -1868,6 +1868,11 @@ unsigned HqlCppTranslator::getOptimizeFlags() const
 }
 
 
+void HqlCppTranslator::exportWarningMappings()
+{
+    globalOnWarnings->exportMappings(wu());
+}
+
 void HqlCppTranslator::overrideOptionsForLibrary()
 {
     options.workunitTemporaries = false;

+ 1 - 0
ecl/hqlcpp/hqlcpp.ipp

@@ -1905,6 +1905,7 @@ public:
     void checkNormalized(BuildCtx & ctx, IHqlExpression * expr);
 
     void checkAmbiguousRollupCondition(IHqlExpression * expr);
+    void exportWarningMappings();
 
 protected:
     HqlCppInstance *    code;

+ 1 - 0
ecl/hqlcpp/hqlecl.cpp

@@ -372,6 +372,7 @@ bool HqlDllGenerator::generateCode(HqlQueryContext & query)
         cycle_t startCycles = get_cycles_now();
         HqlCppTranslator translator(errs, wuname, code, targetClusterType, ctxCallback);
         processMetaCommands(translator, wu, query, ctxCallback);
+        translator.exportWarningMappings();
 
         if (wu->getDebugValueBool("generateFullFieldUsage", false))
         {

+ 13 - 0
ecl/regress/issue12314.eclxml

@@ -0,0 +1,13 @@
+<Archive legacyImport="0"
+         legacyWhen="0">
+ <Query attributePath="_local_directory_.temp"/>
+ <OnWarning name="1006" value="ignore"/>
+ <OnWarning name="12345" value="ignore"/>
+ <Module key="_local_directory_" name="_local_directory_">
+  <Attribute key="temp" name="temp" sourcePath="temp.ecl">
+   case(0,&apos;default&apos;);&#10;&#10;&#10;
+   #onwarning (12345, error); //overrides the setting in the archive
+   #onwarning (54321, log);
+  </Attribute>
+ </Module>
+</Archive>