List:Internals« Previous MessageNext Message »
From:mmatthews Date:August 2 2005 8:39pm
Subject:Connector/J commit: r4019 - in branches/branch_3_1/connector-j: . src/com/mysql/jdbc src/testsuite/regression
View as plain text  
Modified:
   branches/branch_3_1/connector-j/CHANGES
   branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java
   branches/branch_3_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
Log:
Fixed BUG#12229 - explainSlowQueries hangs with server-side
	  prepared statements.

Modified: branches/branch_3_1/connector-j/CHANGES
===================================================================
--- branches/branch_3_1/connector-j/CHANGES	2005-08-02 20:15:38 UTC (rev 4018)
+++ branches/branch_3_1/connector-j/CHANGES	2005-08-02 20:39:16 UTC (rev 4019)
@@ -54,6 +54,9 @@
 	  
 	- Fixed BUG#11115, VARBINARY data corrupted when using server-side
 	  prepared statements and .setBytes().
+	
+	- Fixed BUG#12229 - explainSlowQueries hangs with server-side
+	  prepared statements.
       
 06-23-05 - Version 3.1.10-stable
 

Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java
===================================================================
--- branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java	2005-08-02 20:15:38 UTC (rev 4018)
+++ branches/branch_3_1/connector-j/src/com/mysql/jdbc/ServerPreparedStatement.java	2005-08-02 20:39:16 UTC (rev 4019)
@@ -1093,6 +1093,36 @@
 			Buffer resultPacket = mysql.sendCommand(MysqlDefs.COM_EXECUTE,
 					null, packet, false, null);
 
+			
+
+			this.connection.incrementNumberOfPreparedExecutes();
+
+			if (this.connection.getProfileSql()) {
+				this.eventSink = ProfileEventSink.getInstance(this.connection);
+
+				this.eventSink.consumeEvent(new ProfilerEvent(
+						ProfilerEvent.TYPE_EXECUTE, "", this.currentCatalog, //$NON-NLS-1$
+						this.connection.getId(), this.statementId, -1, System
+								.currentTimeMillis(), (int) (System
+								.currentTimeMillis() - begin), null,
+						new Throwable(), null));
+			}
+
+			com.mysql.jdbc.ResultSet rs = mysql.readAllResults(this,
+					maxRowsToRetrieve, this.resultSetType,
+					this.resultSetConcurrency, createStreamingResultSet,
+					this.currentCatalog, resultPacket, true, this.fieldCount,
+					true);
+
+			
+			if (!createStreamingResultSet && 
+					this.serverNeedsResetBeforeEachExecution) {
+				serverResetStatement(); // clear any long data...
+			}
+
+			this.sendTypesToServer = false;
+			this.results = rs;
+
 			if (this.connection.getLogSlowQueries()
 					|| this.connection.getGatherPerformanceMetrics()) {
 				long elapsedTime = System.currentTimeMillis() - begin;
@@ -1124,35 +1154,7 @@
 					this.connection.registerQueryExecutionTime(elapsedTime);
 				}
 			}
-
-			this.connection.incrementNumberOfPreparedExecutes();
-
-			if (this.connection.getProfileSql()) {
-				this.eventSink = ProfileEventSink.getInstance(this.connection);
-
-				this.eventSink.consumeEvent(new ProfilerEvent(
-						ProfilerEvent.TYPE_EXECUTE, "", this.currentCatalog, //$NON-NLS-1$
-						this.connection.getId(), this.statementId, -1, System
-								.currentTimeMillis(), (int) (System
-								.currentTimeMillis() - begin), null,
-						new Throwable(), null));
-			}
-
-			com.mysql.jdbc.ResultSet rs = mysql.readAllResults(this,
-					maxRowsToRetrieve, this.resultSetType,
-					this.resultSetConcurrency, createStreamingResultSet,
-					this.currentCatalog, resultPacket, true, this.fieldCount,
-					true);
-
 			
-			if (!createStreamingResultSet && 
-					this.serverNeedsResetBeforeEachExecution) {
-				serverResetStatement(); // clear any long data...
-			}
-
-			this.sendTypesToServer = false;
-			this.results = rs;
-
 			return rs;
 		}
 	}

Modified: branches/branch_3_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java
===================================================================
--- branches/branch_3_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java	2005-08-02 20:15:38 UTC (rev 4018)
+++ branches/branch_3_1/connector-j/src/testsuite/regression/ConnectionRegressionTest.java	2005-08-02 20:39:16 UTC (rev 4019)
@@ -42,6 +42,7 @@
 import com.mysql.jdbc.NonRegisteringDriver;
 import com.mysql.jdbc.ReplicationConnection;
 import com.mysql.jdbc.ReplicationDriver;
+import com.mysql.jdbc.log.StandardLogger;
 
 /**
  * Regression tests for Connections
@@ -1145,6 +1146,38 @@
 		}
 	}
 	
+	/**
+	 * Tests fix for BUG#12229 - explainSlowQueries hangs with server-side
+	 * prepared statements.
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug12229() throws Exception {
+		createTable("testBug12229","(`int_field` integer )");  
+		this.stmt.executeUpdate("insert into testBug12229 values (123456),(1)"); 
+		
+		Properties props = new Properties();
+	 	props.put("profileSQL", "true");
+	 	props.put("slowQueryThresholdMillis", "0");
+	 	props.put("logSlowQueries", "true");
+		props.put("explainSlowQueries", "true");
+		props.put("useServerPrepStmts", "true");
+		
+		Connection explainConn = getConnectionWithProps(props);
+
+		pstmt = explainConn.prepareStatement("SELECT `int_field` FROM `testBug12229` WHERE `int_field` = ?");
+		pstmt.setInt(1,1);
+
+		rs = pstmt.executeQuery();
+		assertTrue(rs.next());
+		
+		rs = pstmt.executeQuery();
+		assertTrue(rs.next());
+
+		rs = pstmt.executeQuery();
+		assertTrue(rs.next());
+	}
+	
 	public void testCSC5765() throws Exception {
 		Properties props = new Properties();
 		props.setProperty("useUnicode","true");

Thread
Connector/J commit: r4019 - in branches/branch_3_1/connector-j: . src/com/mysql/jdbc src/testsuite/regressionmmatthews2 Aug