| Bug #91157 | NullPointerException when calling zero-argument function with alternate definer. | ||
|---|---|---|---|
| Submitted: | 6 Jun 2018 11:44 | Modified: | 6 Jun 2018 16:53 |
| Reporter: | Simon Greatrix | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 5.1.46 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[6 Jun 2018 13:53]
Chiranjeevi Battula
Hello Simon Greatrix, Thank you for the bug report and testcase. I could not repeat the issue at our end using with Connector / J 5.1.46, MySQL 5.7.22 version. Please use "useInformationSchema=true" in connection string. Thanks, Chiranjeevi.
[6 Jun 2018 13:54]
Chiranjeevi Battula
Screenshot
Attachment: Bug_91157.PNG (image/png, text), 67.63 KiB.
[6 Jun 2018 16:53]
Simon Greatrix
I can confirm that if I add "(useInformationSchem=true)" to the connection string, then I do not have NullPointerException. However the issue does replicate on multiple machines for me using Connector / J version 5.1.46 and MySQL version 5.7.22

Description: See "How to repeat". The following exception is raised: java.lang.NullPointerException at com.mysql.jdbc.CallableStatement$CallableStatementParamInfo.iterator(CallableStatement.java:364) at com.mysql.jdbc.CallableStatement.setInOutParamsOnServer(CallableStatement.java:2008) at com.mysql.jdbc.CallableStatement.execute(CallableStatement.java:834) at MySqlFunctionTest.main(MySqlFunctionTest.java:30) How to repeat: SQL to create test case: ------------------------------------------------------------------------------- CREATE DATABASE IF NOT EXISTS `test`; CREATE USER IF NOT EXISTS `tester`@`localhost` IDENTIFIED BY 'tester'; CREATE USER IF NOT EXISTS `test_owner`@`localhost` IDENTIFIED BY 'tester'; GRANT ALL ON test.* TO `tester`@`localhost`; USE `test`; DROP FUNCTION IF EXISTS `hiFive`; DELIMITER $$ CREATE DEFINER=`test_owner`@`localhost` FUNCTION `hiFive`() RETURNS INTEGER BEGIN RETURN 5; END; $$ DELIMITER ; GRANT EXECUTE ON FUNCTION hiFive TO `tester`@`localhost`; GRANT EXECUTE ON FUNCTION hiFive TO `test_owner`@`localhost`; ------------------------------------------------------------------------------- Then access with Java program: import java.sql.*; public class MySqlFunctionTest { public static void main(String[] args) throws Exception { Connection conn = DriverManager.getConnection("jdbc:mysql://address=(host=localhost)(protocol=tcp)(useSSL=false)(noAccessToProcedureBodies=true)" + "(port=3306)/test", "tester", "tester"); CallableStatement callableStatement = conn.prepareCall("{? = CALL hiFive()}"); callableStatement.registerOutParameter(1, Types.INTEGER); callableStatement.execute(); System.out.println("Function returned: " + callableStatement.getInt(1)); } } Suggested fix: Adding a dummy parameter to the function avoids the NullPointerException. This is a work-around, not a fix.