List:Commits« Previous MessageNext Message »
From:mmatthews Date:October 6 2006 2:47am
Subject:Connector/J commit: r5833 - branches/branch_3_1/connector-j branches/branch_3_1/connector-j/src/com/mysql/jdbc branches/branch_3_1/connector-j/src/tes...
View as plain text  
Modified:
   branches/branch_3_1/connector-j/CHANGES
   branches/branch_3_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java
   branches/branch_3_1/connector-j/src/testsuite/regression/StatementRegressionTest.java
   branches/branch_5_0/connector-j/CHANGES
   branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java
   branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
   trunk/connector-j/CHANGES
   trunk/connector-j/src/com/mysql/jdbc/PreparedStatement.java
   trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java
Log:
Driver now sends numeric 1 or 0 for client-prepared statement  setBoolean() calls instead
of '1' or '0'.

Modified: branches/branch_3_1/connector-j/CHANGES
===================================================================
--- branches/branch_3_1/connector-j/CHANGES	2006-10-06 00:02:14 UTC (rev 5832)
+++ branches/branch_3_1/connector-j/CHANGES	2006-10-06 00:47:14 UTC (rev 5833)
@@ -46,6 +46,13 @@
 	- Removed logger autodectection altogether, must now specify logger 
 	  explitly if you want to use a logger other than one that logs
 	  to STDERR.
+	  
+	- Fixed BUG#22290 - Driver issues truncation on write exception when
+	  it shouldn't (due to sending big decimal incorrectly to server with
+	  server-side prepared statement).
+	  
+	- Driver now sends numeric 1 or 0 for client-prepared statement
+	  setBoolean() calls instead of '1' or '0'.
 	  	    
 05-26-06 - Version 3.1.13
 

Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java
===================================================================
--- branches/branch_3_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-10-06
00:02:14 UTC (rev 5832)
+++ branches/branch_3_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-10-06
00:47:14 UTC (rev 5833)
@@ -1305,13 +1305,15 @@
 			InputStream[] batchedParameterStreams, boolean[] batchedIsStream,
 			int[] batchedStreamLengths, boolean[] batchedIsNull,
 			boolean isReallyBatch) throws SQLException {
+		checkClosed();
+		
 		if (this.connection.isReadOnly()) {
 			throw new SQLException(Messages.getString("PreparedStatement.34") //$NON-NLS-1$
 					+ Messages.getString("PreparedStatement.35"), //$NON-NLS-1$
 					SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
 		}
 
-		checkClosed();
+		
 
 		if ((this.firstCharOfStmt == 'S')
 				&& StringUtils.startsWithIgnoreCaseAndWs(this.originalSql,
@@ -2095,7 +2097,7 @@
 	 */
 	public void setBoolean(int parameterIndex, boolean x) throws SQLException {
 		if (this.useTrueBoolean) {
-			setInternal(parameterIndex, x ? "'1'" : "'0'"); //$NON-NLS-1$ //$NON-NLS-2$
+			setInternal(parameterIndex, x ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$
 		} else {
 			setInternal(parameterIndex, x ? "'t'" : "'f'"); //$NON-NLS-1$ //$NON-NLS-2$
 		}

Modified:
branches/branch_3_1/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
---
branches/branch_3_1/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-10-06
00:02:14 UTC (rev 5832)
+++
branches/branch_3_1/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-10-06
00:47:14 UTC (rev 5833)
@@ -3338,4 +3338,67 @@
 			closeMemberJDBCResources();
 		}
 	}
+
+	/**
+	 * Tests fix for BUG#22290 - Driver issues truncation on write exception when
+	 * it shouldn't (due to sending big decimal incorrectly to server with
+	 * server-side prepared statement).
+	 * 
+	 * @throws Exception if the test fails.
+	 */
+	public void testBug22290() throws Exception {
+		if (!versionMeetsMinimum(5, 0)) {
+			return;
+		}
+		
+		createTable(
+				"testbug22290",
+				"(`id` int(11) NOT NULL default '1',`cost` decimal(10,2) NOT NULL,PRIMARY KEY 
(`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8");
+		assertEquals(
+				this.stmt
+						.executeUpdate("INSERT INTO testbug22290 (`id`,`cost`) VALUES (1,'1.00')"),
+				1);
+	
+		Connection configuredConn = null;
+		
+		try {
+			Properties props = new Properties();
+			props.setProperty("sessionVariables", "sql_mode='STRICT_TRANS_TABLES'");
+			
+			
+			configuredConn = getConnectionWithProps(props);
+			
+			this.pstmt = configuredConn
+					.prepareStatement("update testbug22290 set cost = cost + ? where id = 1");
+			this.pstmt.setBigDecimal(1, new BigDecimal("1.11"));
+			assertEquals(this.pstmt.executeUpdate(), 1);
+			
+			assertEquals(this.stmt
+					.executeUpdate("UPDATE testbug22290 SET cost='1.00'"), 1);
+			this.pstmt = ((com.mysql.jdbc.Connection)configuredConn)
+				.clientPrepareStatement("update testbug22290 set cost = cost + ? where id = 1");
+			this.pstmt.setBigDecimal(1, new BigDecimal("1.11"));
+			assertEquals(this.pstmt.executeUpdate(), 1);
+		} finally {
+			closeMemberJDBCResources();
+			
+			if (configuredConn != null) {
+				configuredConn.close();
+			}
+		}
+	}
+	
+	public void testClientPreparedSetBoolean() throws Exception {
+		try {
+			this.pstmt = ((com.mysql.jdbc.Connection)this.conn).clientPrepareStatement("SELECT
?");
+			this.pstmt.setBoolean(1, false);
+			assertEquals("SELECT 0", 
+					this.pstmt.toString().substring(this.pstmt.toString().indexOf("SELECT")));
+			this.pstmt.setBoolean(1, true);
+			assertEquals("SELECT 1", 
+					this.pstmt.toString().substring(this.pstmt.toString().indexOf("SELECT")));
+		} finally {
+			closeMemberJDBCResources();
+		}
+	}
 }

Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES	2006-10-06 00:02:14 UTC (rev 5832)
+++ branches/branch_5_0/connector-j/CHANGES	2006-10-06 00:47:14 UTC (rev 5833)
@@ -269,7 +269,10 @@
     - Fixed BUG#22290 - Driver issues truncation on write exception when
 	  it shouldn't (due to sending big decimal incorrectly to server with
 	  server-side prepared statement).
-	        	  	  	  	  
+	  
+	- Driver now sends numeric 1 or 0 for client-prepared statement
+	  setBoolean() calls instead of '1' or '0'.
+	      	  	  	  	  
 05-26-06 - Version 3.1.13
 
     - Fixed BUG#15464 - INOUT parameter does not store IN value.

Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-10-06
00:02:14 UTC (rev 5832)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-10-06
00:47:14 UTC (rev 5833)
@@ -2138,7 +2138,7 @@
 	 */
 	public void setBoolean(int parameterIndex, boolean x) throws SQLException {
 		if (this.useTrueBoolean) {
-			setInternal(parameterIndex, x ? "'1'" : "'0'"); //$NON-NLS-1$ //$NON-NLS-2$
+			setInternal(parameterIndex, x ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$
 		} else {
 			setInternal(parameterIndex, x ? "'t'" : "'f'"); //$NON-NLS-1$ //$NON-NLS-2$
 		}

Modified:
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
---
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-10-06
00:02:14 UTC (rev 5832)
+++
branches/branch_5_0/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-10-06
00:47:14 UTC (rev 5833)
@@ -3481,4 +3481,18 @@
 		}
 	}
 
+	public void testClientPreparedSetBoolean() throws Exception {
+		try {
+			this.pstmt = ((com.mysql.jdbc.Connection)this.conn).clientPrepareStatement("SELECT
?");
+			this.pstmt.setBoolean(1, false);
+			assertEquals("SELECT 0", 
+					this.pstmt.toString().substring(this.pstmt.toString().indexOf("SELECT")));
+			this.pstmt.setBoolean(1, true);
+			assertEquals("SELECT 1", 
+					this.pstmt.toString().substring(this.pstmt.toString().indexOf("SELECT")));
+		} finally {
+			closeMemberJDBCResources();
+		}
+	}
+
 }

Modified: trunk/connector-j/CHANGES
===================================================================
--- trunk/connector-j/CHANGES	2006-10-06 00:02:14 UTC (rev 5832)
+++ trunk/connector-j/CHANGES	2006-10-06 00:47:14 UTC (rev 5833)
@@ -45,7 +45,10 @@
 	  COLUMN_SIZE for the SET type, now returns length of largest possible
 	  set disregarding whitespace or the "," delimitters to be consistent 
 	  with the ODBC driver.
-	  	 
+	  
+	- Driver now sends numeric 1 or 0 for client-prepared statement
+	  setBoolean() calls instead of '1' or '0'.
+	   
 07-26-06 - Version 5.0.3
 
     - Fixed BUG#20650 - Statement.cancel() causes NullPointerException

Modified: trunk/connector-j/src/com/mysql/jdbc/PreparedStatement.java
===================================================================
--- trunk/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-10-06 00:02:14 UTC
(rev 5832)
+++ trunk/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-10-06 00:47:14 UTC
(rev 5833)
@@ -2150,7 +2150,7 @@
 	 */
 	public void setBoolean(int parameterIndex, boolean x) throws SQLException {
 		if (this.useTrueBoolean) {
-			setInternal(parameterIndex, x ? "'1'" : "'0'"); //$NON-NLS-1$ //$NON-NLS-2$
+			setInternal(parameterIndex, x ? "1" : "0"); //$NON-NLS-1$ //$NON-NLS-2$
 		} else {
 			setInternal(parameterIndex, x ? "'t'" : "'f'"); //$NON-NLS-1$ //$NON-NLS-2$
 		}

Modified: trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
--- trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-10-06
00:02:14 UTC (rev 5832)
+++ trunk/connector-j/src/testsuite/regression/StatementRegressionTest.java	2006-10-06
00:47:14 UTC (rev 5833)
@@ -3484,4 +3484,18 @@
 			}
 		}
 	}
+
+	public void testClientPreparedSetBoolean() throws Exception {
+		try {
+			this.pstmt = ((com.mysql.jdbc.Connection)this.conn).clientPrepareStatement("SELECT
?");
+			this.pstmt.setBoolean(1, false);
+			assertEquals("SELECT 0", 
+					this.pstmt.toString().substring(this.pstmt.toString().indexOf("SELECT")));
+			this.pstmt.setBoolean(1, true);
+			assertEquals("SELECT 1", 
+					this.pstmt.toString().substring(this.pstmt.toString().indexOf("SELECT")));
+		} finally {
+			closeMemberJDBCResources();
+		}
+	}
 }

Thread
Connector/J commit: r5833 - branches/branch_3_1/connector-j branches/branch_3_1/connector-j/src/com/mysql/jdbc branches/branch_3_1/connector-j/src/tes...mmatthews6 Oct