JDBC version 1.0.1
Server version 7.6
DatabaseMetadata.getFunctions does not return a single row that represents the UDAF, it returns a row for the routines that implement init, iter, merge etc.
For example the Resultset returned by DatabaseMetadata.getFunctions(null, null, “%”) returns following.
Column Name:FUNCTION_CAT, display size:64, type name:VARSTRING, type id:12, precision:64, scale:0
Column Name:FUNCTION_SCHEM, display size:0, type name:NULL, type id:0, precision:0, scale:0
Column Name:FUNCTION_NAME, display size:64, type name:VARSTRING, type id:12, precision:64, scale:0
Column Name:REMARKS, display size:-1, type name:LONGBLOB, type id:-1, precision:-1, scale:0
Column Name:FUNCTION_TYPE, display size:20, type name:BIGINT, type id:-5, precision:20, scale:0
Column Name:SPECIFIC_NAME, display size:64, type name:VARSTRING, type id:12, precision:64, scale:0
[cert],[null],[FAGGBINTinit],[],[1],[FAGGBINTinit]
[cert],[null],[FAGGBINTiter],[],[1],[FAGGBINTiter]
[cert],[null],[FAGGBINTmerge],[],[1],[FAGGBINTmerge]
[cert],[null],[FAGGBINTterminate],[],[1],[FAGGBINTterminate]
CREATE OR REPLACE AGGREGATE FAGGINT(integer ) RETURNS integer
WITH STATE integer
INITIALIZE WITH FAGGINTinit
ITERATE WITH FAGGINTiter
MERGE WITH FAGGINTmerge
TERMINATE WITH FAGGINTterminate;
//
CREATE OR REPLACE FUNCTION FAGGBINTinit() RETURNS bigint AS
declare s bigint ;
BEGIN
RETURN s;
END //
CREATE OR REPLACE FUNCTION FAGGBINTiter (s bigint , v bigint )
RETURNS bigint AS
BEGIN
IF (v is not null and s is null) or ( v > s ) THEN
return v;
END IF;
RETURN s;
END //
CREATE OR REPLACE FUNCTION FAGGBINTmerge(s1 bigint , s2 bigint )
RETURNS bigint AS
BEGIN
IF s2 > s1 THEN
RETURN s2;
END IF;
RETURN s1;
END //
CREATE OR REPLACE FUNCTION FAGGBINTterminate(s bigint ) RETURNS bigint AS
BEGIN
RETURN s;
END //