Skip to content

Commit b226e34

Browse files
author
Axyoan Marcelo
committed
Fix for Bug#22931632, GETPARAMETERBINDINGS() ON A PS RETURNS NPE WHEN NOT ALL PARAMETERS ARE BOUND.
Change-Id: I3e4907277ccb83ad98dcc7125f3dc39c2365f57f
1 parent e030ed6 commit b226e34

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

CHANGES

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

44
Version 8.4.0
55

6+
- Fix for Bug#22931632, GETPARAMETERBINDINGS() ON A PS RETURNS NPE WHEN NOT ALL PARAMETERS ARE BOUND.
7+
68
- WL#16147, Remove support for FIDO authentication.
79

810
- Fix for Bug#110286 (Bug#35152855), Only call Messages.getString(...) when it's needed (when the SQLException is thrown).

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2023, Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2024, Oracle and/or its affiliates.
33
*
44
* This program is free software; you can redistribute it and/or modify it under
55
* the terms of the GNU General Public License, version 2.0, as published by the
@@ -117,7 +117,8 @@ public class ParameterBindingsImpl implements ParameterBindings {
117117

118118
Field parameterMetadata = new Field(null, "parameter_" + (i + 1), charsetIndex,
119119
this.propertySet.getStringProperty(PropertyKey.characterEncoding).getValue(), this.queryBindings.getBindValues()[i].getMysqlType(),
120-
rowData[i].length);
120+
rowData[i] != null ? rowData[i].length : 0);
121+
121122
typeMetadata[i] = parameterMetadata;
122123
}
123124

src/test/java/testsuite/regression/StatementRegressionTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13674,4 +13674,15 @@ public <T extends Resultset> T preProcess(java.util.function.Supplier<String> sq
1367413674

1367513675
}
1367613676

13677+
/**
13678+
* Test fix for Bug#22931632, GETPARAMETERBINDINGS() ON A PS RETURNS NPE WHEN NOT ALL PARAMETERS ARE BOUND.
13679+
*
13680+
* @throws Exception
13681+
*/
13682+
@Test
13683+
public void testBug22931632() throws Exception {
13684+
this.pstmt = this.conn.prepareStatement("SELECT ?");
13685+
assertDoesNotThrow(((JdbcPreparedStatement) this.pstmt)::getParameterBindings);
13686+
}
13687+
1367713688
}

0 commit comments

Comments
 (0)