Skip to content

Commit 52c87f0

Browse files
author
Axyoan Marcelo
committed
Fix for Bug#19857207, EXECUTE ON CALLABLESTATEMENT RESULTS IN ARRAYINDEXOUTOFBOUNDSEXCEPTION.
Change-Id: I1039a26fbc4768e3983cecc1d12bca2fde9fbd37
1 parent 27b50cb commit 52c87f0

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
Version 9.3.0
55

6+
- Fix for Bug#19857207, EXECUTE ON CALLABLESTATEMENT RESULTS IN ARRAYINDEXOUTOFBOUNDSEXCEPTION.
7+
68
- Fix for Bug#117027 (Bug#37415840), Mysql connector use an uneffective way to match numericValue.
79

810
- Fix for Bug#19829452, PARAMETER INDEX VALIDATION NOT PROPER IN CALLABLESTATEMENT.

src/main/user-impl/java/com/mysql/cj/jdbc/CallableStatement.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,18 @@ private void setInOutParamsOnServer() throws SQLException {
22792279

22802280
try {
22812281
setPstmt = this.connection.clientPrepareStatement(queryBuf.toString()).unwrap(ClientPreparedStatement.class);
2282-
setPstmt.getQueryBindings().setFromBindValue(0, ((PreparedQuery) this.query).getQueryBindings().getBindValues()[inParamInfo.index]);
2282+
int inOutParamIndex = 0;
2283+
if (this.paramInfo.placeholderToParameterIndexMap == null) {
2284+
inOutParamIndex = inParamInfo.index;
2285+
} else {
2286+
for (int i = 0; i < this.paramInfo.placeholderToParameterIndexMap.length; i++) {
2287+
if (this.paramInfo.placeholderToParameterIndexMap[i] == inParamInfo.index) {
2288+
inOutParamIndex = i;
2289+
break;
2290+
}
2291+
}
2292+
}
2293+
setPstmt.getQueryBindings().setFromBindValue(0, ((PreparedQuery) this.query).getQueryBindings().getBindValues()[inOutParamIndex]);
22832294
setPstmt.executeUpdate();
22842295
} finally {
22852296
if (setPstmt != null) {

src/test/java/testsuite/regression/CallableStatementRegressionTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,4 +1970,19 @@ public void testBug19829452() throws Exception {
19701970
assertThrows(SQLException.class, () -> testCstmt.getString(0));
19711971
}
19721972

1973+
/**
1974+
* Tests fix for Bug#19857207, EXECUTE ON CALLABLESTATEMENT RESULTS IN ARRAYINDEXOUTOFBOUNDSEXCEPTION.
1975+
*
1976+
* @throws Exception
1977+
*/
1978+
@Test
1979+
public void testBug19857207() throws Exception {
1980+
createProcedure("testBug19857207", "(IN a VARCHAR(10),INOUT b VARCHAR(10)) BEGIN SET b = 'data'; END");
1981+
CallableStatement testCstmt = this.conn.prepareCall("{ CALL testBug19857207('a', ?) }");
1982+
testCstmt.setString(1, "b");
1983+
testCstmt.registerOutParameter(1, java.sql.Types.VARCHAR);
1984+
testCstmt.execute();
1985+
assertEquals("data", testCstmt.getString(1));
1986+
}
1987+
19731988
}

0 commit comments

Comments
 (0)