Author: shawkins
Date: 2011-08-18 16:41:00 -0400 (Thu, 18 Aug 2011)
New Revision: 3397
Modified:
branches/7.5.x/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
branches/7.5.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
branches/7.5.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
branches/7.5.x/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
branches/7.5.x/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java
branches/7.5.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
branches/7.5.x/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
branches/7.5.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
branches/7.5.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties
branches/7.5.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
Log:
forward merge of 7.4.1 fixes
Modified: branches/7.5.x/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
===================================================================
---
branches/7.5.x/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2011-08-18
20:34:01 UTC (rev 3396)
+++
branches/7.5.x/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2011-08-18
20:41:00 UTC (rev 3397)
@@ -191,8 +191,8 @@
throw new TeiidSQLException(msg);
}
- public ResultsFuture<Boolean> submitExecute() throws SQLException {
- return executeSql(new String[] {this.prepareSql}, false, ResultsMode.EITHER,
false);
+ public ResultsFuture<Boolean> submitExecute(ResultsMode mode) throws
SQLException {
+ return executeSql(new String[] {this.prepareSql}, false, mode, false);
}
@Override
@@ -236,14 +236,6 @@
return message;
}
- /**
- * <p>Retreives a ResultSetMetaData object with information about the numbers,
- * types, and properties of columns in the ResultSet object that will be returned
- * when this preparedstatement object is executed.
- * @return ResultSetMetaData object
- * @throws SQLException, currently there is no means of getting results
- * metadata before getting results.
- */
public ResultSetMetaData getMetaData() throws SQLException {
// check if the statement is open
Modified: branches/7.5.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- branches/7.5.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2011-08-18
20:34:01 UTC (rev 3396)
+++ branches/7.5.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2011-08-18
20:41:00 UTC (rev 3397)
@@ -245,6 +245,7 @@
public void onCompletion(ResultsFuture<ResultsMessage> future) {
try {
batchResults.setBatch(processBatch(future.get()));
+ result.getResultsReceiver().receiveResults(next());
} catch (Throwable t) {
result.getResultsReceiver().exceptionOccurred(t);
}
@@ -253,13 +254,6 @@
return result;
}
- /**
- * Move row pointer forward one row. This may cause the cursor
- * to fetch more rows.
- * @return True if the current index is on a valid row, false if
- * the pointer is past the end of the rows
- * @throws SQLException if this result set has an exception
- */
public boolean next() throws SQLException {
checkClosed();
if (hasNext()) {
@@ -269,24 +263,12 @@
return false;
}
- /**
- * Move row pointer backward one row. This may cause the cursor
- * to fetch more rows.
- * @return True if the current index is on a valid row, false if
- * the pointer is before the beginning of the rows
- * @throws SQLException if this result set has an exception
- */
public boolean previous() throws SQLException {
checkClosed();
checkNotForwardOnly();
return batchResults.previous();
}
- /**
- * Get current row pointer.
- * @return Index of current row
- * @throws SQLException if this result set has an exception
- */
public int getRow() throws SQLException {
checkClosed();
if (isAfterLast()) {
Modified: branches/7.5.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/7.5.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2011-08-18
20:34:01 UTC (rev 3396)
+++ branches/7.5.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java 2011-08-18
20:41:00 UTC (rev 3397)
@@ -423,7 +423,7 @@
JDBCURL.addNormalizedProperty(key, value,
this.driverConnection.getExecutionProperties());
}
this.updateCounts = new int[] {0};
- return booleanFuture(true);
+ return booleanFuture(false);
}
match = TRANSACTION_STATEMENT.matcher(commands[0]);
if (match.matches()) {
Modified:
branches/7.5.x/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
---
branches/7.5.x/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2011-08-18
20:34:01 UTC (rev 3396)
+++
branches/7.5.x/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2011-08-18
20:41:00 UTC (rev 3397)
@@ -116,11 +116,9 @@
TempTableStore tempTableStore = null;
if(requestManager != null) {
- if (workItem != null) {
- ClientState state =
requestManager.getClientState(workContext.getSessionId(), false);
- if (state != null) {
- tempTableStore = state.sessionTables;
- }
+ ClientState state = requestManager.getClientState(workContext.getSessionId(),
false);
+ if (state != null) {
+ tempTableStore = state.sessionTables;
}
}
if(tempTableStore != null) {
Modified: branches/7.5.x/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java
===================================================================
--- branches/7.5.x/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java 2011-08-18
20:34:01 UTC (rev 3396)
+++ branches/7.5.x/runtime/src/main/java/org/teiid/odbc/ODBCClientRemote.java 2011-08-18
20:41:00 UTC (rev 3397)
@@ -21,7 +21,6 @@
*/
package org.teiid.odbc;
-import java.io.IOException;
import java.sql.ParameterMetaData;
import java.util.List;
import java.util.Properties;
@@ -75,7 +74,7 @@
void sendMoveCursor(ResultSetImpl rs, int rowCount, ResultsFuture<Integer>
results);
- void sendCommandComplete(String sql, int updateCount) throws IOException;
+ void sendCommandComplete(String sql, int updateCount);
// CommandComplete (B)
void sendUpdateCount(String sql, int updateCount);
Modified: branches/7.5.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
---
branches/7.5.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-08-18
20:34:01 UTC (rev 3396)
+++
branches/7.5.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-08-18
20:41:00 UTC (rev 3397)
@@ -40,6 +40,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.teiid.client.RequestMessage.ResultsMode;
import org.teiid.client.util.ResultsFuture;
import org.teiid.core.util.ApplicationInfo;
import org.teiid.core.util.StringUtil;
@@ -211,121 +212,88 @@
}
private void cursorExecute(final String cursorName, final String sql, final
ResultsFuture<Integer> completion) {
- if (this.connection != null) {
- if (sql != null) {
- try {
- // close if the name is already used or the unnamed prepare; otherwise
- // stmt is alive until session ends.
- Prepared previous = this.preparedMap.remove(cursorName);
- if (previous != null) {
- previous.stmt.close();
- }
-
- final PreparedStatementImpl stmt = this.connection.prepareStatement(sql);
- this.executionFuture = stmt.submitExecute();
- this.executionFuture.addCompletionListener(new
ResultsFuture.CompletionListener<Boolean>() {
- @Override
- public void onCompletion(ResultsFuture<Boolean> future) {
- executionFuture = null;
- try {
- if (future.get()) {
- List<PgColInfo> cols =
getPgColInfo(stmt.getResultSet().getMetaData());
- cursorMap.put(cursorName, new Cursor(cursorName, sql, stmt,
null, stmt.getResultSet(), cols));
- client.sendCommandComplete("DECLARE CURSOR", 0); //$NON-NLS-1$
- }
- else {
-
errorOccurred(RuntimePlugin.Util.getString("execution_failed")); //$NON-NLS-1$
- }
- } catch (Throwable e) {
- errorOccurred(e);
- }
- completion.getResultsReceiver().receiveResults(1);
- }
- });
- } catch (SQLException e) {
- errorOccurred(e);
- completion.getResultsReceiver().receiveResults(1);
- }
- }
+ if (sql != null) {
+ try {
+ // close if the name is already used or the unnamed prepare; otherwise
+ // stmt is alive until session ends.
+ Prepared previous = this.preparedMap.remove(cursorName);
+ if (previous != null) {
+ previous.stmt.close();
+ }
+
+ final PreparedStatementImpl stmt = this.connection.prepareStatement(sql);
+ this.executionFuture = stmt.submitExecute(ResultsMode.RESULTSET);
+ this.executionFuture.addCompletionListener(new
ResultsFuture.CompletionListener<Boolean>() {
+ @Override
+ public void onCompletion(ResultsFuture<Boolean> future) {
+ executionFuture = null;
+ try {
+ List<PgColInfo> cols =
getPgColInfo(stmt.getResultSet().getMetaData());
+ cursorMap.put(cursorName, new Cursor(cursorName, sql, stmt,
null, stmt.getResultSet(), cols));
+ client.sendCommandComplete("DECLARE CURSOR", 0); //$NON-NLS-1$
+ completion.getResultsReceiver().receiveResults(0);
+ } catch (Throwable e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
+ }
+ }
+ });
+ } catch (SQLException e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
+ }
}
- else {
- errorOccurred(RuntimePlugin.Util.getString("no_active_connection"));
//$NON-NLS-1$
- completion.getResultsReceiver().receiveResults(1);
- }
-
}
- private void cursorFetch(String cursorName, int rows, final ResultsFuture<Integer>
completion) {
+ private void cursorFetch(String cursorName, int rows, final ResultsFuture<Integer>
completion) throws SQLException {
Cursor cursor = this.cursorMap.get(cursorName);
- if (cursor != null) {
- cursor.fetchSize = rows;
- ResultsFuture<Integer> result = new ResultsFuture<Integer>();
- this.client.sendCursorResults(cursor.rs, cursor.columnMetadata, result, rows);
- result.addCompletionListener(new ResultsFuture.CompletionListener<Integer>() {
- public void onCompletion(ResultsFuture<Integer> future) {
- int rowsSent = 0;
- try {
- rowsSent = future.get();
- client.sendCommandComplete("FETCH", rowsSent); //$NON-NLS-1$
- } catch (InterruptedException e) {
- throw new AssertionError(e);
- } catch (ExecutionException e) {
- errorOccurred(e.getCause());
- } catch (IOException e) {
- errorOccurred(e);
- }
- completion.getResultsReceiver().receiveResults(rowsSent);
- };
- });
+ if (cursor == null) {
+ throw new SQLException(RuntimePlugin.Util.getString("not_bound",
cursorName)); //$NON-NLS-1$
}
- else {
- errorOccurred(RuntimePlugin.Util.getString("not_bound", cursorName));
//$NON-NLS-1$
- completion.getResultsReceiver().receiveResults(1);
- }
+ cursor.fetchSize = rows;
+ ResultsFuture<Integer> result = new ResultsFuture<Integer>();
+ this.client.sendCursorResults(cursor.rs, cursor.columnMetadata, result, rows);
+ result.addCompletionListener(new ResultsFuture.CompletionListener<Integer>() {
+ public void onCompletion(ResultsFuture<Integer> future) {
+ try {
+ int rowsSent = future.get();
+ client.sendCommandComplete("FETCH", rowsSent); //$NON-NLS-1$
+ completion.getResultsReceiver().receiveResults(rowsSent);
+ } catch (Throwable e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
+ }
+ };
+ });
}
- private void cursorMove(String prepareName, int rows, final ResultsFuture<Integer>
completion) {
+ private void cursorMove(String prepareName, int rows, final ResultsFuture<Integer>
completion) throws SQLException {
// win odbc driver sending a move after close; and error is ending up in failure; since
the below
// is not harmful it is ok to send empty move.
if (rows == 0) {
- try {
- client.sendCommandComplete("MOVE", 0); //$NON-NLS-1$
- } catch (IOException e) {
- errorOccurred(e);
- }
+ client.sendCommandComplete("MOVE", 0); //$NON-NLS-1$
completion.getResultsReceiver().receiveResults(0);
return;
}
Cursor cursor = this.cursorMap.get(prepareName);
- if (cursor != null) {
- ResultsFuture<Integer> result = new ResultsFuture<Integer>();
- this.client.sendMoveCursor(cursor.rs, rows, result);
- result.addCompletionListener(new ResultsFuture.CompletionListener<Integer>() {
- public void onCompletion(ResultsFuture<Integer> future) {
- int rowsMoved = 0;
- try {
- rowsMoved = future.get();
- client.sendCommandComplete("MOVE", rowsMoved); //$NON-NLS-1$
- } catch (InterruptedException e) {
- throw new AssertionError(e);
- } catch (ExecutionException e) {
- errorOccurred(e.getCause());
- } catch (IOException e) {
- errorOccurred(e);
- }
- completion.getResultsReceiver().receiveResults(rowsMoved);
- };
- });
+ if (cursor == null) {
+ throw new SQLException(RuntimePlugin.Util.getString("not_bound",
prepareName)); //$NON-NLS-1$
}
- else {
- errorOccurred(RuntimePlugin.Util.getString("not_bound", prepareName));
//$NON-NLS-1$
- completion.getResultsReceiver().receiveResults(1);
- }
+ ResultsFuture<Integer> result = new ResultsFuture<Integer>();
+ this.client.sendMoveCursor(cursor.rs, rows, result);
+ result.addCompletionListener(new ResultsFuture.CompletionListener<Integer>() {
+ public void onCompletion(ResultsFuture<Integer> future) {
+ try {
+ int rowsMoved = future.get();
+ client.sendCommandComplete("MOVE", rowsMoved); //$NON-NLS-1$
+ completion.getResultsReceiver().receiveResults(rowsMoved);
+ } catch (Throwable e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
+ }
+ };
+ });
}
- private void cursorClose(String prepareName) throws SQLException, IOException {
+ private void cursorClose(String prepareName) throws SQLException {
Cursor cursor = this.cursorMap.remove(prepareName);
if (cursor != null) {
cursor.rs.close();
@@ -345,15 +313,8 @@
try {
ResultsFuture<Integer> result = new ResultsFuture<Integer>();
if (future.get()) {
- if (stmt.getResultSet() != null) {
- List<PgColInfo> cols =
getPgColInfo(stmt.getResultSet().getMetaData());
- client.sendResults(sql, stmt.getResultSet(), cols, result,
true);
- }
- else {
- // handles the "SET" commands.
- client.sendUpdateCount(sql, 0);
- result.getResultsReceiver().receiveResults(1);
- }
+ List<PgColInfo> cols =
getPgColInfo(stmt.getResultSet().getMetaData());
+ client.sendResults(sql, stmt.getResultSet(), cols, result,
true);
} else {
client.sendUpdateCount(sql, stmt.getUpdateCount());
setEncoding();
@@ -362,16 +323,20 @@
result.addCompletionListener(new
ResultsFuture.CompletionListener<Integer>() {
public void onCompletion(ResultsFuture<Integer> future) {
try {
- stmt.close();
- } catch (SQLException e) {
- LogManager.logDetail(LogConstants.CTX_ODBC, e, "Error closing
statement"); //$NON-NLS-1$
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ LogManager.logDetail(LogConstants.CTX_ODBC, e, "Error closing
statement"); //$NON-NLS-1$
+ }
+ future.get();
+ completion.getResultsReceiver().receiveResults(1);
+ } catch (Throwable e) {
+ completion.getResultsReceiver().exceptionOccurred(e);
}
- completion.getResultsReceiver().receiveResults(1);
}
});
} catch (Throwable e) {
- errorOccurred(e);
- completion.getResultsReceiver().receiveResults(1);
+ completion.getResultsReceiver().exceptionOccurred(e);
}
}
});
@@ -379,33 +344,27 @@
@Override
public void prepare(String prepareName, String sql, int[] paramType) {
- if (this.connection != null) {
-
- if (prepareName == null || prepareName.length() == 0) {
- prepareName = UNNAMED;
- }
-
- if (sql != null) {
- String modfiedSQL = fixSQL(sql);
- try {
- // close if the name is already used or the unnamed prepare; otherwise
- // stmt is alive until session ends.
- Prepared previous = this.preparedMap.remove(prepareName);
- if (previous != null) {
- previous.stmt.close();
- }
+ if (prepareName == null || prepareName.length() == 0) {
+ prepareName = UNNAMED;
+ }
- PreparedStatementImpl stmt = this.connection.prepareStatement(modfiedSQL);
- this.preparedMap.put(prepareName, new Prepared(prepareName, sql, stmt, paramType));
- this.client.prepareCompleted(prepareName);
- } catch (SQLException e) {
- errorOccurred(e);
+ if (sql != null) {
+ String modfiedSQL = fixSQL(sql);
+ try {
+ // close if the name is already used or the unnamed prepare; otherwise
+ // stmt is alive until session ends.
+ Prepared previous = this.preparedMap.remove(prepareName);
+ if (previous != null) {
+ previous.stmt.close();
}
+
+ PreparedStatementImpl stmt = this.connection.prepareStatement(modfiedSQL);
+ this.preparedMap.put(prepareName, new Prepared(prepareName, sql, stmt, paramType));
+ this.client.prepareCompleted(prepareName);
+ } catch (SQLException e) {
+ errorOccurred(e);
}
}
- else {
- errorOccurred(RuntimePlugin.Util.getString("no_active_connection"));
//$NON-NLS-1$
- }
}
@Override
@@ -484,7 +443,7 @@
stmt.setMaxRows(maxRows);
}
- this.executionFuture = stmt.submitExecute();
+ this.executionFuture = stmt.submitExecute(ResultsMode.EITHER);
executionFuture.addCompletionListener(new
ResultsFuture.CompletionListener<Boolean>() {
@Override
public void onCompletion(ResultsFuture<Boolean> future) {
@@ -539,8 +498,6 @@
throw new AssertionError(e);
} catch (ExecutionException e) {
errorOccurred(e.getCause());
- } catch (IOException e) {
- errorOccurred(e);
}
};
});
@@ -902,7 +859,11 @@
client.errorOccurred(e);
return;
} catch (ExecutionException e) {
- client.errorOccurred(e.getCause());
+ Throwable cause = e;
+ while (cause instanceof ExecutionException && cause.getCause() !=
null && cause != cause.getCause()) {
+ cause = cause.getCause();
+ }
+ client.errorOccurred(cause);
return;
}
QueryWorkItem.this.run(); //continue processing
@@ -962,6 +923,9 @@
private List<PgColInfo> getPgColInfo(ResultSetMetaData meta)
throws SQLException {
+ if (meta == null) {
+ return null;
+ }
int columns = meta.getColumnCount();
final ArrayList<PgColInfo> result = new ArrayList<PgColInfo>(columns);
for (int i = 1; i < columns + 1; i++) {
Modified:
branches/7.5.x/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java
===================================================================
---
branches/7.5.x/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2011-08-18
20:34:01 UTC (rev 3396)
+++
branches/7.5.x/runtime/src/main/java/org/teiid/transport/ODBCClientInstance.java 2011-08-18
20:41:00 UTC (rev 3397)
@@ -21,6 +21,7 @@
*/
package org.teiid.transport;
+import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -88,6 +89,7 @@
@Override
public void exceptionOccurred(Throwable t) {
+ LogManager.log(t instanceof IOException?MessageLevel.DETAIL:MessageLevel.ERROR,
LogConstants.CTX_ODBC, t, "Unhandled exception, closing client instance");
//$NON-NLS-1$
server.terminate();
}
Modified: branches/7.5.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
---
branches/7.5.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-08-18
20:34:01 UTC (rev 3396)
+++
branches/7.5.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2011-08-18
20:41:00 UTC (rev 3397)
@@ -97,6 +97,7 @@
private int rows2Send;
private int rowsSent = 0;
private int rowsInBuffer = 0;
+ String sql;
private ResultsWorkItem(List<PgColInfo> cols, ResultSetImpl rs,
ResultsFuture<Integer> result, int rows2Send) {
this.cols = cols;
@@ -150,6 +151,9 @@
}
} else {
sendContents();
+ if (sql != null) {
+ sendCommandComplete(sql, 0);
+ }
result.getResultsReceiver().receiveResults(rowsSent);
processNext = false;
}
@@ -355,8 +359,8 @@
sendRowDescription(cols);
}
ResultsWorkItem r = new ResultsWorkItem(cols, rs, result, -1);
+ r.sql = sql;
r.run();
- sendCommandComplete(sql, 0);
}
@Override
@@ -602,6 +606,12 @@
}
private void sendRowDescription(List<PgColInfo> cols) {
+ if (cols == null) {
+ //send NoData
+ startMessage('n');
+ sendMessage();
+ return;
+ }
startMessage('T');
writeShort(cols.size());
for (PgColInfo info : cols) {
@@ -785,6 +795,7 @@
private void sendContents() {
ChannelBuffer cb = this.dataOut;
this.dataOut = null;
+ this.writer = null;
Channels.write(this.ctx, this.message.getFuture(), cb,
this.message.getRemoteAddress());
}
Modified: branches/7.5.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- branches/7.5.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2011-08-18
20:34:01 UTC (rev 3396)
+++ branches/7.5.x/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2011-08-18
20:41:00 UTC (rev 3397)
@@ -82,7 +82,6 @@
name_not_found=Translator property "name" not defined for the deployment
"{0}"
translator_type_not_found=The parent translator defined not found in configuration
"{0}"
failed_to_load_odbc_metadata=Failed to load the ODBC metadata repository.
-no_active_connection=No active connection found
bad_binding=Binding on a statement, that has not been prepared:{0}
not_bound=No bound statement found with name {0}
no_stmt_found=No prepared statement found with name {0}
@@ -92,6 +91,5 @@
ambigious_name=Ambiguous VDB name specified. Only single occurrence of the "."
is allowed in the VDB name. Also, when version based vdb name is specified, then a
separate "version" connection option is not allowed:{0}.{1}
lo_not_supported=LO functions are not supported
SSLConfiguration.no_anonymous=The anonymous cipher suite TLS_DH_anon_WITH_AES_128_CBC_SHA
is not available. Please change the transport to be non-SSL or use non-anonymous SSL.
-execution_failed=Cursor execution failed
PgBackendProtocol.ssl_error=Could not initialize ODBC SSL. non-SSL connections will
still be allowed.
\ No newline at end of file
Modified:
branches/7.5.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
===================================================================
---
branches/7.5.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2011-08-18
20:34:01 UTC (rev 3396)
+++
branches/7.5.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java 2011-08-18
20:41:00 UTC (rev 3397)
@@ -128,7 +128,7 @@
config.setBindAddress(addr.getHostName());
config.setPortNumber(0);
odbcTransport = new ODBCSocketListener(config,
BufferManagerFactory.getStandaloneBufferManager(), 0, 100000);
- odbcTransport.setMaxBufferSize(100); //set to a small size to ensure buffering over
the limit works
+ odbcTransport.setMaxBufferSize(1000); //set to a small size to ensure buffering over
the limit works
FakeServer server = new FakeServer();
server.setUseCallingThread(false);
server.deployVDB("parts", UnitTestUtil.getTestDataPath() +
"/PartsSupplier.vdb");
@@ -179,6 +179,18 @@
TestMMDatabaseMetaData.compareResultSet(s.getResultSet());
}
+ @Test public void testMultibatchSelect() throws Exception {
+ Statement s = conn.createStatement();
+ assertTrue(s.execute("select * from tables, columns"));
+ ResultSet rs = s.getResultSet();
+ int i = 0;
+ while (rs.next()) {
+ i++;
+ rs.getString(1);
+ }
+ assertEquals(7812, i);
+ }
+
@Test public void testBlob() throws Exception {
Statement s = conn.createStatement();
assertTrue(s.execute("select to_bytes('abc', 'UTF-16')"));
@@ -197,6 +209,16 @@
String clob = rs.getString(1);
assertEquals("abc", clob);
}
+
+ @Test public void testLargeClob() throws Exception {
+ Statement s = conn.createStatement();
+ assertTrue(s.execute("select cast(repeat('_', 3000) as clob)"));
+ ResultSet rs = s.getResultSet();
+ assertTrue(rs.next());
+ //getting as a clob is unsupported, since it uses the lo logic
+ String clob = rs.getString(1);
+ assertEquals(3000, clob.length());
+ }
@Test public void testTransactionCycle() throws Exception {
//TODO: drill in to ensure that the underlying statement has been set to autocommit
false
@@ -274,6 +296,14 @@
rs.next();
}
+ @Test public void testPreparedUpdate() throws Exception {
+ Statement stmt = conn.createStatement();
+ assertFalse(stmt.execute("create local temporary table x (y string)"));
+ PreparedStatement ps = conn.prepareStatement("delete from x");
+ assertFalse(ps.execute());
+ assertNull(ps.getMetaData());
+ }
+
@Test public void testSelectSsl() throws Exception {
conn.close();
Driver d = new Driver();