teiid SVN: r3123 - in trunk/runtime/src/main/java/org/teiid: transport and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-26 21:26:25 -0400 (Tue, 26 Apr 2011)
New Revision: 3123
Modified:
trunk/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java
trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
Log:
TEIID-1176 further refinement of odbc handling. messages are queued and extended queries will properly handle error conditions
Modified: trunk/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java 2011-04-26 20:04:35 UTC (rev 3122)
+++ trunk/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java 2011-04-27 01:26:25 UTC (rev 3123)
@@ -26,6 +26,7 @@
import java.sql.Statement;
import java.util.Properties;
+import org.teiid.client.util.ResultsFuture;
import org.teiid.jdbc.ResultSetImpl;
public interface ODBCClientRemote {
@@ -65,7 +66,7 @@
// DataRow (B)
// CommandComplete (B)
- void sendResults(String sql, ResultSetImpl rs, boolean describeRows);
+ void sendResults(String sql, ResultSetImpl rs, ResultsFuture<Void> result, boolean describeRows);
// CommandComplete (B)
void sendUpdateCount(String sql, int updateCount);
Modified: trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-04-26 20:04:35 UTC (rev 3122)
+++ trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-04-27 01:26:25 UTC (rev 3123)
@@ -29,6 +29,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -140,8 +141,8 @@
private Properties props;
private AuthenticationType authType;
private ConnectionImpl connection;
- private boolean shouldSynch;
- private boolean synchCalled;
+ private boolean executing;
+ private boolean errorOccurred;
private volatile ResultsFuture<Boolean> executionFuture;
@@ -179,9 +180,9 @@
this.connection = (ConnectionImpl)driver.connect(url, info);
int hash = this.connection.getConnectionId().hashCode();
this.client.authenticationSucess(hash, hash);
- ready(true);
+ ready();
} catch (SQLException e) {
- this.client.errorOccurred(e);
+ errorOccurred(e);
terminate();
}
}
@@ -208,12 +209,12 @@
this.preparedMap.put(prepareName, new Prepared(prepareName, sql, stmt, paramType));
this.client.prepareCompleted(prepareName);
} catch (SQLException e) {
- this.client.errorOccurred(e);
+ errorOccurred(e);
}
}
}
else {
- this.client.errorOccurred(RuntimePlugin.Util.getString("no_active_connection")); //$NON-NLS-1$
+ errorOccurred(RuntimePlugin.Util.getString("no_active_connection")); //$NON-NLS-1$
}
}
@@ -229,7 +230,7 @@
Prepared previous = this.preparedMap.get(prepareName);
if (previous == null) {
- this.client.errorOccurred(RuntimePlugin.Util.getString("bad_binding", prepareName)); //$NON-NLS-1$
+ errorOccurred(RuntimePlugin.Util.getString("bad_binding", prepareName)); //$NON-NLS-1$
return;
}
@@ -242,7 +243,7 @@
previous.stmt.setObject(i+1, params[i]);
}
} catch (SQLException e) {
- this.client.errorOccurred(e);
+ errorOccurred(e);
}
this.portalMap.put(bindName, new Portal(bindName, prepareName, previous.sql, previous.stmt, resultColumnFormat));
@@ -251,13 +252,13 @@
@Override
public void unsupportedOperation(String msg) {
- this.client.errorOccurred(msg);
- ready(true);
+ errorOccurred(msg);
}
@Override
public void execute(String bindName, int maxRows) {
- if (isAwaitingAsynch()) {
+ if (beginExecution()) {
+ errorOccurred("Awaiting asynch result"); //$NON-NLS-1$
return;
}
if (bindName == null || bindName.length() == 0) {
@@ -266,8 +267,7 @@
final Portal query = this.portalMap.get(bindName);
if (query == null) {
- this.client.errorOccurred(RuntimePlugin.Util.getString("not_bound", bindName)); //$NON-NLS-1$
- ready(true);
+ errorOccurred(RuntimePlugin.Util.getString("not_bound", bindName)); //$NON-NLS-1$
}
else {
if (query.sql.trim().isEmpty()) {
@@ -288,23 +288,34 @@
public void onCompletion(ResultsFuture<Boolean> future) {
executionFuture = null;
try {
- if (future.get()) {
- client.sendResults(query.sql, stmt.getResultSet(), true);
- } else {
- client.sendUpdateCount(query.sql, stmt.getUpdateCount());
- setEncoding();
- }
+ ResultsFuture<Void> result = null;
+ if (future.get()) {
+ result = new ResultsFuture<Void>();
+ client.sendResults(query.sql, stmt.getResultSet(), result, true);
+ } else {
+ result = ResultsFuture.NULL_FUTURE;
+ client.sendUpdateCount(query.sql, stmt.getUpdateCount());
+ setEncoding();
+ }
+ result.addCompletionListener(new ResultsFuture.CompletionListener<Void>() {
+ public void onCompletion(ResultsFuture<Void> future) {
+ try {
+ future.get();
+ doneExecuting();
+ } catch (InterruptedException e) {
+ throw new AssertionError(e);
+ } catch (ExecutionException e) {
+ errorOccurred(e.getCause());
+ }
+ };
+ });
} catch (Throwable e) {
- client.errorOccurred(e);
+ errorOccurred(e);
}
- if (query.closeRequested) {
- closeBoundStatement(query.name);
- }
- ready(false);
}
});
} catch (SQLException e) {
- this.client.errorOccurred(e);
+ errorOccurred(e);
}
}
}
@@ -410,7 +421,9 @@
@Override
public void executeQuery(final String query) {
- if (isAwaitingAsynch()) {
+ if (beginExecution()) {
+ this.client.errorOccurred("Awaiting asynch result"); //$NON-NLS-1$
+ ready();
return;
}
//46.2.3 Note that a simple Query message also destroys the unnamed portal.
@@ -419,27 +432,30 @@
if (query.trim().length() == 0) {
this.client.emptyQueryReceived();
- ready(false);
+ ready();
return;
}
QueryWorkItem r = new QueryWorkItem(query);
r.run();
}
- /**
- * Just a sanity check. Should never happen
- */
- private boolean isAwaitingAsynch() {
+ private boolean beginExecution() {
if (this.executionFuture != null) {
- this.client.errorOccurred("Awaiting asynch result"); //$NON-NLS-1$
- ready(true);
return true;
}
synchronized (this) {
- this.shouldSynch = false;
+ this.executing = true;
}
return false;
}
+
+ public boolean isExecuting() {
+ return executing;
+ }
+
+ public boolean isErrorOccurred() {
+ return errorOccurred;
+ }
@Override
public void getParameterDescription(String prepareName) {
@@ -448,17 +464,32 @@
}
Prepared query = this.preparedMap.get(prepareName);
if (query == null) {
- this.client.errorOccurred(RuntimePlugin.Util.getString("no_stmt_found", prepareName)); //$NON-NLS-1$
- ready(true);
+ errorOccurred(RuntimePlugin.Util.getString("no_stmt_found", prepareName)); //$NON-NLS-1$
}
else {
try {
this.client.sendParameterDescription(query.stmt.getParameterMetaData(), query.paramType);
} catch (SQLException e) {
- this.client.errorOccurred(e);
+ errorOccurred(e);
}
}
}
+
+ private void errorOccurred(String error) {
+ this.client.errorOccurred(error);
+ synchronized (this) {
+ this.errorOccurred = true;
+ doneExecuting();
+ }
+ }
+
+ private void errorOccurred(Throwable error) {
+ this.client.errorOccurred(error);
+ synchronized (this) {
+ this.errorOccurred = true;
+ doneExecuting();
+ }
+ }
@Override
public void getResultSetMetaDataDescription(String bindName) {
@@ -467,40 +498,27 @@
}
Portal query = this.portalMap.get(bindName);
if (query == null) {
- this.client.errorOccurred(RuntimePlugin.Util.getString("not_bound", bindName)); //$NON-NLS-1$
+ errorOccurred(RuntimePlugin.Util.getString("not_bound", bindName)); //$NON-NLS-1$
}
else {
try {
this.client.sendResultSetDescription(query.stmt.getMetaData(), query.stmt);
} catch (SQLException e) {
- this.client.errorOccurred(e);
+ errorOccurred(e);
}
}
}
@Override
public void sync() {
- boolean ready = false;
- synchronized (this) {
- synchCalled = true;
- ready = this.shouldSynch;
- }
- if (ready) {
- ready(true);
- }
+ ready();
}
- private void ready(boolean sendAlways) {
- synchronized (this) {
- if (!sendAlways) {
- shouldSynch = true;
- if (!synchCalled) {
- return;
- }
- }
- shouldSynch = true;
- synchCalled = false;
- }
+ protected synchronized void doneExecuting() {
+ executing = false;
+ }
+
+ private void ready() {
boolean inTxn = false;
boolean failedTxn = false;
try {
@@ -510,6 +528,9 @@
} catch (SQLException e) {
failedTxn = true;
}
+ synchronized (this) {
+ this.errorOccurred = false;
+ }
this.client.ready(inTxn, failedTxn);
}
@@ -523,18 +544,9 @@
if (bindName == null || bindName.length() == 0) {
bindName = UNNAMED;
}
- Portal query = this.portalMap.get(bindName);
- if (query != null) {
- if (this.executionFuture != null) {
- synchronized(query) {
- query.closeRequested = true;
- }
- return;
- }
- }
- query = this.portalMap.remove(bindName);
+ Portal query = this.portalMap.remove(bindName);
if (query == null) {
- this.client.errorOccurred(RuntimePlugin.Util.getString("not_bound", bindName)); //$NON-NLS-1$
+ errorOccurred(RuntimePlugin.Util.getString("not_bound", bindName)); //$NON-NLS-1$
}
else {
try {
@@ -559,7 +571,7 @@
}
Prepared query = this.preparedMap.remove(preparedName);
if (query == null) {
- this.client.errorOccurred(RuntimePlugin.Util.getString("no_stmt_found", preparedName)); //$NON-NLS-1$
+ errorOccurred(RuntimePlugin.Util.getString("no_stmt_found", preparedName)); //$NON-NLS-1$
}
else {
// Close all the bound messages off of this prepared
@@ -570,7 +582,7 @@
query.stmt.close();
this.client.statementClosed();
} catch (SQLException e) {
- this.client.errorOccurred(RuntimePlugin.Util.getString("error_closing_stmt", preparedName)); //$NON-NLS-1$
+ errorOccurred(RuntimePlugin.Util.getString("error_closing_stmt", preparedName)); //$NON-NLS-1$
}
}
}
@@ -611,8 +623,7 @@
@Override
public void functionCall(int oid) {
- this.client.errorOccurred(RuntimePlugin.Util.getString("lo_not_supported")); //$NON-NLS-1$
- ready(true);
+ errorOccurred(RuntimePlugin.Util.getString("lo_not_supported")); //$NON-NLS-1$
}
@Override
@@ -661,29 +672,45 @@
public void onCompletion(ResultsFuture<Boolean> future) {
executionFuture = null;
try {
+ ResultsFuture<Void> result = null;
if (future.get()) {
- client.sendResults(sql, stmt.getResultSet(), true);
+ result = new ResultsFuture<Void>();
+ client.sendResults(sql, stmt.getResultSet(), result, true);
} else {
+ result = ResultsFuture.NULL_FUTURE;
client.sendUpdateCount(sql, stmt.getUpdateCount());
setEncoding();
}
- sql = reader.readStatement();
- modfiedSQL = fixSQL(sql);
+ result.addCompletionListener(new ResultsFuture.CompletionListener<Void>() {
+ public void onCompletion(ResultsFuture<Void> future) {
+ try {
+ future.get();
+ sql = reader.readStatement();
+ modfiedSQL = fixSQL(sql);
+ } catch (InterruptedException e) {
+ throw new AssertionError(e);
+ } catch (IOException e) {
+ client.errorOccurred(e);
+ return;
+ } catch (ExecutionException e) {
+ client.errorOccurred(e.getCause());
+ return;
+ } finally {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ LogManager.logDetail(LogConstants.CTX_ODBC, e, "Error closing statement"); //$NON-NLS-1$
+ }
+ }
+ QueryWorkItem.this.run(); //continue processing
+ };
+ });
} catch (Throwable e) {
client.errorOccurred(e);
- ready(true);
return;
- } finally {
- try {
- stmt.close();
- } catch (SQLException e) {
- LogManager.logDetail(LogConstants.CTX_ODBC, e, "Error closing statement"); //$NON-NLS-1$
- }
}
- QueryWorkItem.this.run(); //continue processing
}
});
- ready(false);
return; //wait for the execution to finish
} catch (SQLException e) {
client.errorOccurred(e);
@@ -693,8 +720,10 @@
} catch(IOException e) {
client.errorOccurred(e);
}
- sync();
+ doneExecuting();
+ ready();
}
+
}
/**
@@ -764,9 +793,6 @@
* The prepared statement.
*/
PreparedStatementImpl stmt;
-
- boolean closeRequested;
}
-
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2011-04-26 20:04:35 UTC (rev 3122)
+++ trunk/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2011-04-27 01:26:25 UTC (rev 3123)
@@ -26,6 +26,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
+import java.util.concurrent.ConcurrentLinkedQueue;
import org.teiid.core.util.ReflectionHelper;
import org.teiid.jdbc.TeiidDriver;
@@ -45,6 +46,7 @@
private ODBCClientRemote client;
private ODBCServerRemoteImpl server;
private ReflectionHelper serverProxy = new ReflectionHelper(ODBCServerRemote.class);
+ private ConcurrentLinkedQueue<PGRequest> messageQueue = new ConcurrentLinkedQueue<PGRequest>();
public ODBCClientInstance(final ObjectChannel channel, ODBCServerRemote.AuthenticationType authType, TeiidDriver driver) {
this.client = (ODBCClientRemote)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {ODBCClientRemote.class}, new InvocationHandler() {
@@ -58,7 +60,21 @@
return null;
}
});
- this.server = new ODBCServerRemoteImpl(this, authType, driver);
+ this.server = new ODBCServerRemoteImpl(this, authType, driver) {
+ @Override
+ protected synchronized void doneExecuting() {
+ super.doneExecuting();
+ while (!server.isExecuting()) {
+ PGRequest request = messageQueue.poll();
+ if (request == null) {
+ break;
+ }
+ if (!server.isErrorOccurred() || request.struct.methodName.equals("sync")) { //$NON-NLS-1$
+ processMessage(request.struct);
+ }
+ }
+ }
+ };
}
public ODBCClientRemote getClient() {
@@ -83,6 +99,17 @@
public void receivedMessage(Object msg) throws CommunicationException {
if (msg instanceof PGRequest) {
PGRequest request = (PGRequest)msg;
+ synchronized (server) {
+ if (server.isExecuting()) {
+ //queue until done
+ messageQueue.add(request);
+ return;
+ }
+ if (server.isErrorOccurred() && !request.struct.methodName.equals("sync")) { //$NON-NLS-1$
+ //discard until sync
+ return;
+ }
+ }
processMessage(request.struct);
}
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-04-26 20:04:35 UTC (rev 3122)
+++ trunk/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-04-27 01:26:25 UTC (rev 3123)
@@ -72,12 +72,14 @@
private final List<PgColInfo> cols;
private final String sql;
private final ResultSetImpl rs;
+ private final ResultsFuture<Void> result;
private ResultsWorkItem(List<PgColInfo> cols, String sql,
- ResultSetImpl rs) {
+ ResultSetImpl rs, ResultsFuture<Void> result) {
this.cols = cols;
this.sql = sql;
this.rs = rs;
+ this.result = result;
}
@Override
@@ -101,11 +103,7 @@
break;
}
} catch (Throwable t) {
- try {
- sendErrorResponse(t);
- } catch (IOException e) {
- terminate(e);
- }
+ result.getResultsReceiver().exceptionOccurred(t);
}
}
}
@@ -118,14 +116,11 @@
sendDataRow(rs, cols);
} else {
sendCommandComplete(sql, 0);
+ result.getResultsReceiver().receiveResults(null);
processNext = false;
}
} catch (Throwable t) {
- try {
- sendErrorResponse(t);
- } catch (IOException e) {
- terminate(e);
- }
+ result.getResultsReceiver().exceptionOccurred(t);
return false;
}
return processNext;
@@ -167,6 +162,8 @@
private MessageEvent message;
private int maxLobSize = (2*1024*1024); // 2 MB
+ private volatile ResultsFuture<Boolean> nextFuture;
+
public PgBackendProtocol(int maxLobSize) {
this.maxLobSize = maxLobSize;
}
@@ -328,25 +325,22 @@
}
}
- private volatile ResultsFuture<Boolean> nextFuture;
-
@Override
- public void sendResults(final String sql, final ResultSetImpl rs, boolean describeRows) {
+ public void sendResults(final String sql, final ResultSetImpl rs, ResultsFuture<Void> result, boolean describeRows) {
try {
if (nextFuture != null) {
sendErrorResponse(new IllegalStateException("Pending results have not been sent")); //$NON-NLS-1$
}
- try {
- ResultSetMetaData meta = rs.getMetaData();
- List<PgColInfo> cols = getPgColInfo(meta, rs.getStatement());
- if (describeRows) {
- sendRowDescription(cols);
- }
- Runnable r = new ResultsWorkItem(cols, sql, rs);
- r.run();
- } catch (SQLException e) {
- sendErrorResponse(e);
- }
+
+ ResultSetMetaData meta = rs.getMetaData();
+ List<PgColInfo> cols = getPgColInfo(meta, rs.getStatement());
+ if (describeRows) {
+ sendRowDescription(cols);
+ }
+ Runnable r = new ResultsWorkItem(cols, sql, rs, result);
+ r.run();
+ } catch (SQLException e) {
+ result.getResultsReceiver().exceptionOccurred(e);
} catch (IOException e) {
terminate(e);
}
13 years
teiid SVN: r3122 - in trunk: test-integration/common/src/test/java/org/teiid/transport and 1 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-26 16:04:35 -0400 (Tue, 26 Apr 2011)
New Revision: 3122
Added:
trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected
Modified:
trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
Log:
TEIID-1532: The ODBC driver in the case of the prepared statement send "execute;close;sync" in a single input message block. when executing in asynch these can get out order and fail. This addresses the issue.
Modified: trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-04-26 15:12:52 UTC (rev 3121)
+++ trunk/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-04-26 20:04:35 UTC (rev 3122)
@@ -297,6 +297,9 @@
} catch (Throwable e) {
client.errorOccurred(e);
}
+ if (query.closeRequested) {
+ closeBoundStatement(query.name);
+ }
ready(false);
}
});
@@ -520,7 +523,16 @@
if (bindName == null || bindName.length() == 0) {
bindName = UNNAMED;
}
- Portal query = this.portalMap.remove(bindName);
+ Portal query = this.portalMap.get(bindName);
+ if (query != null) {
+ if (this.executionFuture != null) {
+ synchronized(query) {
+ query.closeRequested = true;
+ }
+ return;
+ }
+ }
+ query = this.portalMap.remove(bindName);
if (query == null) {
this.client.errorOccurred(RuntimePlugin.Util.getString("not_bound", bindName)); //$NON-NLS-1$
}
@@ -671,6 +683,7 @@
QueryWorkItem.this.run(); //continue processing
}
});
+ ready(false);
return; //wait for the execution to finish
} catch (SQLException e) {
client.errorOccurred(e);
@@ -680,7 +693,7 @@
} catch(IOException e) {
client.errorOccurred(e);
}
- ready(false);
+ sync();
}
}
@@ -751,6 +764,8 @@
* The prepared statement.
*/
PreparedStatementImpl stmt;
+
+ boolean closeRequested;
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2011-04-26 15:12:52 UTC (rev 3121)
+++ trunk/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2011-04-26 20:04:35 UTC (rev 3122)
@@ -27,6 +27,7 @@
import java.net.InetSocketAddress;
import java.nio.charset.Charset;
import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;
@@ -133,6 +134,14 @@
TestMMDatabaseMetaData.compareResultSet(rs);
}
+ @Test public void testPkPrepared() throws Exception {
+ PreparedStatement stmt = conn.prepareStatement("select ta.attname, ia.attnum, ic.relname, n.nspname, tc.relname " +//$NON-NLS-1$
+ "from pg_catalog.pg_attribute ta, pg_catalog.pg_attribute ia, pg_catalog.pg_class tc, pg_catalog.pg_index i, " +//$NON-NLS-1$
+ "pg_catalog.pg_namespace n, pg_catalog.pg_class ic where tc.relname = E'pg_attribute' AND n.nspname = E'pg_catalog'");
+ ResultSet rs = stmt.executeQuery();
+ TestMMDatabaseMetaData.compareResultSet(rs);
+ }
+
@Test public void testEscapedLiteral() throws Exception {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select E'\\n\\thello pg'");
Added: trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected (rev 0)
+++ trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testPkPrepared.expected 2011-04-26 20:04:35 UTC (rev 3122)
@@ -0,0 +1,10 @@
+varchar int2 varchar varchar varchar
+name attnum tablename schemaname tablename
+oid 1 pg_attribute pg_catalog pg_attribute
+Row Count : 1
+getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
+name 12 java.lang.String name varchar 2147483647 0 0 false true false false 0 false true false true
+attnum 5 java.lang.Integer attnum int2 6 5 0 false false false false 2 false true true true
+tablename 12 java.lang.String tablename varchar 2147483647 0 0 false true false false 0 false true false true
+schemaname 12 java.lang.String schemaname varchar 2147483647 0 0 false true false false 1 false true false true
+tablename 12 java.lang.String tablename varchar 2147483647 0 0 false true false false 0 false true false true
13 years
teiid SVN: r3121 - in branches/7.1.x/engine/src: main/java/org/teiid/query/tempdata and 1 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-26 11:12:52 -0400 (Tue, 26 Apr 2011)
New Revision: 3121
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
Log:
SOA-3037
Modified: branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2011-04-25 20:29:04 UTC (rev 3120)
+++ branches/7.1.x/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2011-04-26 15:12:52 UTC (rev 3121)
@@ -140,6 +140,7 @@
}
this.results = buffer;
bufferManager.addTupleBuffer(this.results);
+ this.results.close();
}
return true;
} catch (TeiidComponentException e) {
Modified: branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-04-25 20:29:04 UTC (rev 3120)
+++ branches/7.1.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-04-26 15:12:52 UTC (rev 3121)
@@ -396,10 +396,10 @@
key.vdb = new VDBKey(context.getVdbName(), context.getVdbVersion());
MatTableEntry entry = this.tables.get(key);
- if (entry != null && entry.lastUpdate > info.getUpdateTime()
- && info.getState() != MatState.LOADING) {
+ boolean firstload = !info.isValid();
+ if (entry != null && entry.lastUpdate > info.getUpdateTime() && info.getState() != MatState.LOADING) {
//remote load
- info.setState(MatState.NEEDS_LOADING, entry.valid, null);
+ info.setState(MatState.NEEDS_LOADING, firstload?false:entry.valid, null);
loadTime = entry.lastUpdate;
}
}
Modified: branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
===================================================================
--- branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2011-04-25 20:29:04 UTC (rev 3120)
+++ branches/7.1.x/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2011-04-26 15:12:52 UTC (rev 3121)
@@ -23,6 +23,7 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -125,6 +126,7 @@
TupleBuffer cachedTb = cachedResults.getResults();
+ assertTrue(cachedTb.isFinal());
assertEquals(tb.getRowCount(), cachedTb.getRowCount());
assertEquals(tb.getBatchSize(), cachedTb.getBatchSize());
13 years
teiid SVN: r3120 - in trunk: client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-25 16:29:04 -0400 (Mon, 25 Apr 2011)
New Revision: 3120
Added:
trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/
trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/
trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java
Modified:
trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java
Log:
TEIID-1491: Adding support for XML results
Added: trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java
===================================================================
--- trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java (rev 0)
+++ trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java 2011-04-25 20:29:04 UTC (rev 3120)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @author tags. See the COPYRIGHT.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package net.sf.retrotranslator.runtime.javax.xml.stream;
+
+public class XMLStreamException_ extends Exception {
+
+ public XMLStreamException_() {
+ super();
+ }
+
+ public XMLStreamException_(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public XMLStreamException_(String message) {
+ super(message);
+ }
+
+ public XMLStreamException_(Throwable cause) {
+ super(cause);
+ }
+
+}
Property changes on: trunk/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java 2011-04-25 20:18:21 UTC (rev 3119)
+++ trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java 2011-04-25 20:29:04 UTC (rev 3120)
@@ -131,6 +131,10 @@
this.type = (Type)in.readObject();
} catch (OptionalDataException e) {
this.type = Type.UNKNOWN;
+ } catch(IOException e) {
+ this.type = Type.UNKNOWN;
+ } catch(ClassNotFoundException e) {
+ this.type = Type.UNKNOWN;
}
}
13 years
teiid SVN: r3119 - in trunk/engine/src: test/java/org/teiid/query/optimizer and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-04-25 16:18:21 -0400 (Mon, 25 Apr 2011)
New Revision: 3119
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java
Log:
TEIID-1566 fix for projection raising ordering on an alias
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java 2011-04-25 19:51:53 UTC (rev 3118)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java 2011-04-25 20:18:21 UTC (rev 3119)
@@ -41,6 +41,9 @@
import org.teiid.query.sql.lang.OrderBy;
import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.util.CommandContext;
@@ -236,8 +239,21 @@
List<SingleElementSymbol> childOutputCols = (List<SingleElementSymbol>) projectNode.getFirstChild().getProperty(Info.OUTPUT_COLS);
OrderBy orderBy = (OrderBy) node.getProperty(Info.SORT_ORDER);
List<SingleElementSymbol> orderByKeys = orderBy.getSortKeys();
- if (!childOutputCols.containsAll(orderByKeys)) {
- return root;
+ for (SingleElementSymbol ss : orderByKeys) {
+ if(ss instanceof AliasSymbol) {
+ ss = ((AliasSymbol)ss).getSymbol();
+ }
+
+ if (ss instanceof ExpressionSymbol && !(ss instanceof AggregateSymbol)) {
+ ExpressionSymbol exprSymbol = (ExpressionSymbol)ss;
+
+ if (!exprSymbol.isDerivedExpression()) {
+ return root; //TODO: insert a new project node to handle this case
+ }
+ }
+ if (!childOutputCols.contains(ss)) {
+ return root;
+ }
}
NodeEditor.removeChildNode(projectNode.getParent(), projectNode);
if (parent != null && parent.getType() == NodeConstants.Types.TUPLE_LIMIT && parent.getParent() != null) {
@@ -256,13 +272,21 @@
}
}
List<SingleElementSymbol> orderByOutputSymbols = (List<SingleElementSymbol>) node.getProperty(Info.OUTPUT_COLS);
+ boolean unrelated = false;
if (node.hasBooleanProperty(Info.UNRELATED_SORT)) {
node.setProperty(Info.UNRELATED_SORT, false);
- //update sort order
- for (OrderByItem item : orderBy.getOrderByItems()) {
+ unrelated = true;
+ }
+ for (OrderByItem item : orderBy.getOrderByItems()) {
+ if (unrelated) {
+ //update sort order
int index = childOutputCols.indexOf(item.getSymbol());
item.setExpressionPosition(index);
}
+ //strip alias as project was raised
+ if (item.getSymbol() instanceof AliasSymbol) {
+ item.setSymbol(((AliasSymbol)item.getSymbol()).getSymbol());
+ }
}
projectNode.setProperty(Info.OUTPUT_COLS, orderByOutputSymbols);
projectNode.setProperty(Info.PROJECT_COLS, orderByOutputSymbols);
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java 2011-04-25 19:51:53 UTC (rev 3118)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java 2011-04-25 20:18:21 UTC (rev 3119)
@@ -239,6 +239,20 @@
helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
new String[] {"SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
}
+
+ @Test public void testProjectionRaisingWithAlias() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ String sql = "select (select e1 from pm2.g1 where e2 = x.e2) as z, x.e1 as foo from pm1.g1 as x order by foo limit 1"; //$NON-NLS-1$
+ helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0 LIMIT 1"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
}
13 years
teiid SVN: r3118 - in trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio: data-roles-ext and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-25 15:51:53 -0400 (Mon, 25 Apr 2011)
New Revision: 3118
Added:
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/README.txt
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/portfolio-vdb.xml
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-roles.properties
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-users.properties
Log:
TEIID-1431: adding simple data-roles example to the kit.
Added: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/README.txt
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/README.txt (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/README.txt 2011-04-25 19:51:53 UTC (rev 3118)
@@ -0,0 +1,43 @@
+This example is continuation from the previous portfolio example. Make sure that you have the working example before using this example.
+
+In this example, the vdb is defined with two different data access rules.
+
+1) read-only - this restricts access of vdb to only read i.e selects. This role is given to everybody who has a login
+credetials (use the user called "user" to login with password "user")
+
+2) read-write access - this role gives read access, and also adds write access. i.e. inserts. This access is given only
+to users with "superuser" JAAS role. (use user called "portfolio" to login with password "portfolio")
+
+See the portfolio-vdb.xml for extra xml elements defined for define the above roles. For more information check out
+Reference Guide's Data Roles chapter.
+
+To deploy the VDB, follow same steps as before in the previous example.
+
+To define the new users and their roles to be used with this example,copy both the teiid-security-user.properties,
+teiid-security-roles.properties into "<jboss-as>/server/<profile>/conf/props" directory. Server restart is required after this
+operation.
+
+
+Query Demonstrations:
+
+==== Using the simpleclient example ====
+
+1) Change your working directory to teiid-examples/simpleclient
+
+2) Use the simpleclient example run script, using the following format
+
+$./run.sh localhost 31000 dynamicportfolio "example query"
+
+
+example queries:
+
+1) "select * from product" - this should execute correctly
+
+2) "insert into product (id, symbol,company_name) values (2000,'RHT','Red Hat')" - this will fail with data access error saying
+ that the user named "user" is not allowed write access.
+
+Since this simpleclient example hard coded the default user and password, modify the included JDBCClient.java class
+to take the user name and password from command line and re-execute the query (2) with user name "portfolio"
+and password "portfolio" and see it executes to success!
+
+
\ No newline at end of file
Property changes on: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/README.txt
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/portfolio-vdb.xml
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/portfolio-vdb.xml (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/portfolio-vdb.xml 2011-04-25 19:51:53 UTC (rev 3118)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<vdb name="DynamicPortfolio" version="1">
+
+ <description>A Dynamic VDB</description>
+
+ <!--
+ Setting to use connector supplied metadata. Can be "true" or "cached".
+ "true" will obtain metadata once for every launch of Teiid.
+ "cached" will save a file containing the metadata into
+ the deploy/<vdb name>/<vdb version/META-INF directory
+ -->
+ <property name="UseConnectorMetadata" value="true" />
+
+
+ <!--
+ Each model represents a access to one or more sources.
+ The name of the model will be used as a top level schema name
+ for all of the metadata imported from the connector.
+
+ NOTE: Multiple model, with different import settings, can be bound to
+ the same connector binding and will be treated as the same source at
+ runtime.
+ -->
+ <model name="MarketData">
+ <!--
+ Each source represents a translator and data source. There are
+ pre-defined translators, or you can create one. ConnectionFactories
+ or DataSources in JBoss AS they are typically defined using "xxx-ds.xml" files.
+ -->
+ <source name="text-connector" translator-name="file" connection-jndi-name="java:marketdata-file"/>
+ </model>
+
+ <model name="Accounts">
+ <!--
+ JDBC Import settings
+
+ importer.useFullSchemaName directs the importer to drop the source
+ schema from the Teiid object name, so that the Teiid fully qualified name
+ will be in the form of <model name>.<table name>
+ -->
+ <property name="importer.useFullSchemaName" value="false"/>
+
+ <!--
+ This connector is defined to reference the HSQL localDS"
+ -->
+ <source name="hsql-connector" translator-name="hsql" connection-jndi-name="java:DefaultDS"/>
+ </model>
+
+ <!-- For detailed description about data roles please refer to Reference Guide's Data Roles chapter -->
+ <data-role name="ReadOnly" any-authenticated="true">
+ <description>Allow ReadOnly Operations by default to any authenticated user</description>
+
+ <permission>
+ <resource-name>Accounts</resource-name>
+ <allow-create>false</allow-create>
+ <allow-read>true</allow-read>
+ <allow-update>false</allow-update>
+ </permission>
+
+ <permission>
+ <resource-name>MarketData</resource-name>
+ <allow-create>false</allow-create>
+ <allow-read>true</allow-read>
+ <allow-update>false</allow-update>
+ </permission>
+
+ <!--
+ Since any-authenticated is set to true above, any user who has login credentials to access the VDB
+ will be given this role. No explicit mapping to a JAAS role is not needed.
+ -->
+ <mapped-role-name>anyuser</mapped-role-name>
+ </data-role>
+
+ <data-role name="ReadWrite">
+ <description>Allow Reads and Writes to tables and procedures</description>
+
+ <permission>
+ <resource-name>Accounts</resource-name>
+ <allow-create>false</allow-create>
+ <allow-read>true</allow-read>
+ <allow-update>true</allow-update>
+ </permission>
+
+ <permission>
+ <resource-name>MarketData</resource-name>
+ <allow-create>false</allow-create>
+ <allow-read>true</allow-read>
+ <allow-update>true</allow-update>
+ </permission>
+
+ <!--
+ This role must defined in the JAAS security domain, the sample UserRolesLoginModules based roles file provided
+ in this sample directory. copy these "teiid-security-roles.properties" and "teiid-security-users.proeprties"
+ into "servers/default/conf/props" directory and replace the old ones.
+ -->
+ <mapped-role-name>supervisor</mapped-role-name>
+ </data-role>
+
+
+
+</vdb>
\ No newline at end of file
Property changes on: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/portfolio-vdb.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-roles.properties
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-roles.properties (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-roles.properties 2011-04-25 19:51:53 UTC (rev 3118)
@@ -0,0 +1,3 @@
+# A roles.properties file for use with the UsersRolesLoginModule
+# username=role1,role2
+portfolio=superuser
Property changes on: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-roles.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-users.properties
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-users.properties (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-users.properties 2011-04-25 19:51:53 UTC (rev 3118)
@@ -0,0 +1,4 @@
+# A users.properties file for use with the UsersRolesLoginModule
+# username=password
+user=user
+portfolio=portfolio
\ No newline at end of file
Property changes on: trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/data-roles-ext/teiid-security-users.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
13 years
teiid SVN: r3117 - in branches/7.1.x: client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax and 3 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-25 12:29:57 -0400 (Mon, 25 Apr 2011)
New Revision: 3117
Added:
branches/7.1.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/
branches/7.1.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/
branches/7.1.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java
Modified:
branches/7.1.x/client-jdk15/
branches/7.1.x/common-core/src/main/java/org/teiid/core/types/XMLType.java
Log:
SOA-3025: adding the support for the XMLType
Property changes on: branches/7.1.x/client-jdk15
___________________________________________________________________
Added: svn:ignore
+ target
.classpath
.settings
.project
Added: branches/7.1.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java
===================================================================
--- branches/7.1.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java (rev 0)
+++ branches/7.1.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java 2011-04-25 16:29:57 UTC (rev 3117)
@@ -0,0 +1,21 @@
+package net.sf.retrotranslator.runtime.javax.xml.stream;
+
+public class XMLStreamException_ extends Exception {
+
+ public XMLStreamException_() {
+ super();
+ }
+
+ public XMLStreamException_(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public XMLStreamException_(String message) {
+ super(message);
+ }
+
+ public XMLStreamException_(Throwable cause) {
+ super(cause);
+ }
+
+}
Property changes on: branches/7.1.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/javax/xml/stream/XMLStreamException_.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/7.1.x/common-core/src/main/java/org/teiid/core/types/XMLType.java
===================================================================
--- branches/7.1.x/common-core/src/main/java/org/teiid/core/types/XMLType.java 2011-04-25 16:11:04 UTC (rev 3116)
+++ branches/7.1.x/common-core/src/main/java/org/teiid/core/types/XMLType.java 2011-04-25 16:29:57 UTC (rev 3117)
@@ -131,6 +131,10 @@
this.type = (Type)in.readObject();
} catch (OptionalDataException e) {
this.type = Type.UNKNOWN;
+ } catch(IOException e) {
+ this.type = Type.UNKNOWN;
+ } catch(ClassNotFoundException e) {
+ this.type = Type.UNKNOWN;
}
}
13 years
teiid SVN: r3116 - in branches/451425/engine/src: main/java/org/teiid/query/tempdata and 1 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-25 12:11:04 -0400 (Mon, 25 Apr 2011)
New Revision: 3116
Modified:
branches/451425/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
branches/451425/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
branches/451425/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
Log:
SOA-3037: changes to fix the clustering issue 421425
Modified: branches/451425/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
===================================================================
--- branches/451425/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2011-04-25 15:44:23 UTC (rev 3115)
+++ branches/451425/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2011-04-25 16:11:04 UTC (rev 3116)
@@ -140,6 +140,7 @@
}
this.results = buffer;
bufferManager.addTupleBuffer(this.results);
+ this.results.close();
}
return true;
} catch (TeiidComponentException e) {
Modified: branches/451425/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- branches/451425/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-04-25 15:44:23 UTC (rev 3115)
+++ branches/451425/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-04-25 16:11:04 UTC (rev 3116)
@@ -396,10 +396,10 @@
key.vdb = new VDBKey(context.getVdbName(), context.getVdbVersion());
MatTableEntry entry = this.tables.get(key);
- if (entry != null && entry.lastUpdate > info.getUpdateTime()
- && info.getState() != MatState.LOADING) {
+ boolean firstload = !info.isValid();
+ if (entry != null && entry.lastUpdate > info.getUpdateTime() && info.getState() != MatState.LOADING) {
//remote load
- info.setState(MatState.NEEDS_LOADING, entry.valid, null);
+ info.setState(MatState.NEEDS_LOADING, firstload?false:entry.valid, null);
loadTime = entry.lastUpdate;
}
}
Modified: branches/451425/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java
===================================================================
--- branches/451425/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2011-04-25 15:44:23 UTC (rev 3115)
+++ branches/451425/engine/src/test/java/org/teiid/dqp/internal/process/TestCachedResults.java 2011-04-25 16:11:04 UTC (rev 3116)
@@ -23,6 +23,7 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -125,6 +126,7 @@
TupleBuffer cachedTb = cachedResults.getResults();
+ assertTrue(cachedTb.isFinal());
assertEquals(tb.getRowCount(), cachedTb.getRowCount());
assertEquals(tb.getBatchSize(), cachedTb.getBatchSize());
13 years
teiid SVN: r3115 - branches.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-25 11:44:23 -0400 (Mon, 25 Apr 2011)
New Revision: 3115
Added:
branches/451425/
Log:
00451425:Clustered Caching Not Working
13 years
teiid SVN: r3114 - in trunk: connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc and 3 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-04-25 11:26:44 -0400 (Mon, 25 Apr 2011)
New Revision: 3114
Added:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
Log:
TEIID-1495 - Reverified teradata translator with correct capabilities
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-04-25 15:09:21 UTC (rev 3113)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-04-25 15:26:44 UTC (rev 3114)
@@ -22,60 +22,281 @@
package org.teiid.translator.jdbc.teradata;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.Function;
+import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
/**
- * for Teradata database Release V2R5.1
+ * Teradata database Release 12
*/
@Translator(name="teradata", description="A translator for Teradata Database")
public class TeradataExecutionFactory extends JDBCExecutionFactory {
+ public static String TERADATA = "teradata"; //$NON-NLS-1$
+ protected ConvertModifier convert = new ConvertModifier();
+
public TeradataExecutionFactory() {
setSupportsOuterJoins(false);
}
+ @Override
+ public void start() throws TranslatorException {
+ super.start();
+ convert.addTypeMapping("byteint", FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.BOOLEAN); //$NON-NLS-1$
+ convert.addTypeMapping("double precision", FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convert.addTypeMapping("numeric(18,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convert.addConvert(FunctionModifier.INTEGER, FunctionModifier.STRING, new NumericToStringModifier(12));
+ convert.addConvert(FunctionModifier.BIGDECIMAL, FunctionModifier.STRING, new NumericToStringModifier(38));
+ convert.addConvert(FunctionModifier.BIGINTEGER, FunctionModifier.STRING, new NumericToStringModifier(38));
+ convert.addConvert(FunctionModifier.FLOAT, FunctionModifier.STRING, new NumericToStringModifier(25));
+ convert.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new NumericToStringModifier(1));
+ convert.addConvert(FunctionModifier.LONG, FunctionModifier.STRING, new NumericToStringModifier(25));
+ convert.addConvert(FunctionModifier.SHORT, FunctionModifier.STRING, new NumericToStringModifier(12));
+ convert.addConvert(FunctionModifier.DOUBLE, FunctionModifier.STRING, new NumericToStringModifier(25));
+ convert.addConvert(FunctionModifier.BYTE, FunctionModifier.STRING, new NumericToStringModifier(4));
+ convert.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
+ convert.addNumericBooleanConversions();
+
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
+
+ registerFunctionModifier(SourceSystemFunctions.RAND, new AliasModifier("random")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.NULLIF, new AliasModifier("NULLIFZERO")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("ZEROIFNULL")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("LN")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("LOWER")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("UPPER")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LENGTH, new AliasModifier("CHARACTER_LENGTH")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CURDATE, new AliasModifier("CURRENT_DATE")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CURTIME, new AliasModifier("CURRENT_TIME")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr"));//$NON-NLS-1$
+
+ registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractModifier("YEAR")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractModifier("MONTH")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractModifier("DAY")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractModifier("HOUR")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractModifier("MINUTE")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractModifier("SECOND")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("position(",function.getParameters().get(0)," in ",function.getParameters().get(1) ,")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ });
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory()));
+ }
+
+ @Override
+ public SQLConversionVisitor getSQLConversionVisitor() {
+ return new TeradataSQLConversionVisitor(this);
+ }
+
+
@Override
public List getSupportedFunctions() {
- List supportedFunctions = new ArrayList();
+ List<String> supportedFunctions = new ArrayList<String>();
supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
-// supportedFunctions.add("LOG"); //$NON-NLS-1$ // "LN"
-// supportedFunctions.add("LOG10"); //$NON-NLS-1$ // "LOG"
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
+
+ supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ACOS);
+ supportedFunctions.add(SourceSystemFunctions.ASIN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN2);
+ supportedFunctions.add(SourceSystemFunctions.COS);
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.EXP);
+ supportedFunctions.add(SourceSystemFunctions.LOG);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.TAN);
supportedFunctions.add("||"); //$NON-NLS-1$
-// supportedFunctions.add("CONCAT"); //$NON-NLS-1$ // "||"
-// supportedFunctions.add("LCASE"); //$NON-NLS-1$ // "LOWER"
-// supportedFunctions.add("LOCATE"); //$NON-NLS-1$ //"POSITION", "INDEX" ?
- supportedFunctions.add("LOWER"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
-// supportedFunctions.add("UCASE"); //$NON-NLS-1$ // "UPPER"
- supportedFunctions.add("UPPER"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
- supportedFunctions.add("DAY"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- //supportedFunctions.add("CONVERT"); //$NON-NLS-1$ "CAST"
-
return supportedFunctions;
}
+
+ @Override
+ public List<FunctionMethod> getPushDownFunctions(){
+
+ List<FunctionMethod> pushdownFunctions = new ArrayList<FunctionMethod>();
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "COSH", "COSH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic Cos")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "SINH", "SINH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic Sin")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "TANH", "TANH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic Tanh")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ACOSH", "ACOSH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic ArcCos")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ASINH", "ASINH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic ArcSin")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ATANH", "ATANH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic ArcTan")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "CHAR2HEXINT", "CHAR2HEXINT", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "INDEX", "INDEX", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "BYTES", "BYTES", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "OCTET_LENGTH", "OCTET_LENGTH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHAMP", "HASHAMP", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHBAKAMP", "HASHBAKAMP", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHBUCKET", "HASHBUCKET", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHROW", "HASHROW", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {
+ new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ return pushdownFunctions;
+ }
+
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "cast('" + formatDateValue(dateValue) + "' AS DATE FORMAT 'yyyy-mm-dd')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "cast('" + formatDateValue(timeValue) + "' AS TIME(0) FORMAT 'hh:mi:ss')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "cast('" + formatDateValue(timestampValue) + "' AS TIMESTAMP(6))"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ // Teradata also supports MINUS & ALL set operators
+ // more aggregates available
+
+ @Override
+ public boolean supportsScalarSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesEnhancedNumeric() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCommonTableExpressions() {
+ return false;
+ }
+
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.FIRST;
+ }
+
+ @Override
+ public boolean supportsSetQueryOrderBy() {
+ return false;
+ }
+
+ public static class ExtractModifier extends FunctionModifier {
+ private String type;
+ public ExtractModifier(String type) {
+ this.type = type;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("extract(",this.type," from ",function.getParameters().get(0) ,")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ public static class NumericToStringModifier extends FunctionModifier {
+ private int charSize;
+ public NumericToStringModifier(int size) {
+ this.charSize = size;
+ }
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("TRIM(BOTH FROM ",function.getParameters().get(0), " (FORMAT 'Z')(CHAR("+this.charSize+")))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
}
Added: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java 2011-04-25 15:26:44 UTC (rev 3114)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.jdbc.teradata;
+
+import java.util.List;
+
+import org.teiid.language.AndOr;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.language.Expression;
+import org.teiid.language.In;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.AndOr.Operator;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+
+public class TeradataSQLConversionVisitor extends SQLConversionVisitor {
+
+ public TeradataSQLConversionVisitor(TeradataExecutionFactory ef) {
+ super(ef);
+ }
+
+ @Override
+ public void visit(In obj) {
+ List<Expression> exprs = obj.getRightExpressions();
+
+ Class expectedType = obj.getLeftExpression().getType();
+
+ boolean decompose = false;
+ for (Expression expr:exprs) {
+ if (!(expr.getType().equals(expectedType)) || (!(expr.getType().isAssignableFrom(Number.class)) && !expr.getType().isAssignableFrom(String.class))) {
+ decompose = true;
+ }
+ }
+
+ if (decompose) {
+ if (exprs.size() > 1) {
+ Condition left = LanguageFactory.INSTANCE.createCompareCriteria(Comparison.Operator.EQ, obj.getLeftExpression(), exprs.get(0));
+ for (int i = 1; i < exprs.size(); i++) {
+ AndOr replace = LanguageFactory.INSTANCE.createAndOr(Operator.OR, left, LanguageFactory.INSTANCE.createCompareCriteria(Comparison.Operator.EQ, obj.getLeftExpression(), exprs.get(i)));
+ left = replace;
+ }
+ super.visit((AndOr)left);
+ }
+ else {
+ super.visit(LanguageFactory.INSTANCE.createCompareCriteria(Comparison.Operator.EQ, obj.getLeftExpression(), exprs.get(0)));
+ }
+ }
+ else {
+ super.visit(obj);
+ }
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataSQLConversionVisitor.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-04-25 15:09:21 UTC (rev 3113)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-04-25 15:26:44 UTC (rev 3114)
@@ -25,7 +25,9 @@
import static org.junit.Assert.assertEquals;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import javax.xml.bind.JAXBException;
@@ -48,7 +50,7 @@
public static final String BQT_VDB = "/bqt.vdb"; //$NON-NLS-1$
public static Command helpTranslate(String vdbFileName, String sql) {
- return helpTranslate(vdbFileName, null, sql);
+ return helpTranslate(vdbFileName, null, null, sql);
}
public static TranslationUtility getTranslationUtility(String vdbFileName, String udf) {
@@ -78,8 +80,24 @@
}
}
- public static Command helpTranslate(String vdbFileName, String udf, String sql) {
- return getTranslationUtility(vdbFileName, udf).parseCommand(sql);
+ public static Command helpTranslate(String vdbFileName, String udf, List<FunctionMethod> pushdowns, String sql) {
+ TranslationUtility util = getTranslationUtility(vdbFileName, null);
+
+ Collection <FunctionMethod> methods = new ArrayList<FunctionMethod>();
+ if (udf != null) {
+ try {
+ methods.addAll(FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream()));
+ } catch (JAXBException e) {
+ throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
+ } catch (IOException e) {
+ throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
+ }
+ }
+ if (pushdowns != null) {
+ methods.addAll(pushdowns);
+ }
+ util.setUDF(methods);
+ return util.parseCommand(sql);
}
public static void helpTestVisitor(String vdb, String input, String expectedOutput, JDBCExecutionFactory translator) throws TranslatorException {
@@ -88,7 +106,7 @@
public static void helpTestVisitor(String vdb, String udf, String input, String expectedOutput, JDBCExecutionFactory translator) throws TranslatorException {
// Convert from sql to objects
- Command obj = helpTranslate(vdb, udf, input);
+ Command obj = helpTranslate(vdb, udf, translator.getPushDownFunctions(), input);
helpTestVisitor(expectedOutput, translator, obj);
}
Added: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java 2011-04-25 15:26:44 UTC (rev 3114)
@@ -0,0 +1,138 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.jdbc.teradata;
+
+import static org.junit.Assert.assertEquals;
+
+import java.sql.Date;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.In;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.SQLConversionVisitor;
+import org.teiid.translator.jdbc.TranslationHelper;
+
+@SuppressWarnings("nls")
+public class TestTeradataTranslator {
+
+ private static TeradataExecutionFactory TRANSLATOR;
+ private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
+
+ @BeforeClass
+ public static void setUp() throws TranslatorException {
+ TRANSLATOR = new TeradataExecutionFactory();
+ TRANSLATOR.setUseBindVariables(false);
+ TRANSLATOR.start();
+ }
+
+ public void helpTest(Expression srcExpression, String tgtType, String expectedExpression) throws Exception {
+ Function func = LANG_FACTORY.createFunction("convert",
+ Arrays.asList( srcExpression,LANG_FACTORY.createLiteral(tgtType, String.class)),TypeFacility.getDataTypeClass(tgtType));
+
+ assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType,
+ expectedExpression, helpGetString(func));
+ }
+
+ public String helpGetString(Expression expr) throws Exception {
+ SQLConversionVisitor sqlVisitor = TRANSLATOR.getSQLConversionVisitor();
+ sqlVisitor.append(expr);
+
+ return sqlVisitor.toString();
+ }
+
+ @Test public void testSubstring1() throws Exception {
+ String input = "SELECT dayofmonth(datevalue) FROM BQT1.SMALLA";
+ String output = "SELECT extract(DAY from SmallA.DateValue) FROM SmallA";
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
+ }
+
+ @Test public void testByteToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "TRIM(BOTH FROM 1 (FORMAT 'Z')(CHAR(4)))");
+ }
+
+ @Test public void testDoubleToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.0), Double.class), "string", "TRIM(BOTH FROM 1.0 (FORMAT 'Z')(CHAR(25)))");
+ }
+
+ @Test public void testInDecompose() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createLiteral("2", String.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' IN ('2', '3')", helpGetString(expr));
+ }
+
+ @Test public void testSingleInDecompose() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createLiteral("2", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' IN ('2')", helpGetString(expr));
+ }
+
+ @Test public void testInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+ right.add(LANG_FACTORY.createLiteral("3", String.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' = func() OR '1' = '3'", helpGetString(expr));
+ }
+
+ @Test public void testsingleInDecomposeNonLiterals() throws Exception {
+ Expression left = LANG_FACTORY.createLiteral("1", String.class);
+ List<Expression> right = new ArrayList<Expression>();
+ right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
+
+ In expr = LANG_FACTORY.createIn(left,right, false);
+
+ assertEquals("'1' = func()", helpGetString(expr));
+ }
+
+ @Test public void testNullComapreNull() throws Exception {
+ String input = "SELECT INTKEY, STRINGKEY, DOUBLENUM FROM bqt1.smalla WHERE NULL <> NULL";
+ String out = "SELECT SmallA.IntKey, SmallA.StringKey, SmallA.DoubleNum FROM SmallA WHERE 1 = 0";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, new TeradataExecutionFactory());
+ }
+
+ @Test public void testPushDownFunction() throws Exception {
+ String input = "SELECT teradata.HASHBAKAMP(STRINGKEY) DOUBLENUM FROM bqt1.smalla";
+ String out = "SELECT HASHBAKAMP(SmallA.StringKey) AS DOUBLENUM FROM SmallA";
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, null, input, out, new TeradataExecutionFactory());
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/teradata/TestTeradataTranslator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-04-25 15:09:21 UTC (rev 3113)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-04-25 15:26:44 UTC (rev 3114)
@@ -626,6 +626,8 @@
}
if(crit == TRUE_CRITERIA) {
query.setCriteria(null);
+ } else if (crit == UNKNOWN_CRITERIA) {
+ query.setCriteria(FALSE_CRITERIA);
} else {
query.setCriteria(crit);
}
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-04-25 15:09:21 UTC (rev 3113)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-04-25 15:26:44 UTC (rev 3114)
@@ -834,7 +834,7 @@
@Test public void testCompareSubqueryUnknown() {
helpTestRewriteCommand("SELECT e1 FROM pm1.g1 WHERE null = SOME (SELECT e1 FROM pm1.g2)", //$NON-NLS-1$
- "SELECT e1 FROM pm1.g1 WHERE null <> null"); //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g1 WHERE 1 = 0"); //$NON-NLS-1$
}
@Test public void testINClauseSubquery() {
13 years