Hi Team, I am facing an issue while invoking the PostgreSQL stored procedure call, it fails due escaping call with curly braces.
Problem Statement
When invoking the PostgreSQL stored procedure, it returns error:
bad SQL grammar [{call sample_sp(?, ?)}]; nested exception is org.postgresql.util.PSQLException
Root cause
PostgreSQL doesn't support/need escaping call with curly braces, need to make it conditional.
Issue class
https://github.com/spring-projects/spring-framework/blob/main/spring-jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java#L645-L668
Fix
Add an if
condition to add curly braces only for non PostgreSQL calls.
if(this.metaDataProvider instanceof PostgresCallMetaDataProvider) {
callString = new StringBuilder("call ");
}else {
callString = new StringBuilder("{call ");
}
Comment From: sbrannen
I've edited your comment to improve the formatting. You might want to check out this Mastering Markdown guide for future reference.
Comment From: sbrannen
Closing as superseded by #30257.
Please refrain from creating an issue and a PR for the same topic. The PR is sufficient.
Thanks
Comment From: snicoll
Reopening as the PR has been declined
Comment From: jhoeller
This seems to be the case outlined here: https://stackoverflow.com/questions/65116924/x-is-a-procedure-use-call-when-i-am-already-using-call
In order to make PostgreSQL compliant with standard JDBC syntax for stored procedures and not just functions, you may specify escapeSyntaxCallMode=callIfNoReturn
as a JDBC driver property. Not sure why that is not the driver's default but it is the recommended solution to this problem.
From the Spring side, we are going to close this issue and stick with standard JDBC syntax.