Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/candidate-3.10.2' into candidate-3.10.x

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 12 gadi atpakaļ
vecāks
revīzija
9505a6cdf5

+ 3 - 0
docs/ECLLanguageReference/ECLR-includer.xml

@@ -488,6 +488,9 @@
     <xi:include href="ECLLanguageReference/ECLR_mods/BltInFunc-HAVING.xml" xpointer="element(/1)"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />
 
+    <xi:include href="ECLLanguageReference/ECLR_mods/BltInFunc-HTTPCALL.xml" xpointer="element(/1)"
+                xmlns:xi="http://www.w3.org/2001/XInclude" />
+
     <xi:include href="ECLLanguageReference/ECLR_mods/BltInFunc-IF.xml" xpointer="element(/1)"
                 xmlns:xi="http://www.w3.org/2001/XInclude" />
 

+ 163 - 0
docs/ECLLanguageReference/ECLR_mods/BltInFunc-HTTPCALL.xml

@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<sect1 id="HTTPCALL">
+  <title>HTTPCALL<indexterm>
+      <primary>HTTPCALL</primary>
+    </indexterm></title>
+
+  <para><emphasis>result</emphasis><emphasis role="bold"> :=
+  HTTPCALL<indexterm>
+      <primary>HTTPCALL Function</primary>
+    </indexterm>( </emphasis><emphasis> url, httpmethod, responsemimetype,
+  outstructure</emphasis> <emphasis role="bold">[</emphasis><emphasis>,
+  options </emphasis><emphasis role="bold"> ] );</emphasis></para>
+
+  <para><informaltable colsep="0" frame="none" rowsep="0">
+      <tgroup cols="2">
+        <colspec colwidth="121.70pt" />
+
+        <colspec />
+
+        <tbody>
+          <row>
+            <entry><emphasis>result</emphasis></entry>
+
+            <entry>The definition name for the resulting recordset.</entry>
+          </row>
+
+          <row>
+            <entry><emphasis>url</emphasis></entry>
+
+            <entry>A string containing the URL that hosts the service to
+            invoke. This may contain parameters to the service.</entry>
+          </row>
+
+          <row>
+            <entry><emphasis>httpmethod</emphasis></entry>
+
+            <entry>A string containing the HTTP Method to invoke. Valid
+            methods are: "GET"</entry>
+          </row>
+
+          <row>
+            <entry><emphasis>responsemimetype</emphasis></entry>
+
+            <entry>A string containing the Response MIME type to use. Valid
+            types are: "text/xml"</entry>
+          </row>
+
+          <row>
+            <entry><emphasis>outstructure</emphasis></entry>
+
+            <entry>A RECORD structure containing the output field definitions.
+            For an XML-based <emphasis>responsemimetype</emphasis> these
+            should use XPATH to specify the exact data path.</entry>
+          </row>
+
+          <row>
+            <entry><emphasis>options</emphasis></entry>
+
+            <entry>A comma-delimited list of optional specifications from the
+            list below.</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </informaltable></para>
+
+  <para><emphasis role="bold">HTTPCALL<indexterm>
+      <primary>HTTPCALL Options</primary>
+    </indexterm> </emphasis>is a function that calls a REST service.</para>
+
+  <para>Valid <emphasis>options</emphasis> are:</para>
+
+  <para><informaltable colsep="0" frame="none" rowsep="0">
+      <tgroup cols="2">
+        <colspec colwidth="135.80pt" />
+
+        <colspec />
+
+        <tbody>
+          <row>
+            <entry><emphasis role="bold">RETRY</emphasis><indexterm>
+                <primary>RETRY</primary>
+              </indexterm>(<emphasis>count</emphasis>)</entry>
+
+            <entry>Specifies re-attempting the call count number of times if
+            non-fatal errors occur. If omitted, the default is three
+            (3).</entry>
+          </row>
+
+          <row>
+            <entry><emphasis role="bold">TIMEOUT</emphasis><indexterm>
+                <primary>TIMEOUT</primary>
+              </indexterm>(<emphasis>period</emphasis>)</entry>
+
+            <entry>Specifies the amount of time to attempt the read before
+            failing. The <emphasis>period</emphasis> is a real number where
+            the integer portion specifies seconds. Setting to zero (0)
+            indicates waiting forever. If omitted, the default is three
+            hundred (300).</entry>
+          </row>
+
+          <row>
+            <entry><emphasis role="bold">TIMELIMIT</emphasis><indexterm>
+                <primary>TIMELIMIT</primary>
+              </indexterm>(<emphasis>period</emphasis>)</entry>
+
+            <entry>Specifies the total amount of time allowed for the
+            HTTPCALL. The <emphasis>period</emphasis> is a real number where
+            the integer portion specifies seconds. If omitted, the default is
+            zero (0) indicating no limit.</entry>
+          </row>
+
+          <row>
+            <entry><emphasis role="bold">XPATH<indexterm>
+                <primary>XPATH</primary>
+              </indexterm></emphasis>(<emphasis>xpath</emphasis>)</entry>
+
+            <entry>Specifies the path used to access rows in the output. If
+            omitted, the default is:
+            'serviceResponse/Results/Result/Dataset/Row'.</entry>
+          </row>
+
+          <row>
+            <entry><emphasis role="bold">ONFAIL<indexterm>
+                <primary>ONFAIL</primary>
+              </indexterm></emphasis>(<emphasis>transform</emphasis>)</entry>
+
+            <entry>Specifies either the transform function to call if the
+            service fails for a particular record, or the keyword SKIP. The
+            TRANSFORM function must produce a <emphasis>resultype</emphasis>
+            the same as the <emphasis>outstructure</emphasis> and may use
+            FAILCODE and/or FAILMESSAGE<indexterm>
+                <primary>FAILMESSAGE</primary>
+              </indexterm> to provide details of the failure.</entry>
+          </row>
+
+          <row>
+            <entry><emphasis role="bold">TRIM<indexterm>
+                <primary>TRIM</primary>
+              </indexterm></emphasis></entry>
+
+            <entry>Specifies all trailing spaces are removed from strings
+            before output.</entry>
+          </row>
+        </tbody>
+      </tgroup>
+    </informaltable></para>
+
+  <para>Example:</para>
+
+  <programlisting>worldBankSource := RECORD
+  STRING name {XPATH('name')}
+END;
+
+OutRec1 := RECORD
+  DATASET(worldBankSource) Fred{XPATH('/source')};
+END;
+
+raw := HTTPCALL('http://api.worldbank.org/sources', 'GET', 'text/xml', OutRec1);
+
+OUTPUT(raw);</programlisting>
+</sect1>

+ 3 - 3
docs/common/Version.xml

@@ -5,11 +5,11 @@
   <chapterinfo>
     <date id="DateVer">DEVELOPER NON-GENERATED VERSION</date>
 
-    <releaseinfo id="FooterInfo">© 2012 HPCC Systems. All rights
+    <releaseinfo id="FooterInfo">© 2013 HPCC Systems. All rights
     reserved</releaseinfo>
 
     <copyright id="Copyright">
-      <year>2012 HPCC Systems. All rights reserved</year>
+      <year>2013 HPCC Systems. All rights reserved</year>
     </copyright>
   </chapterinfo>
 
@@ -23,7 +23,7 @@
     serve one purpose and that is to store the chapterinfo the above sections
     that are being used by several other documents.</para>
 
-    <para id="CHMVer">2012 Version 3.x</para>
+    <para id="CHMVer">2013 Version 3.x</para>
 
     <para>The following line is the code to be put into the document you wish
     to include the above version info in:</para>

+ 4 - 4
docs/common/Version.xml.in

@@ -3,13 +3,13 @@
 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
 <chapter>
   <chapterinfo>
-    <date id="DateVer">2012 Version ${DOC_VERSION}</date>
+    <date id="DateVer">2013 Version ${DOC_VERSION}</date>
 
-    <releaseinfo id="FooterInfo">© 2012 HPCC Systems. All rights
+    <releaseinfo id="FooterInfo">© 2013 HPCC Systems. All rights
     reserved</releaseinfo>
 
     <copyright id="Copyright">
-      <year>2012 HPCC Systems. All rights reserved</year>
+      <year>2013 HPCC Systems. All rights reserved</year>
     </copyright>
   </chapterinfo>
 
@@ -23,7 +23,7 @@
     serve one purpose and that is to store the chapterinfo the above sections
     that are being used by several other documents.</para>
 
-    <para id="CHMVer">2012 Version ${DOC_VERSION}</para>
+    <para id="CHMVer">2013 Version ${DOC_VERSION}</para>
 
     <para>The following line is the code to be put into the document you wish
     to include the above version info in:</para>

+ 18 - 1
ecl/hqlcpp/hqlsource.cpp

@@ -1359,7 +1359,24 @@ void SourceBuilder::buildTransformElements(BuildCtx & ctx, IHqlExpression * expr
                     if (!returnIfFilterFails)
                         translator.buildFilter(ctx, test);
                     else
-                        translator.buildFilteredReturn(ctx, test, failedFilterValue);
+                    {
+                        LinkedHqlExpr mismatchReturnValue = failedFilterValue;
+                        //If the output row has already been generated, then returning at this point will leak any
+                        //child datasets. To avoid that we explicitly call the destructor on the output row.
+                        if (recordRequiresDestructor(expr->queryRecord()))
+                        {
+                            if (lastTransformer && lastTransformer->queryNormalizedSelector() == expr->queryNormalizedSelector())
+                            {
+                                StringBuffer s;
+                                translator.buildMetaForRecord(s, expr->queryRecord());
+                                s.append(".destruct(crSelf.row())");
+                                OwnedHqlExpr cleanupAction = createQuoted(s.str(), makeVoidType());
+                                //Create a compound expression (destroy-old, return-value)
+                                mismatchReturnValue.setown(createCompound(LINK(cleanupAction), LINK(mismatchReturnValue)));
+                            }
+                        }
+                        translator.buildFilteredReturn(ctx, test, mismatchReturnValue);
+                    }
                 }
             }
         }

+ 1 - 1
roxie/ccd/ccdserver.cpp

@@ -32445,7 +32445,7 @@ protected:
 
     void init()
     {
-        package.setown(createPackage(NULL, NULL));
+        package.setown(createRoxiePackage(NULL, NULL));
         ctx.setown(createSlaveContext(NULL, logctx, 0, 50*1024*1024, NULL));
         queryDll.setown(createExeQueryDll("roxie"));
         queryFactory.setown(createServerQueryFactory("test", queryDll.getLink(), *package, NULL));