diff --git a/CHANGES b/CHANGES index c18cb02ef..4858c88ca 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,8 @@ Version 8.4.0 + - Fix for Bug#22931632, GETPARAMETERBINDINGS() ON A PS RETURNS NPE WHEN NOT ALL PARAMETERS ARE BOUND. + - WL#16147, Remove support for FIDO authentication. - Fix for Bug#110286 (Bug#35152855), Only call Messages.getString(...) when it's needed (when the SQLException is thrown). diff --git a/src/main/user-impl/java/com/mysql/cj/jdbc/ParameterBindingsImpl.java b/src/main/user-impl/java/com/mysql/cj/jdbc/ParameterBindingsImpl.java index 214b27436..2613160c5 100644 --- a/src/main/user-impl/java/com/mysql/cj/jdbc/ParameterBindingsImpl.java +++ b/src/main/user-impl/java/com/mysql/cj/jdbc/ParameterBindingsImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 2.0, as published by the @@ -117,7 +117,8 @@ public class ParameterBindingsImpl implements ParameterBindings { Field parameterMetadata = new Field(null, "parameter_" + (i + 1), charsetIndex, this.propertySet.getStringProperty(PropertyKey.characterEncoding).getValue(), this.queryBindings.getBindValues()[i].getMysqlType(), - rowData[i].length); + rowData[i] != null ? rowData[i].length : 0); + typeMetadata[i] = parameterMetadata; } diff --git a/src/test/java/testsuite/regression/StatementRegressionTest.java b/src/test/java/testsuite/regression/StatementRegressionTest.java index 2be81e50d..5c1c3ac46 100644 --- a/src/test/java/testsuite/regression/StatementRegressionTest.java +++ b/src/test/java/testsuite/regression/StatementRegressionTest.java @@ -13674,4 +13674,15 @@ public T preProcess(java.util.function.Supplier sq } + /** + * Test fix for Bug#22931632, GETPARAMETERBINDINGS() ON A PS RETURNS NPE WHEN NOT ALL PARAMETERS ARE BOUND. + * + * @throws Exception + */ + @Test + public void testBug22931632() throws Exception { + this.pstmt = this.conn.prepareStatement("SELECT ?"); + assertDoesNotThrow(((JdbcPreparedStatement) this.pstmt)::getParameterBindings); + } + }