[teiid-commits] teiid SVN: r3434 - branches/7.4.x/runtime/src/main/java/org/teiid/odbc.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue Aug 30 10:16:44 EDT 2011


Author: shawkins
Date: 2011-08-30 10:16:43 -0400 (Tue, 30 Aug 2011)
New Revision: 3434

Modified:
   branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
Log:
TEIID-1732 correcting the simple query execution to always send ready

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-30 02:16:42 UTC (rev 3433)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java	2011-08-30 14:16:43 UTC (rev 3434)
@@ -454,7 +454,6 @@
 		                	List<PgColInfo> cols = getPgColInfo(stmt.getResultSet().getMetaData());
                             client.sendResults(query.sql, stmt.getResultSet(), cols, result, true);
 		                } else {
-		                	// null future
 		                	client.sendUpdateCount(query.sql, stmt.getUpdateCount());
 		                	setEncoding();
 		                	result.getResultsReceiver().receiveResults(1);
@@ -603,11 +602,6 @@
 		this.portalMap.remove(UNNAMED);
 		this.preparedMap.remove(UNNAMED);
 		
-		if (query.trim().length() == 0) {
-    		this.client.emptyQueryReceived();
-    		ready();
-    		return;
-    	}
         QueryWorkItem r = new QueryWorkItem(query);
 		r.run();
 	}
@@ -837,6 +831,15 @@
 		private QueryWorkItem(String query) {
 			this.reader = new ScriptReader(new StringReader(query));		
 		}
+		
+		private void done(Throwable error) {
+			if (error != null) {
+				errorOccurred(error);
+			} else {
+				doneExecuting();
+			}
+			ready();
+		}
 
 		@Override
 		public void run() {
@@ -845,6 +848,11 @@
 					sql = reader.readStatement();
 				}
 		        while (sql != null) {
+		    		if (sql.trim().length() == 0) {
+		    			sql = reader.readStatement();
+		        		client.emptyQueryReceived();
+		        		continue;
+		        	}
 		            try {
 		    			
 		            	ResultsFuture<Integer> results = new ResultsFuture<Integer>();
@@ -856,14 +864,14 @@
 		    					} catch (InterruptedException e) {
 		    						throw new AssertionError(e);
 		    					} catch (IOException e) {
-		    						client.errorOccurred(e);
+		    						done(e);
 		    						return;
 		    					} catch (ExecutionException e) {
 		    						Throwable cause = e;
 		    						while (cause instanceof ExecutionException && cause.getCause() != null && cause != cause.getCause()) {
 		    							cause = cause.getCause();
 		    						}
-		    						client.errorOccurred(cause);
+		    						done(cause);
 		    						return;
 		    					}
 		            			QueryWorkItem.this.run(); //continue processing
@@ -909,15 +917,15 @@
 		    			}
 		                return; //wait for the execution to finish
 		            } catch (SQLException e) {
-		                errorOccurred(e);
-		                break;
+		            	done(e);
+		            	return;
 		            } 
 		        }
 			} catch(IOException e) {
-				errorOccurred(e);
+				done(e);
+				return;
 			}
-			doneExecuting();
-			ready();
+			done(null);
 		}
 	}
     



More information about the teiid-commits mailing list