Skip to content

Commit

Permalink
TEIID-5462 adding a new translator property for netezza
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Sep 6, 2018
1 parent f344f7d commit d049b63
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
Expand Up @@ -1591,4 +1591,17 @@ public void setSupportsWindowFunctionNthValue(boolean supportsNthValue) {
this.supportsNthValue = supportsNthValue;
}

Boolean supportsMultipleOpenStatements;
@Override
public boolean supportsMultipleOpenExecutions() {
if (supportsMultipleOpenStatements != null) {
return supportsMultipleOpenStatements;
}
return delegate.supportsMultipleOpenExecutions();
}

public void setSupportsMultipleOpenStatements(
boolean supportsMultipleOpenStatements) {
this.supportsMultipleOpenStatements = supportsMultipleOpenStatements;
}
}
9 changes: 9 additions & 0 deletions api/src/main/java/org/teiid/translator/ExecutionFactory.java
Expand Up @@ -1465,4 +1465,13 @@ public boolean supportsWindowFunctionCumeDist() {
public boolean supportsWindowFunctionNthValue() {
return supportsElementaryOlapOperations();
}

/**
*
* @since 11.2
* @return true if multiple executions may be open against a single connection at a time
*/
public boolean supportsMultipleOpenExecutions() {
return true;
}
}
Expand Up @@ -34,7 +34,7 @@ public class TestBaseDelegatingExecutionFactory {
Method[] methods = ExecutionFactory.class.getDeclaredMethods();
Method[] proxyMethods = BaseDelegatingExecutionFactory.class.getDeclaredMethods();
//excluding the setter methods the counts should be equal
assertEquals(methods.length+96, proxyMethods.length);
assertEquals(methods.length+97, proxyMethods.length);
}

@Test public void testExecution() throws TranslatorException {
Expand Down
Expand Up @@ -465,4 +465,10 @@ public boolean supportsSelectWithoutFrom() {
return true;
}

@Override
public boolean supportsMultipleOpenExecutions() {
//See TEIID-5462
return false;
}

}
Expand Up @@ -588,7 +588,7 @@ public boolean isForkable() {

@Override
public boolean isThreadBound() {
return this.connector.isThreadBound();
return this.connector.isThreadBound() || (this.requestMsg.isTransactional() && !this.connector.supportsMultipleOpenExecutions());
}

private List<?> correctTypes(List row) throws TeiidException {
Expand Down
Expand Up @@ -59,6 +59,7 @@
import org.teiid.dqp.message.RequestID;
import org.teiid.dqp.service.AutoGenDataService;
import org.teiid.dqp.service.TransactionContext;
import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.language.Call;
import org.teiid.language.QueryExpression;
import org.teiid.metadata.RuntimeMetadata;
Expand Down Expand Up @@ -546,5 +547,33 @@ public Object getConnectionFactory(){
ConnectorManager cm = TestConnectorManager.getConnectorManager();
cm.registerRequest(arm);
}

@Test public void testIsThreadBound() throws Exception {
Command command = helpGetCommand("SELECT intkey FROM bqt1.smalla", EXAMPLE_BQT); //$NON-NLS-1$
AtomicRequestMessage arm = createNewAtomicRequestMessage(1, 1);
TransactionContext tc = new TransactionContext();
tc.setTransactionType(Scope.LOCAL);
arm.setTransactionContext(tc);
arm.setCommand(command);
final FakeConnector c = new FakeConnector() {
public boolean supportsMultipleOpenExecutions() {
return false;
}
};
ConnectorManager cm = new ConnectorManager("FakeConnector","FakeConnector") { //$NON-NLS-1$ //$NON-NLS-2$
public ExecutionFactory getExecutionFactory() {
return c;
}
public Object getConnectionFactory(){
return c;
}
};
cm.start();
ConnectorWorkItem cwi = new ConnectorWorkItem(arm, cm);
assertTrue(cwi.isThreadBound());

cwi = new ConnectorWorkItem(arm, TestConnectorManager.getConnectorManager());
assertFalse(cwi.isThreadBound());
}

}

0 comments on commit d049b63

Please sign in to comment.