Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all articles
Browse latest Browse all 884

Bug regarding rewritableAsMultiValues introduced in 8.0.29 (8 replies)

$
0
0
After bumping to 8.0.29 and later versions we noticed that batch inserts made by prepared statements took much longer time to execute. After a bit of investigation we found that this only happens on some of our inserts. Namely inserts where we have column names that have the word "value" in them and where the query takes placeholders "?".

We could find no way to work around this so please provide a fix since we can't go above 8.0.28 until this is resolved.

Including is a test verifying the bug:

import static org.junit.jupiter.api.Assertions.assertTrue;

import com.mysql.cj.jdbc.ClientPreparedStatement;
import com.mysql.cj.jdbc.MysqlDataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.junit.jupiter.api.Test;

class TransferDatabaseTest {
@Test
void rewritableAsMultiValuesBug() throws SQLException {
MysqlDataSource dataSource = new MysqlDataSource();
String url = "YOUR CONNECTION STRING GOES HERE :)";
dataSource.setURL(url);
dataSource.setRewriteBatchedStatements(true);
Connection connection = dataSource.getConnection();

//WORKING QUERY
PreparedStatement preparedStatement = connection.prepareStatement(
"INSERT INTO test (a, b) VALUES (?, ?)"
);
ClientPreparedStatement clientPreparedStatement = (ClientPreparedStatement) preparedStatement;
boolean isRewritable = clientPreparedStatement.getQueryInfo()
.isRewritableWithMultiValuesClause();
assertTrue(isRewritable);
connection.close();

//FAILING QUERY
connection = dataSource.getConnection();
PreparedStatement preparedStatementBug = connection.prepareStatement(
"INSERT INTO test (a_value, bvalue) VALUES (?, ?)"
);
ClientPreparedStatement clientPreparedStatementBug = (ClientPreparedStatement) preparedStatementBug;
boolean isRewritableBug = clientPreparedStatementBug.getQueryInfo()
.isRewritableWithMultiValuesClause();
assertTrue(isRewritableBug);

}

}

Viewing all articles
Browse latest Browse all 884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>