@@ -481,9 +481,10 @@ abstract class RemoteJDBCInstrumentationTest extends VersionedNamingTestBase {
481481 }
482482
483483
484- def " prepared call with storedproc on #driver with #connection.getClass().getCanonicalName() does not hang" () {
484+ def " prepared procedure call with return value on #driver with #connection.getClass().getCanonicalName() does not hang" () {
485485 setup :
486486 injectSysConfig(" dd.dbm.propagation.mode" , " full" )
487+
487488 CallableStatement upperProc = connection. prepareCall(query)
488489 upperProc. registerOutParameter(1 , Types . VARCHAR )
489490 upperProc. setString(2 , " hello world" )
@@ -505,12 +506,76 @@ abstract class RemoteJDBCInstrumentationTest extends VersionedNamingTestBase {
505506 " mysql" | cpDatasources. get(" hikari" ). get(driver). getConnection() | " { ? = call upper( ? ) }"
506507 " postgresql" | cpDatasources. get(" tomcat" ). get(driver). getConnection() | " { ? = call upper( ? ) }"
507508 " mysql" | cpDatasources. get(" tomcat" ). get(driver). getConnection() | " { ? = call upper( ? ) }"
508- " postgresql" | cpDatasources. get(" c3p0" ). get(driver). getConnection() | " { ? = call upper( ? ) }"
509+ " postgresql" | cpDatasources. get(" c3p0" ). get(driver). getConnection() | " { ? = call upper( ? ) }"
509510 " mysql" | cpDatasources. get(" c3p0" ). get(driver). getConnection() | " { ? = call upper( ? ) }"
510511 " postgresql" | connectTo(driver, peerConnectionProps) | " { ? = call upper( ? ) }"
511512 " mysql" | connectTo(driver, peerConnectionProps) | " { ? = call upper( ? ) }"
512513 }
513514
515+ def " prepared procedure call on #driver with #connection.getClass().getCanonicalName() does not hang" () {
516+ setup :
517+
518+ String createSql
519+ if (driver == " postgresql" ) {
520+ createSql =
521+ """
522+ CREATE OR REPLACE PROCEDURE dummy(inout res integer)
523+ LANGUAGE SQL
524+ AS \$\$
525+ SELECT 1;
526+ \$\$ ;
527+ """
528+ } else if (driver == " mysql" ) {
529+ createSql =
530+ """
531+ CREATE PROCEDURE IF NOT EXISTS dummy(inout res int)
532+ BEGIN
533+ SELECT 1;
534+ END
535+ """
536+ } else {
537+ assert false
538+ }
539+
540+ if (driver. equals(" postgresql" ) && connection. getMetaData(). getDatabaseMajorVersion() <= 11 ) {
541+ // Skip test for older versions of PG that don't support out on procedure
542+ return
543+ }
544+
545+
546+ connection. prepareCall(createSql). execute()
547+
548+ injectSysConfig(" dd.dbm.propagation.mode" , " full" )
549+ CallableStatement proc = connection. prepareCall(query)
550+ proc. setInt(1 ,1 )
551+ proc. registerOutParameter(1 , Types . INTEGER )
552+ when :
553+ runUnderTrace(" parent" ) {
554+ return proc. execute()
555+ }
556+ TEST_WRITER . waitForTraces(1 )
557+
558+ then :
559+ assert proc. getInt(1 ) == 1
560+
561+ cleanup :
562+ if (proc != null ) {
563+ proc. close()
564+ }
565+ connection. close()
566+
567+ where :
568+ driver | connection | query
569+ " postgresql" | cpDatasources. get(" hikari" ). get(driver). getConnection() | " CALL dummy(?)"
570+ " mysql" | cpDatasources. get(" hikari" ). get(driver). getConnection() | " CALL dummy(?)"
571+ " postgresql" | cpDatasources. get(" tomcat" ). get(driver). getConnection() | " CALL dummy(?)"
572+ " mysql" | cpDatasources. get(" tomcat" ). get(driver). getConnection() | " CALL dummy(?)"
573+ " postgresql" | cpDatasources. get(" c3p0" ). get(driver). getConnection() | " CALL dummy(?)"
574+ " mysql" | cpDatasources. get(" c3p0" ). get(driver). getConnection() | " CALL dummy(?)"
575+ " postgresql" | connectTo(driver, peerConnectionProps) | " CALL dummy(?)"
576+ " mysql" | connectTo(driver, peerConnectionProps) | " CALL dummy(?)"
577+ }
578+
514579
515580 Driver driverFor (String db ) {
516581 return newDriver(jdbcDriverClassNames. get(db))
0 commit comments