Skip to content

Commit

Permalink
TEIID-5130 forcing result parameters to be first
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Oct 30, 2017
1 parent a12b6ca commit 455ca69
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
Expand Up @@ -130,7 +130,8 @@ public void execute() throws TranslatorException {
if (arguments.size() > 5
//designer modeled the return value as an out, which will add an argument in the 5th position that is an out
&& this.procedure.getMetadataObject() != null
&& this.procedure.getMetadataObject().getParameters().get(0).getType() == Type.ReturnValue) {
&& (this.procedure.getMetadataObject().getParameters().get(0).getType() == Type.ReturnValue
|| this.procedure.getMetadataObject().getParameters().get(5).getName().equalsIgnoreCase("headers"))) {
Clob headers = (Clob)arguments.get(5).getArgumentValue().getValue();
if (headers != null) {
parseHeader(httpHeaders, headers);
Expand Down
Expand Up @@ -54,6 +54,8 @@ public class SQLParserUtil {

public static final boolean DECIMAL_AS_DOUBLE = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.decimalAsDouble", false); //$NON-NLS-1$

public static final boolean RESULT_ANY_POSITION = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.resultAnyPosition", false); //$NON-NLS-1$

String prependSign(String sign, String literal) {
if (sign != null && sign.charAt(0) == '-') {
return sign + literal;
Expand Down
3 changes: 3 additions & 0 deletions engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
Expand Up @@ -5676,6 +5676,9 @@ void procedureParameter(MetadataFactory factory, Procedure proc) :
throw new ParseException(QueryPlugin.Util.getString("SQLParser.param_out", proc.getName(), name));
}
ppType = ProcedureParameter.Type.ReturnValue;
if (!RESULT_ANY_POSITION && !proc.getParameters().isEmpty()) {
throw new ParseException(QueryPlugin.Util.getString("SQLParser.param_result_first", proc.getName(), name));
}
}
]
{
Expand Down
1 change: 1 addition & 0 deletions engine/src/main/resources/org/teiid/query/i18n.properties
Expand Up @@ -1408,6 +1408,7 @@ TEIID31123=Could not load non-FOREIGN UDF "{0}", since both invocation class and

SQLParser.proc_type_conflict=Result type {1} conflicts with return type {2} for procedure {0}
SQLParser.param_out=Procedure {0} RESULT param {1} must be of type OUT.
SQLParser.param_result_first=Procedure {0} RESULT param {1} must be the first parameter.
udt_format_wrong=UDT option mentioned on column "{0}" is wrong. It must be in the form UDT=name(length,precision,scale). Otherwise UDT data type specified is not a known data type to Teiid.
TEIID31125=Return statement with expression used, but no return value is expected: {0}
TEIID31126=The use of the KEEP ALIASES option has introduced a duplicate alias into the source query {0}. A NO_UNNEST hint may be needed to preserve a view or the KEEP ALIASES option should not be used and the generated aliases should be obtained from the query plan.
Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.MetadataStore;
import org.teiid.metadata.ParseException;
import org.teiid.metadata.Table;
import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.parser.QueryParser;
Expand Down Expand Up @@ -161,14 +162,22 @@ public void testCreateTriggerFails() throws Exception {
assertTrue(printError(report), report.hasItems());
}

@Test public void testProcWithMultipleReturn() throws Exception {
@Test(expected=ParseException.class) public void testProcWithMultipleReturn() throws Exception {
String ddl = "create foreign procedure x (out param1 string result, out param2 string result); ";
buildModel("pm1", true, this.vdb, this.store,ddl);
buildTransformationMetadata();
ValidatorReport report = new MetadataValidator().validate(vdb, store);
assertTrue(printError(report), report.hasItems());
}

@Test(expected=ParseException.class) public void testProcWithOutOfOrderReturn() throws Exception {
String ddl = "create foreign procedure x (out param1 string, out param2 string result); ";
buildModel("pm1", true, this.vdb, this.store,ddl);
buildTransformationMetadata();
ValidatorReport report = new MetadataValidator().validate(vdb, store);
assertTrue(printError(report), report.hasItems());
}

@Test public void testProcWithDuplicateParam() throws Exception {
String ddl = "create foreign procedure x (out param1 string, out param1 string); ";
buildModel("pm1", true, this.vdb, this.store,ddl);
Expand Down
Expand Up @@ -53,6 +53,7 @@ <h4>from 9.3</h4>
<li><a href="https://issues.jboss.org/browse/TEIID-5012">TEIID-5012</a> A Description column was added to SYS.VirtualDatabases. </li>
<li><a href="https://issues.jboss.org/browse/TEIID-4943">TEIID-4943</a> Copy criteria created from a join will typically only be pushed when the join is not pushed.</li>
<li><a href="https://issues.jboss.org/browse/TEIID-5112">TEIID-5112</a> Type length specified in DDL or SQL must be greater than 0. Char type length must only be 1.</li>
<li><a href="https://issues.jboss.org/browse/TEIID-5130">TEIID-5130</a> Procedure RESULT parameters must appear as the first parameter in the argument list. To allow the old behavior of appearing anywhere, set the system property org.teiid.resultAnyPosition=true.</li>
</ul>

<h4>from 9.2</h4>
Expand Down

0 comments on commit 455ca69

Please sign in to comment.