[teiid-commits] teiid SVN: r3396 - in branches/7.4.x: engine/src/main/java/org/teiid/dqp/internal/process and 3 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Thu Aug 18 16:34:01 EDT 2011


Author: shawkins
Date: 2011-08-18 16:34:01 -0400 (Thu, 18 Aug 2011)
New Revision: 3396

Modified:
   branches/7.4.x/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
   branches/7.4.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
   branches/7.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
   branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
   branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
   branches/7.4.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
   branches/7.4.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
Log:
TEIID-1719 correction TEIID-1721 fixing update metadata in odbc

Modified: branches/7.4.x/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java	2011-08-18 19:14:32 UTC (rev 3395)
+++ branches/7.4.x/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java	2011-08-18 20:34:01 UTC (rev 3396)
@@ -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.4.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java	2011-08-18 19:14:32 UTC (rev 3395)
+++ branches/7.4.x/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java	2011-08-18 20:34:01 UTC (rev 3396)
@@ -245,7 +245,7 @@
     		public void onCompletion(ResultsFuture<ResultsMessage> future) {
     			try {
 					batchResults.setBatch(processBatch(future.get()));
-					result.getResultsReceiver().receiveResults(batchResults.hasNext());
+					result.getResultsReceiver().receiveResults(next());
 				} catch (Throwable t) {
 					result.getResultsReceiver().exceptionOccurred(t);
 				}
@@ -254,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()) {
@@ -270,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.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2011-08-18 19:14:32 UTC (rev 3395)
+++ branches/7.4.x/client/src/main/java/org/teiid/jdbc/StatementImpl.java	2011-08-18 20:34:01 UTC (rev 3396)
@@ -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.4.x/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java	2011-08-18 19:14:32 UTC (rev 3395)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java	2011-08-18 20:34:01 UTC (rev 3396)
@@ -115,11 +115,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.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java	2011-08-18 19:14:32 UTC (rev 3395)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java	2011-08-18 20:34:01 UTC (rev 3396)
@@ -313,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();
@@ -930,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.4.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java	2011-08-18 19:14:32 UTC (rev 3395)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java	2011-08-18 20:34:01 UTC (rev 3396)
@@ -606,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) {

Modified: branches/7.4.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java
===================================================================
--- branches/7.4.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java	2011-08-18 19:14:32 UTC (rev 3395)
+++ branches/7.4.x/test-integration/common/src/test/java/org/teiid/transport/TestODBCSocketTransport.java	2011-08-18 20:34:01 UTC (rev 3396)
@@ -188,7 +188,7 @@
 			i++;
 			rs.getString(1);
 		}
-		assertEquals(7827, i);
+		assertEquals(7812, i);
 	}
 	
 	@Test public void testBlob() throws Exception {
@@ -296,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();



More information about the teiid-commits mailing list