Bug #112447 CallablleStatement fails with a misleading error for non unique object names
Submitted: 25 Sep 2023 1:17 Modified: 1 Nov 2023 12:08
Reporter: Boyan Mihaylov Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:8.*.* OS:Any
Assigned to: CPU Architecture:Any
Tags: CallableStatement

[25 Sep 2023 1:17] Boyan Mihaylov
Description:
MySQL allows the same object name to be used to declare a function as well as a procedure. CallablleStatement with an OUT parameter works fine for this scenario using Connector/J 5.1.49, but fails with a misleading error message in all versions of Connector/J 8.*.*:

java.sql.SQLException: Parameter number 2 is not an OUT parameter
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:130)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:98)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:90)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:64)
	at com.mysql.cj.jdbc.CallableStatement.checkIsOutputParam(CallableStatement.java:645)
	at com.mysql.cj.jdbc.CallableStatement.registerOutParameter(CallableStatement.java:1717)
	at com.mysql.cj.jdbc.CallableStatement.registerOutParameter(CallableStatement.java:1725)
	at CallableStatementBugReport.runTest(CallableStatementBugReport.java:100)
	at com.mysql.cj.jdbc.util.BaseBugReport.run(BaseBugReport.java:138)
	at CallableStatementBugReport.main(CallableStatementBugReport.java:130)
 

How to repeat:
Create a function and a procedure with the same name. The procedure should have at least one OUT parameter. Use CallableStatement to call the procedure.

Suggested fix:
Do not allow objects to share the same name, return a more appropriate error message.
[25 Sep 2023 1:23] Boyan Mihaylov
BugReport

Attachment: CallableStatementBugReport.java (application/octet-stream, text), 4.65 KiB.

[25 Sep 2023 8:11] MySQL Verification Team
Hello Boyan Mihaylov,

Thank you for the report and test case.

regards,
Umesh
[1 Nov 2023 12:08] Filipe Silva
Actually this is a regression from Connector/J 5.1 where an identical bug (Bug#73774) was fixed but not ported to Connector/J 8.0. So, we'll port the other fix and close this bug as a duplicate.