package testsuite.simple; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Properties; import testsuite.BaseTestCase; public class TestBug57432 extends BaseTestCase { public TestBug57432(String name) { super(name); } /** * @param args */ public static void main(String[] args) { junit.textui.TestRunner.run(TestBug57432.class); } public void testBug57432() throws Exception { createTable("Networks", "(" + "stagingId int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, " + "auditColumn datetime NOT NULL, " + "source varchar(50) NOT NULL, " + "crc bigint(20) NOT NULL, " + "id_ bigint(20) NOT NULL, " + "ip_ varchar(11), " + "name_ varchar(200)," + "INDEX SOURCE_ID_CRC (source, id_, crc)" + ")"); Properties props = new Properties(); props.put("rewriteBatchedStatements", "true"); props.put("cachePrepStmts", "true"); props.put("prepStmtCacheSize", "512"); props.put("allowMultiQueries", "true"); props.put("socketTimeout", "1200000"); props.put("connectTimeout", "1200000"); Connection myCon = getConnectionWithProps(props); String select = "select crc,id_ from Networks where source='asdfsdfa' and id_='asdds' order by stagingId"; String disableKeys = "ALTER TABLE Networks disable keys"; String enableKeys = "ALTER TABLE Networks enable keys"; Connection myCon2 = getConnectionWithProps(props); myCon2.createStatement().execute(disableKeys); PreparedStatement statementInsert = myCon2.prepareStatement("insert into Networks(source, auditColumn, crc,id_, ip_, name_) values('test', '2010-09-09',?, ?, ?, ?)"); PreparedStatement statement = myCon.prepareStatement(select); ((com.mysql.jdbc.Statement) statement).enableStreamingResults(); ResultSet theResults = statement.executeQuery(select); System.out.println("*************************************"); System.out.println("STARTING EXECUTION!!"); //int cnt = 25000000; int cnt = 1000000; for (int i = 0; i < cnt; i++) { theResults.next(); statementInsert.setInt(1, i); statementInsert.setInt(2, i); statementInsert.setString(3, "ip"+i); statementInsert.setString(4, "name"+i); statementInsert.execute(); } myCon2.createStatement().execute(enableKeys); System.out.println("*************************************"); System.out.println("Execution ended we now close the stamenet."); myCon.close(); myCon2.close(); } }