Author: shawkins
Date: 2010-09-01 11:38:19 -0400 (Wed, 01 Sep 2010)
New Revision: 2513
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
Log:
TEIID-1234 fixing parameter order
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2010-08-31
22:50:54 UTC (rev 2512)
+++
branches/7.1.x/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2010-09-01
15:38:19 UTC (rev 2513)
@@ -258,7 +258,7 @@
* @return Ordered list of SingleElementSymbol
*/
public List getProjectedSymbols(){
- List result = new ArrayList();
+ List<ElementSymbol> result = new ArrayList<ElementSymbol>();
//add result set columns
List rsColumns = getResultSetColumns();
result.addAll(rsColumns);
@@ -266,24 +266,15 @@
return result;
}
//add out/inout parameter symbols
- Iterator iter = mapOfParameters.values().iterator();
- while(iter.hasNext()){
- SPParameter parameter = (SPParameter)iter.next();
- if(parameter.getParameterType() == ParameterInfo.INOUT || parameter.getParameterType()
== ParameterInfo.OUT){
+ for (SPParameter parameter : mapOfParameters.values()) {
+ if(parameter.getParameterType() == ParameterInfo.RETURN_VALUE){
ElementSymbol symbol = parameter.getParameterSymbol();
symbol.setGroupSymbol(getGroup());
- result.add(symbol);
- }
- }
- //add return parameter
- iter = mapOfParameters.values().iterator();
- while(iter.hasNext()){
- SPParameter parameter = (SPParameter)iter.next();
- if(parameter.getParameterType() == ParameterInfo.RETURN_VALUE){
+ result.add(0, symbol);
+ } else if(parameter.getParameterType() == ParameterInfo.INOUT ||
parameter.getParameterType() == ParameterInfo.OUT){
ElementSymbol symbol = parameter.getParameterSymbol();
symbol.setGroupSymbol(getGroup());
- result.add(symbol);
- break;
+ result.add(symbol);
}
}
return result;
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-08-31
22:50:54 UTC (rev 2512)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-09-01
15:38:19 UTC (rev 2513)
@@ -96,6 +96,7 @@
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.FakeMetadataObject;
import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.query.util.ErrorMessageKeys;
@@ -3023,4 +3024,11 @@
helpResolveUpdateProcedure(procedure, userUpdateStr);
}
+ //return should be first, then out
+ @Test public void testParamOrder() {
+ Query resolvedQuery = (Query)helpResolve("SELECT * FROM (exec
pm4.spRetOut()) as a", RealMetadataFactory.exampleBQTCached(), null); //$NON-NLS-1$
+
+ assertEquals("A.ret",
resolvedQuery.getProjectedSymbols().get(0).getName());
+ }
+
}
\ No newline at end of file
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-08-31
22:50:54 UTC (rev 2512)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-09-01
15:38:19 UTC (rev 2513)
@@ -2661,119 +2661,6 @@
return facade;
}
- public static VDBMetaData exampleXQueryTransformationsVDB() {
- VDBMetaData vdb = new VDBMetaData();
- vdb.setName("exampleXQueryTransformations");
- vdb.setVersion(1);
- vdb.addModel(createModel("m", true));
- return vdb;
- }
-
- public static FakeMetadataFacade exampleXQueryTransformations() {
- FakeMetadataObject model =
FakeMetadataFactory.createPhysicalModel("m");//$NON-NLS-1$
-
- // Simple xquery view - no inputs, calls out to source docs
- FakeMetadataObject xmlrs =
FakeMetadataFactory.createResultSet("m.xprocrs", model, new String[] {
"xml" }, new String[] { DataTypeManager.DefaultDataTypes.XML }); //$NON-NLS-1$
//$NON-NLS-2$
- FakeMetadataObject xml1out = FakeMetadataFactory.createParameter("rs",
1, ParameterInfo.RESULT_SET, null, xmlrs); //$NON-NLS-1$
- QueryNode xproct1 = new QueryNode("m.xproc1",
"<test></test>"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject xproc1 =
FakeMetadataFactory.createVirtualProcedure("m.xproc1", model, Arrays.asList(new
FakeMetadataObject[] { xml1out }), xproct1); //$NON-NLS-1$
-
- // XQuery view: call out to proc returning xml
- QueryNode xproct2 = new QueryNode("m.xproc2", "doc(\"EXEC
m.xproc1()\")"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject xproc2 =
FakeMetadataFactory.createVirtualProcedure("m.xproc2", model, Arrays.asList(new
FakeMetadataObject[] { xml1out }), xproct2); //$NON-NLS-1$
-
- // XQuery view with xml input arg
- FakeMetadataObject xml3in =
FakeMetadataFactory.createParameter("input", 2, ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.XML, null); //$NON-NLS-1$
- QueryNode xproct3 = new QueryNode("m.xproc3", //$NON-NLS-1$
- "declare variable $INPUT as node()
external; " + //$NON-NLS-1$
- "<wrap>{ $INPUT
}</wrap>"); //$NON-NLS-1$
- FakeMetadataObject xproc3 =
FakeMetadataFactory.createVirtualProcedure("m.xproc3", model, Arrays.asList(new
FakeMetadataObject[] { xml1out, xml3in }), xproct3); //$NON-NLS-1$
-
- // XQuery view with scalar input args
- FakeMetadataObject xml4in = FakeMetadataFactory.createParameter("in1",
2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml4in2 = FakeMetadataFactory.createParameter("in2",
3, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- QueryNode xproct4 = new QueryNode("m.xproc4", //$NON-NLS-1$
- "declare variable $in1 as xs:string
external; " + //$NON-NLS-1$
- "declare variable $in2 as xs:int external;
" + //$NON-NLS-1$
- "<wrap><a>{ $in1
}</a><b>{ $in2 }</b></wrap>"); //$NON-NLS-1$
- FakeMetadataObject xproc4 =
FakeMetadataFactory.createVirtualProcedure("m.xproc4", model, Arrays.asList(new
FakeMetadataObject[] { xml1out, xml4in, xml4in2 }), xproct4); //$NON-NLS-1$
-
- // XQuery view calling doc() function with non-literal
- FakeMetadataObject xml5in =
FakeMetadataFactory.createParameter("procName", 2, ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode xproct5 = new QueryNode("m.xproc5", //$NON-NLS-1$
- "declare variable $procName as xs:string
external; " + //$NON-NLS-1$
- "let $sql := concat('EXEC ',
$procName, '()') " + //$NON-NLS-1$
- "return
<wrap>{doc($sql)}</wrap>"); //$NON-NLS-1$
- FakeMetadataObject xproc5 =
FakeMetadataFactory.createVirtualProcedure("m.xproc5", model, Arrays.asList(new
FakeMetadataObject[] { xml1out, xml5in }), xproct5); //$NON-NLS-1$
-
- // XQuery view to create dynamic element
- FakeMetadataObject xml6in = FakeMetadataFactory.createParameter("tag",
2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml6in2 =
FakeMetadataFactory.createParameter("value", 3, ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode xproct6 = new QueryNode("m.maketag", //$NON-NLS-1$
- "declare variable $tag as xs:string
external; " + //$NON-NLS-1$
- "declare variable $value as xs:string
external; " + //$NON-NLS-1$
- "element { $tag } { $value }");
//$NON-NLS-1$
- FakeMetadataObject xproc6 =
FakeMetadataFactory.createVirtualProcedure("m.maketag", model, Arrays.asList(new
FakeMetadataObject[] { xml1out, xml6in, xml6in2 }), xproct6); //$NON-NLS-1$
-
- // XQuery view calling multiple doc() functions with non-literal
- FakeMetadataObject xml7in =
FakeMetadataFactory.createParameter("wrapperTag", 2, ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml7in2 =
FakeMetadataFactory.createParameter("tag1", 3, ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml7in3 =
FakeMetadataFactory.createParameter("val1", 4, ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml7in4 =
FakeMetadataFactory.createParameter("tag2", 5, ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- FakeMetadataObject xml7in5 =
FakeMetadataFactory.createParameter("val2", 6, ParameterInfo.IN,
DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode xproct7 = new QueryNode("m.combinetags", //$NON-NLS-1$
- "declare variable $wrapperTag as xs:string
external; " + //$NON-NLS-1$
- "declare variable $tag1 as xs:string
external; " + //$NON-NLS-1$
- "declare variable $val1 as xs:string
external; " + //$NON-NLS-1$
- "declare variable $tag2 as xs:string
external; " + //$NON-NLS-1$
- "declare variable $val2 as xs:string
external; " + //$NON-NLS-1$
- "let $t1 := concat(\"EXEC
m.maketag('\", $tag1, \"','\", $val1, \"')\")
" + //$NON-NLS-1$
- "let $t2 := concat(\"EXEC
m.maketag('\", $tag2, \"','\", $val2, \"')\")
" + //$NON-NLS-1$
- "return element { $wrapperTag } {
doc($t1), doc($t2) }"); //$NON-NLS-1$
- FakeMetadataObject xproc7 =
FakeMetadataFactory.createVirtualProcedure("m.combinetags", model,
Arrays.asList(new FakeMetadataObject[] { xml1out, xml7in, xml7in2, xml7in3, xml7in4,
xml7in5 }), xproct7); //$NON-NLS-1$
-
- // XQuery web service view: takes xml in, yields xml out
- // Expects doc like:
<in><tag>tag</tag><value></value></in>
- FakeMetadataObject xml8in = FakeMetadataFactory.createParameter("in",
2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.XML, null); //$NON-NLS-1$
- QueryNode xproct8 = new QueryNode("m.svc8", //$NON-NLS-1$
- "declare variable $in as node() external;
" + //$NON-NLS-1$
- "element { $in//tag/text() } {
$in//value/text() }"); //$NON-NLS-1$
- FakeMetadataObject xproc8 =
FakeMetadataFactory.createVirtualProcedure("m.svc8", model, Arrays.asList(new
FakeMetadataObject[] { xml1out, xml8in }), xproct8); //$NON-NLS-1$
-
- // Chaining together XQuery web service views
- // Expects doc like:
<in><tag>tag</tag><values><value>val1</value><value>val2</value>...</values></in>
- FakeMetadataObject xml9in = FakeMetadataFactory.createParameter("in",
2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.XML, null); //$NON-NLS-1$
- QueryNode xproct9 = new QueryNode("m.svc9", //$NON-NLS-1$
- "declare variable $in as node() external;
" + //$NON-NLS-1$
- "<results> {" + //$NON-NLS-1$
- " for $value in $in//value " +
//$NON-NLS-1$
- " let $tag := $in//tag " +
//$NON-NLS-1$
- " return doc(" + //$NON-NLS-1$
- " concat(\"EXEC
m.svc8('<in><tag>\", $tag, \"</tag><value>\",
$value, \"</value></in>')\"))" + //$NON-NLS-1$
- "} </results>"); //$NON-NLS-1$
- FakeMetadataObject xproc9 =
FakeMetadataFactory.createVirtualProcedure("m.svc9", model, Arrays.asList(new
FakeMetadataObject[] { xml1out, xml9in }), xproct9); //$NON-NLS-1$
-
- // XQuery service with only a doc expression in it
- QueryNode xproct10 = new QueryNode("m.xproc10", //$NON-NLS-1$
- "doc('EXEC m.xproc1()')");
//$NON-NLS-1$
- FakeMetadataObject xproc10 =
FakeMetadataFactory.createVirtualProcedure("m.xproc10", model, Arrays.asList(new
FakeMetadataObject[] { xml1out }), xproct10); //$NON-NLS-1$
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(model);
- store.addObject(xproc1);
- store.addObject(xproc2);
- store.addObject(xproc3);
- store.addObject(xproc4);
- store.addObject(xproc5);
- store.addObject(xproc6);
- store.addObject(xproc7);
- store.addObject(xproc8);
- store.addObject(xproc9);
- store.addObject(xproc10);
-
- return new FakeMetadataFacade(store);
- }
/**
* Create a physical model with default settings.
* @param name Name of model
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-08-31
22:50:54 UTC (rev 2512)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-09-01
15:38:19 UTC (rev 2513)
@@ -253,6 +253,9 @@
QueryNode vspqn6 = new QueryNode("vsp6", "CREATE VIRTUAL PROCEDURE
BEGIN SELECT p1 as StringKey; END"); //$NON-NLS-1$ //$NON-NLS-2$
Procedure vsp6 = createVirtualProcedure("MMSP6", mmspTest1,
Arrays.asList(vsp6p1), vspqn6); //$NON-NLS-1$
vsp6.setResultSet(vsprs6);
+
+ createStoredProcedure("spRetOut", pm4,
Arrays.asList(createParameter("ret", ParameterInfo.RETURN_VALUE,
DataTypeManager.DefaultDataTypes.INTEGER),
+ createParameter("x", ParameterInfo.OUT,
DataTypeManager.DefaultDataTypes.INTEGER)), "spRetOut"); //$NON-NLS-1$
//$NON-NLS-2$
return createTransformationMetadata(metadataStore, "bqt");
}