MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:mmatthews Date:January 10 2007 6:57pm
Subject:Connector/J commit: r6286 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes...
View as plain text  
Modified:
   branches/branch_5_0/connector-j/CHANGES
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/MysqlIO.java
   branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
   trunk/connector-j/CHANGES
   trunk/connector-j/src/com/mysql/jdbc/MysqlIO.java
   trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java
Log:
Fixed BUG#25009 - Results from updates not handled correctly in  multi-statement queries, leading to erroneous "Result is from UPDATE"  exceptions.

Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES	2007-01-10 18:24:24 UTC (rev 6285)
+++ branches/branch_5_0/connector-j/CHANGES	2007-01-10 18:57:48 UTC (rev 6286)
@@ -52,6 +52,10 @@
 
 	- Fixed BUG#25514 - Timer instance used for Statement.setQueryTimeout()
 	  created per-connection, rather than per-VM, causing memory leak.
+	
+	- Fixed BUG#25009 - Results from updates not handled correctly in 
+	  multi-statement queries, leading to erroneous "Result is from UPDATE" 
+	  exceptions.
 	  
 10-20-06 - Version 5.0.4
 

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/MysqlIO.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/MysqlIO.java	2007-01-10 18:24:24 UTC (rev 6285)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/MysqlIO.java	2007-01-10 18:57:48 UTC (rev 6286)
@@ -1,5 +1,5 @@
 /*
-      Copyright (C) 2002-2004 MySQL AB
+      Copyright (C) 2002-2007 MySQL AB
 
       This program is free software; you can redistribute it and/or modify
       it under the terms of version 2 of the GNU General Public License as
@@ -1414,12 +1414,6 @@
         	Buffer fieldPacket = checkErrorPacket();
             fieldPacket.setPosition(0);
             
-            if ((fieldPacket.readByte(0) == 0) &&
-                    (fieldPacket.readByte(1) == 0) &&
-                    (fieldPacket.readByte(2) == 0)) {
-                break;
-            }
-
             ResultSet newResultSet = readResultsForQueryOrUpdate(callingStatement,
                     maxRows, resultSetType, resultSetConcurrency,
                     streamResults, catalog, fieldPacket, isBinaryEncoded,

Modified: branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
--- branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2007-01-10 18:24:24 UTC (rev 6285)
+++ branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2007-01-10 18:57:48 UTC (rev 6286)
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2002-2004 MySQL AB
+ Copyright (C) 2002-2007 MySQL AB
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of version 2 of the GNU General Public License as 
@@ -3726,6 +3726,53 @@
 	}
 	
 	/**
+	 * Tests fix for BUG#25009 - Results from updates not handled correctly in multi-statement
+	 * queries.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug25009() throws Exception {
+		if (!versionMeetsMinimum(4, 1)) {
+			return;
+		}
+		
+		Properties props = new Properties();
+		props.setProperty("allowMultiQueries", "true");
+		
+		Connection multiConn = getConnectionWithProps(props);
+		createTable("testBug25009", "(field1 INT)");
+		
+		try {
+			Statement multiStmt = multiConn.createStatement();
+			multiStmt.execute("SELECT 1;SET @a=1; SET @b=2; SET @c=3; INSERT INTO testBug25009 VALUES (1)");
+			
+			assertEquals(-1, multiStmt.getUpdateCount());
+			
+			this.rs = multiStmt.getResultSet();
+			assertTrue(this.rs.next());
+			assertEquals(multiStmt.getMoreResults(), false);
+			
+			for (int i = 0; i < 3; i++) {
+				assertEquals(0, multiStmt.getUpdateCount());
+				assertEquals(multiStmt.getMoreResults(), false);
+			}
+			
+			assertEquals(1, multiStmt.getUpdateCount());
+
+			this.rs = multiStmt.executeQuery("SELECT field1 FROM testBug25009");
+			assertTrue(this.rs.next());
+			assertEquals(1, this.rs.getInt(1));
+			
+		} finally {
+			closeMemberJDBCResources();
+			
+			if (multiConn != null) {
+				multiConn.close();
+			}
+		}
+	}
+	
+	/**
 	 * Tests fix for BUG#25025 - Client-side prepared statement parser gets confused by
 	 * in-line (slash-star) comments and therefore can't rewrite batched statements or
 	 * reliably detect type of statements when they're used.

Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES	2007-01-10 18:24:24 UTC (rev 6285)
+++ trunk/connector-j/CHANGES	2007-01-10 18:57:48 UTC (rev 6286)
@@ -48,7 +48,11 @@
 
 	- Fixed BUG#25514 - Timer instance used for Statement.setQueryTimeout()
 	  created per-connection, rather than per-VM, causing memory leak
-	  	  	  	  	   	  	   
+	  
+	- Fixed BUG#25009 - Results from updates not handled correctly in 
+	  multi-statement queries, leading to erroneous "Result is from UPDATE" 
+	  exceptions.
+	    	  	  	  	   	  	   
 10-20-06 - Version 5.0.4
 
     - Fixed BUG#21379 - column names don't match metadata in cases 

Modified: trunk/connector-j/src/com/mysql/jdbc/MysqlIO.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/MysqlIO.java	2007-01-10 18:24:24 UTC (rev 6285)
+++ trunk/connector-j/src/com/mysql/jdbc/MysqlIO.java	2007-01-10 18:57:48 UTC (rev 6286)
@@ -1411,12 +1411,6 @@
         while (moreRowSetsExist) {
         	Buffer fieldPacket = checkErrorPacket();
             fieldPacket.setPosition(0);
-            
-            if ((fieldPacket.readByte(0) == 0) &&
-                    (fieldPacket.readByte(1) == 0) &&
-                    (fieldPacket.readByte(2) == 0)) {
-                break;
-            }
 
             ResultSet newResultSet = readResultsForQueryOrUpdate(callingStatement,
                     maxRows, resultSetType, resultSetConcurrency,

Modified: trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java	2007-01-10 18:24:24 UTC (rev 6285)
+++ trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java	2007-01-10 18:57:48 UTC (rev 6286)
@@ -1,5 +1,5 @@
 /*
- Copyright (C) 2002-2006 MySQL AB
+ Copyright (C) 2002-2007 MySQL AB
 
  This program is free software; you can redistribute it and/or modify
  it under the terms of version 2 of the GNU General Public License as 
@@ -3734,6 +3734,53 @@
 	}
 	
 	/**
+	 * Tests fix for BUG#25009 - Results from updates not handled correctly in multi-statement
+	 * queries.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug25009() throws Exception {
+		if (!versionMeetsMinimum(4, 1)) {
+			return;
+		}
+		
+		Properties props = new Properties();
+		props.setProperty("allowMultiQueries", "true");
+		
+		Connection multiConn = getConnectionWithProps(props);
+		createTable("testBug25009", "(field1 INT)");
+		
+		try {
+			Statement multiStmt = multiConn.createStatement();
+			multiStmt.execute("SELECT 1;SET @a=1; SET @b=2; SET @c=3; INSERT INTO testBug25009 VALUES (1)");
+			
+			assertEquals(-1, multiStmt.getUpdateCount());
+			
+			this.rs = multiStmt.getResultSet();
+			assertTrue(this.rs.next());
+			assertEquals(multiStmt.getMoreResults(), false);
+			
+			for (int i = 0; i < 3; i++) {
+				assertEquals(0, multiStmt.getUpdateCount());
+				assertEquals(multiStmt.getMoreResults(), false);
+			}
+			
+			assertEquals(1, multiStmt.getUpdateCount());
+
+			this.rs = multiStmt.executeQuery("SELECT field1 FROM testBug25009");
+			assertTrue(this.rs.next());
+			assertEquals(1, this.rs.getInt(1));
+			
+		} finally {
+			closeMemberJDBCResources();
+			
+			if (multiConn != null) {
+				multiConn.close();
+			}
+		}
+	}
+	
+	/**
 	 * Tests fix for BUG#25025 - Client-side prepared statement parser gets confused by
 	 * in-line (slash-star) comments and therefore can't rewrite batched statements or
 	 * reliably detect type of statements when they're used.

Thread
Connector/J commit: r6286 - branches/branch_5_0/connector-j branches/branch_5_0/connector-j/src/com/mysql/jdbc branches/branch_5_0/connector-j/src/tes...mmatthews10 Jan