@@ -11826,4 +11826,51 @@ public void testBug105211() throws Exception {
11826
11826
con.close();
11827
11827
} while (useSPS = !useSPS);
11828
11828
}
11829
+
11830
+ /**
11831
+ * Test fix for Bug#84365 (33425867), INSERT..VALUE with VALUES function lead to a StringIndexOutOfBoundsException.
11832
+ *
11833
+ * @throws Exception
11834
+ */
11835
+ @Test
11836
+ public void testBug84365() throws Exception {
11837
+ createTable("testBug84365", "(id int(11) NOT NULL, name varchar(25) DEFAULT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=latin1");
11838
+
11839
+ Properties props = new Properties();
11840
+ props.setProperty(PropertyKey.sslMode.getKeyName(), SslMode.DISABLED.name());
11841
+ props.setProperty(PropertyKey.allowPublicKeyRetrieval.getKeyName(), "true");
11842
+ props.setProperty(PropertyKey.rewriteBatchedStatements.getKeyName(), "true");
11843
+
11844
+ for (boolean useSSPS : new boolean[] { false, true }) {
11845
+
11846
+ this.stmt.executeUpdate("truncate table testBug84365");
11847
+
11848
+ props.setProperty(PropertyKey.useServerPrepStmts.getKeyName(), "" + useSSPS);
11849
+ Connection testConn = getConnectionWithProps(props);
11850
+
11851
+ PreparedStatement st = testConn.prepareStatement("insert into testBug84365(id, name) VALUES(?,?) on duplicate key update id = values(id) + 1");
11852
+ st.setInt(1, 1);
11853
+ st.setString(2, "Name1");
11854
+ st.execute();
11855
+ st.close();
11856
+
11857
+ st = testConn.prepareStatement("insert into testBug84365(id, name) VALUE(?,?) on duplicate key update id = values(id) + 1");
11858
+ st.setInt(1, 2);
11859
+ st.setString(2, "Name2");
11860
+ st.execute();
11861
+ st.close();
11862
+
11863
+ st = testConn.prepareStatement("insert into testBug84365 set id = 2 on duplicate key update id = values(id) + 1");
11864
+ st.execute();
11865
+
11866
+ this.rs = testConn.createStatement().executeQuery("select * from testBug84365 order by id");
11867
+ assertTrue(this.rs.next());
11868
+ assertEquals(1, this.rs.getInt("id"));
11869
+ assertEquals("Name1", this.rs.getString("name"));
11870
+ assertTrue(this.rs.next());
11871
+ assertEquals(3, this.rs.getInt("id"));
11872
+ assertEquals("Name2", this.rs.getString("name"));
11873
+ assertFalse(this.rs.next());
11874
+ }
11875
+ }
11829
11876
}
0 commit comments