Description
I have only tested this in the 10.5 trunk. However, I suspect that this affects all previous releases of Derby as well.
In resolving method signatures for function/procedure invocations, the SQL standard makes the following definitions in part 13, section 4.5 (parameter mapping). These definitions, in turn, refer to tables B-1 and B-3 in JDBC 3.0 Specification, Final Release, October 2001 ([JDBC]).
- Simply mappable - This refers to the correspondence of SQL and Java types described in [JDBC] table B-1. This is the table which defines the mapping of SQL types to Java primitives.
- Object mappable - This refers to the correspondence of SQL and Java types described in [JDBC] table B-3. This is the table which defines the mapping of SQL types to Java wrapper objects.
- Output mappable - For OUT and INOUT parameters, this refers to a single element array whose cell is simply mappable or object mappable. E.g. Integer[] or float[].
- Mappable - This means simply, object, or output mappable.
- Result set mappable - This means a single element array whose cell is a type which implements either java.sql.ResultSet or sqlj.runtime.ResultSetIterator.
Putting all of this together, section 4.5 continues:
"A Java method with M parameters is mappable (to SQL) if and only if, for some N, 0 (zero) <= N <= M, the data types of the first N parameters are mappable, the last M - N parameters are result set mappable, and the result type is either simply mappable, object mappable, or void."
Section 8.6 gives more detailed rules, but they are hard to follow. According to section 8.6, when resolving a routine invocation, Derby should expect to find one and only one static mappable method with the expected external name (Java class + method name).
I believe that this is a fair description of the rules. This, at least, is what some other databases appear to do. See, for instance, http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.java/html/java/java126.htm and http://www.service-architecture.com/database/articles/mapping_sql_and_java_data_types.html
We do not have a regression test which verifies that Derby applies the SQL standard resolution rules. There may be several divergences from the standard. This JIRA is a place to track those discrepancies. Here is one that I have noticed:
The following SQL signature
( a int ) returns int
should be mappable to any of the following Java signatures
public static int f( int a )
public static int f( Integer a )
public static Integer f( int a )
public static Integer f( Integer a )
However, I observe that Derby is only able to resolve the first and third signatures (the ones with primitive arguments). I will attach a test case showing this problem.
I will also attach an html table summarizing the simply and object mappable rules.
Attachments
Attachments
Issue Links
- incorporates
-
DERBY-3511 Cannot resolve functions which return VARCHAR FOR BIT DATA or LONG VARCHAR FOR BIT DATA
- Closed
-
DERBY-3694 'Method resolution for signature java.lang.String.valueOf(int) was ambiguous. (No single maximally specific method.)' in 'testFunctionNullHandling(org.apache.derbyTesting.functionTests.tests.lang.RoutineTest)' on JavaME
- Closed
-
DERBY-3744 User-coded functions can't return Blob or Clob because these raise connection-killing errors in the byte-code compiler
- Closed
-
DERBY-4068 Numeric arguments to functions/parameters raise overflow condition in client/server configuration.
- Closed
-
DERBY-5497 Derby cannot resolve BINARY output procedure parameters on CDC/FP 1.1
- Closed
-
DERBY-3737 Document the new SignatureChecker lint tool in the Tools Guide
- Closed
-
DERBY-4078 Document the SQL Standard routine matching rules which Derby now supports
- Closed
- is duplicated by
-
DERBY-1483 Java Function defined with a BIGINT parameter invokes the method with a signature of method(long) rather than method(Long)
- Closed
- is related to
-
DERBY-3697 Compiler exception when invoking a routine with NUMERIC argument on J2ME
- Closed
-
DERBY-4958 Wrapper types not recognized when resolving procedures with OUT arguments.
- Closed
-
DERBY-4066 Allow functions/procedures to take Blob/Clob arguments
- Closed
- relates to
-
DERBY-2201 Calling functions that return Blob/Clob does not work.
- Closed