Author: rhillegas Date: Thu Dec 6 13:18:54 2012 New Revision: 1417835 URL: http://svn.apache.org/viewvc?rev=1417835&view=rev Log: DERBY-3069: DDL for varargs routines. Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/VarargsTest.java (with props) Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/types/RoutineAliasInfo.java Thu Dec 6 13:18:54 2012 @@ -54,12 +54,14 @@ public class RoutineAliasInfo extends Me /** PARAMETER STYLE DERBY_JDBC_RESULT_SET */ public static final short PS_DERBY_JDBC_RESULT_SET = PS_JAVA + 1; + /** PARAMETER STYLE DERBY */ + public static final short PS_DERBY = PS_DERBY_JDBC_RESULT_SET + 1; + /** Masks for the sqlOptions field */ private static final short SQL_ALLOWED_MASK = (short) 0xF; private static final short DETERMINISTIC_MASK = (short) 0x10; - - /** Mask for the SECURITY INVOKER/DEFINER field */ - private static final short SECURITY_DEFINER_MASK = (short) 0x20; + private static final short SECURITY_DEFINER_MASK = (short) 0x20; // Mask for the SECURITY INVOKER/DEFINER field + private static final short VARARGS_MASK = (short) 0x40; private int parameterCount; @@ -121,10 +123,20 @@ public class RoutineAliasInfo extends Me /** Create a RoutineAliasInfo for an internal PROCEDURE. */ - public RoutineAliasInfo(String methodName, int parameterCount, String[] parameterNames, - TypeDescriptor[] parameterTypes, int[] parameterModes, int dynamicResultSets, short parameterStyle, short sqlAllowed, - boolean isDeterministic ) { - + public RoutineAliasInfo + ( + String methodName, + int parameterCount, + String[] parameterNames, + TypeDescriptor[] parameterTypes, + int[] parameterModes, + int dynamicResultSets, + short parameterStyle, + short sqlAllowed, + boolean isDeterministic, + boolean hasVarargs + ) + { this(methodName, parameterCount, parameterNames, @@ -134,6 +146,7 @@ public class RoutineAliasInfo extends Me parameterStyle, sqlAllowed, isDeterministic, + hasVarargs, false /* definersRights*/, true, (TypeDescriptor) null); @@ -151,6 +164,7 @@ public class RoutineAliasInfo extends Me short parameterStyle, short sqlAllowed, boolean isDeterministic, + boolean hasVarargs, boolean definersRights, boolean calledOnNullInput, TypeDescriptor returnType) @@ -165,6 +179,7 @@ public class RoutineAliasInfo extends Me this.parameterStyle = parameterStyle; this.sqlOptions = (short) (sqlAllowed & SQL_ALLOWED_MASK); if ( isDeterministic ) { this.sqlOptions = (short) (sqlOptions | DETERMINISTIC_MASK); } + if ( hasVarargs ) { this.sqlOptions = (short) (sqlOptions | VARARGS_MASK); } if (definersRights) { this.sqlOptions = (short) (sqlOptions | SECURITY_DEFINER_MASK); @@ -251,6 +266,11 @@ public class RoutineAliasInfo extends Me return ( (sqlOptions & DETERMINISTIC_MASK) != 0 ); } + public boolean hasVarargs() + { + return ( (sqlOptions & VARARGS_MASK) != 0 ); + } + public boolean hasDefinersRights() { return ( (sqlOptions & SECURITY_DEFINER_MASK) != 0 ); @@ -392,6 +412,7 @@ public class RoutineAliasInfo extends Me sb.append(' '); sb.append(parameterTypes[i].getSQLstring()); } + if ( hasVarargs() ) { sb.append( " ... " ); } sb.append(')'); if (returnType != null) { @@ -405,6 +426,7 @@ public class RoutineAliasInfo extends Me { case PS_JAVA: sb.append( "JAVA " ); break; case PS_DERBY_JDBC_RESULT_SET: sb.append( "DERBY_JDBC_RESULT_SET " ); break; + case PS_DERBY: sb.append( "DERBY " ); break; } if ( isDeterministic() ) Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java Thu Dec 6 13:18:54 2012 @@ -244,30 +244,30 @@ public final class DataDictionaryImpl * */ private static final String[][] SYSFUN_FUNCTIONS = { - {"ACOS", "DOUBLE", "java.lang.StrictMath", "acos(double)", "true", "DOUBLE"}, - {"ASIN", "DOUBLE", "java.lang.StrictMath", "asin(double)", "true", "DOUBLE"}, - {"ATAN", "DOUBLE", "java.lang.StrictMath", "atan(double)", "true", "DOUBLE"}, - {"ATAN2", "DOUBLE", "java.lang.StrictMath", "atan2(double,double)", "true", "DOUBLE", "DOUBLE"}, - {"COS", "DOUBLE", "java.lang.StrictMath", "cos(double)", "true", "DOUBLE"}, - {"SIN", "DOUBLE", "java.lang.StrictMath", "sin(double)", "true", "DOUBLE"}, - {"TAN", "DOUBLE", "java.lang.StrictMath", "tan(double)", "true", "DOUBLE"}, - {"PI", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "PI()", "true"}, - {"DEGREES", "DOUBLE", "java.lang.StrictMath", "toDegrees(double)", "true", "DOUBLE"}, - {"RADIANS", "DOUBLE", "java.lang.StrictMath", "toRadians(double)", "true", "DOUBLE"}, - {"LN", "DOUBLE", "java.lang.StrictMath", "log(double)", "true", "DOUBLE"}, - {"LOG", "DOUBLE", "java.lang.StrictMath", "log(double)", "true", "DOUBLE"}, // Same as LN - {"LOG10", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "LOG10(double)", "true", "DOUBLE"}, - {"EXP", "DOUBLE", "java.lang.StrictMath", "exp(double)", "true", "DOUBLE"}, - {"CEIL", "DOUBLE", "java.lang.StrictMath", "ceil(double)", "true", "DOUBLE"}, - {"CEILING", "DOUBLE", "java.lang.StrictMath", "ceil(double)", "true", "DOUBLE"}, // Same as CEIL - {"FLOOR", "DOUBLE", "java.lang.StrictMath", "floor(double)", "true", "DOUBLE"}, - {"SIGN", "INTEGER", "org.apache.derby.catalog.SystemProcedures", "SIGN(double)", "true", "DOUBLE"}, - {"RANDOM", "DOUBLE", "java.lang.StrictMath", "random()", "false" }, - {"RAND", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "RAND(int)", "false", "INTEGER"}, // Escape function spec. - {"COT", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "COT(double)", "true", "DOUBLE"}, - {"COSH", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "COSH(double)", "true", "DOUBLE"}, - {"SINH", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "SINH(double)", "true", "DOUBLE"}, - {"TANH", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "TANH(double)", "true", "DOUBLE"} + {"ACOS", "DOUBLE", "java.lang.StrictMath", "acos(double)", "true", "false", "DOUBLE" }, + {"ASIN", "DOUBLE", "java.lang.StrictMath", "asin(double)", "true", "false", "DOUBLE" }, + {"ATAN", "DOUBLE", "java.lang.StrictMath", "atan(double)", "true", "false", "DOUBLE" }, + {"ATAN2", "DOUBLE", "java.lang.StrictMath", "atan2(double,double)", "true", "false", "DOUBLE", "DOUBLE" }, + {"COS", "DOUBLE", "java.lang.StrictMath", "cos(double)", "true", "false", "DOUBLE" }, + {"SIN", "DOUBLE", "java.lang.StrictMath", "sin(double)", "true", "false", "DOUBLE" }, + {"TAN", "DOUBLE", "java.lang.StrictMath", "tan(double)", "true", "false", "DOUBLE" }, + {"PI", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "PI()", "false", "true" }, + {"DEGREES", "DOUBLE", "java.lang.StrictMath", "toDegrees(double)", "true", "false", "DOUBLE" }, + {"RADIANS", "DOUBLE", "java.lang.StrictMath", "toRadians(double)", "true", "false", "DOUBLE" }, + {"LN", "DOUBLE", "java.lang.StrictMath", "log(double)", "true", "false", "DOUBLE" }, + {"LOG", "DOUBLE", "java.lang.StrictMath", "log(double)", "true", "false", "DOUBLE" }, // Same as LN + {"LOG10", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "LOG10(double)", "true", "false", "DOUBLE" }, + {"EXP", "DOUBLE", "java.lang.StrictMath", "exp(double)", "true", "false", "DOUBLE" }, + {"CEIL", "DOUBLE", "java.lang.StrictMath", "ceil(double)", "true", "false", "DOUBLE" }, + {"CEILING", "DOUBLE", "java.lang.StrictMath", "ceil(double)", "true", "false", "DOUBLE" }, // Same as CEIL + {"FLOOR", "DOUBLE", "java.lang.StrictMath", "floor(double)", "true", "false", "DOUBLE" }, + {"SIGN", "INTEGER", "org.apache.derby.catalog.SystemProcedures", "SIGN(double)", "true", "false", "DOUBLE" }, + {"RANDOM", "DOUBLE", "java.lang.StrictMath", "random()", "false", "false" }, + {"RAND", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "RAND(int)", "false", "false", "INTEGER" }, // Escape function spec. + {"COT", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "COT(double)", "true", "false", "DOUBLE" }, + {"COSH", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "COSH(double)", "true", "false", "DOUBLE" }, + {"SINH", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "SINH(double)", "true", "false", "DOUBLE" }, + {"TANH", "DOUBLE", "org.apache.derby.catalog.SystemProcedures", "TANH(double)", "true", "false", "DOUBLE" } }; @@ -278,10 +278,16 @@ public final class DataDictionaryImpl private static final int SYSFUN_DETERMINISTIC_INDEX = 4; /** + * Index into SYSFUN_FUNCTIONS of the VARARGS indicator. + * Used to determine whether the system function has VARARGS + */ + private static final int SYSFUN_VARARGS_INDEX = 5; + + /** * The index of the first parameter in entries in the SYSFUN_FUNCTIONS * table. Used to determine the parameter count (zero to many). */ - private static final int SYSFUN_FIRST_PARAMETER_INDEX = 5; + private static final int SYSFUN_FIRST_PARAMETER_INDEX = 6; /** * Runtime definition of the functions from SYSFUN_FUNCTIONS. @@ -2686,6 +2692,7 @@ public final class DataDictionaryImpl oldRai.getParameterStyle(), oldRai.getSQLAllowed(), oldRai.isDeterministic(), + oldRai.hasVarargs(), oldRai.hasDefinersRights(), oldRai.calledOnNullInput(), newReturnType @@ -7809,6 +7816,7 @@ public final class DataDictionaryImpl DataTypeDescriptor.getBuiltInDataTypeDescriptor(details[1]).getCatalogType(); boolean isDeterministic = Boolean.valueOf( details[ SYSFUN_DETERMINISTIC_INDEX ] ).booleanValue(); + boolean hasVarargs = Boolean.valueOf( details[ SYSFUN_VARARGS_INDEX ] ).booleanValue(); // Determine the number of arguments (could be zero). int paramCount = details.length - SYSFUN_FIRST_PARAMETER_INDEX; @@ -7827,7 +7835,7 @@ public final class DataDictionaryImpl RoutineAliasInfo ai = new RoutineAliasInfo(details[3], paramCount, paramNames, pt, paramModes, 0, - RoutineAliasInfo.PS_JAVA, RoutineAliasInfo.NO_SQL, isDeterministic, + RoutineAliasInfo.PS_JAVA, RoutineAliasInfo.NO_SQL, isDeterministic, hasVarargs, false, /* hasDefinersRights */ false, rt); @@ -10727,6 +10735,7 @@ public final class DataDictionaryImpl int num_result_sets, short routine_sql_control, boolean isDeterministic, + boolean hasVarargs, TypeDescriptor return_type, HashSet newlyCreatedRoutines, TransactionController tc, @@ -10774,6 +10783,7 @@ public final class DataDictionaryImpl // CONTAINS_SQL // NO_SQL isDeterministic, // whether the procedure/function is DETERMINISTIC + hasVarargs, // whether the procedure/function has VARARGS false, // not definer's rights true, // true - calledOnNullInput return_type); @@ -10846,6 +10856,7 @@ public final class DataDictionaryImpl int num_result_sets, short routine_sql_control, boolean isDeterministic, + boolean hasVarargs, TypeDescriptor return_type, HashSet newlyCreatedRoutines, TransactionController tc) @@ -10853,7 +10864,7 @@ public final class DataDictionaryImpl { UUID routine_uuid = createSystemProcedureOrFunction(routine_name, schema_uuid, arg_names, arg_types, - num_out_param, num_result_sets, routine_sql_control, isDeterministic, + num_out_param, num_result_sets, routine_sql_control, isDeterministic, hasVarargs, return_type, newlyCreatedRoutines, tc, "org.apache.derby.catalog.SystemProcedures"); return routine_uuid; } @@ -10913,6 +10924,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -10941,6 +10953,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -10957,6 +10970,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -10973,6 +10987,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -10989,6 +11004,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11014,6 +11030,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11041,6 +11058,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11063,6 +11081,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11085,6 +11104,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11107,6 +11127,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11138,6 +11159,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, DataTypeDescriptor.getCatalogType( Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH), newlyCreatedRoutines, @@ -11164,6 +11186,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, TypeDescriptor.INTEGER, newlyCreatedRoutines, tc); @@ -11181,6 +11204,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, DataTypeDescriptor.getCatalogType( Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH), newlyCreatedRoutines, @@ -11223,6 +11247,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11247,6 +11272,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11270,6 +11296,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11309,6 +11336,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11346,6 +11374,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11388,6 +11417,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11433,6 +11463,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11469,6 +11500,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11568,6 +11600,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11599,6 +11632,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11630,6 +11664,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11661,6 +11696,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11694,6 +11730,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11728,6 +11765,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11761,6 +11799,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11794,6 +11833,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11827,6 +11867,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11865,6 +11906,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11903,6 +11945,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11930,6 +11973,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11966,6 +12010,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -11982,6 +12027,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12140,6 +12186,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12190,6 +12237,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12221,6 +12269,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12253,6 +12302,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12287,6 +12337,7 @@ public final class DataDictionaryImpl 1, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12324,6 +12375,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, TypeDescriptor.INTEGER, newlyCreatedRoutines, tc, @@ -12343,6 +12395,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, null, newlyCreatedRoutines, tc, @@ -12368,6 +12421,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, DataTypeDescriptor.getCatalogType( Types.BIGINT), newlyCreatedRoutines, @@ -12393,6 +12447,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, DataTypeDescriptor.getCatalogType( Types.BIGINT), newlyCreatedRoutines, @@ -12413,6 +12468,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, DataTypeDescriptor.getCatalogType( Types.BIGINT), newlyCreatedRoutines, @@ -12438,6 +12494,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, DataTypeDescriptor.getCatalogType( Types.VARCHAR, Limits.MAX_CLOB_RETURN_LEN), @@ -12466,6 +12523,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, null, newlyCreatedRoutines, tc, @@ -12489,6 +12547,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, null, newlyCreatedRoutines, tc, @@ -12510,6 +12569,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, TypeDescriptor.INTEGER, newlyCreatedRoutines, tc, @@ -12529,6 +12589,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, null, newlyCreatedRoutines, tc, @@ -12554,6 +12615,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, DataTypeDescriptor.getCatalogType( Types.BIGINT), newlyCreatedRoutines, @@ -12579,6 +12641,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, DataTypeDescriptor.getCatalogType( Types.BIGINT), newlyCreatedRoutines, @@ -12601,6 +12664,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, DataTypeDescriptor.getCatalogType( Types.BIGINT), newlyCreatedRoutines, @@ -12626,6 +12690,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, DataTypeDescriptor.getCatalogType( Types.VARBINARY, Limits.MAX_BLOB_RETURN_LEN), @@ -12654,6 +12719,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, null, newlyCreatedRoutines, tc, @@ -12677,6 +12743,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, null, newlyCreatedRoutines, tc, @@ -12719,6 +12786,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12756,6 +12824,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.CONTAINS_SQL, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12773,6 +12842,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, TypeDescriptor.INTEGER, newlyCreatedRoutines, tc); @@ -12798,6 +12868,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12814,6 +12885,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, CATALOG_TYPE_SYSTEM_IDENTIFIER, newlyCreatedRoutines, tc); @@ -12887,6 +12959,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12929,6 +13002,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -12969,6 +13043,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -13016,6 +13091,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -13033,6 +13109,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.NO_SQL, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -13052,6 +13129,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -13070,6 +13148,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, CATALOG_TYPE_SYSTEM_IDENTIFIER, newlyCreatedRoutines, tc); @@ -13086,6 +13165,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.NO_SQL, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -13133,6 +13213,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc @@ -13164,6 +13245,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc @@ -13194,6 +13276,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc @@ -13224,6 +13307,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc @@ -13253,6 +13337,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.READS_SQL_DATA, false, + false, DataTypeDescriptor.getCatalogType( Types.BIGINT ), newlyCreatedRoutines, tc); @@ -13280,6 +13365,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); @@ -13311,6 +13397,7 @@ public final class DataDictionaryImpl 0, RoutineAliasInfo.NO_SQL, false, + false, (TypeDescriptor) null, newlyCreatedRoutines, tc); Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateAliasNode.java Thu Dec 6 13:18:54 2012 @@ -60,12 +60,12 @@ public class CreateAliasNode extends DDL public static final int NULL_ON_NULL_INPUT = DETERMINISTIC + 1; public static final int RETURN_TYPE = NULL_ON_NULL_INPUT + 1; public static final int ROUTINE_SECURITY_DEFINER = RETURN_TYPE + 1; + public static final int VARARGS = ROUTINE_SECURITY_DEFINER + 1; // Keep ROUTINE_ELEMENT_COUNT last (determines set cardinality). // Note: Remember to also update the map ROUTINE_CLAUSE_NAMES in // sqlgrammar.jj when elements are added. - public static final int ROUTINE_ELEMENT_COUNT = - ROUTINE_SECURITY_DEFINER + 1; + public static final int ROUTINE_ELEMENT_COUNT = VARARGS + 1; // // These are the names of 1-arg builtin functions which are represented in the @@ -265,6 +265,9 @@ public class CreateAliasNode extends DDL Boolean isDeterministicO = (Boolean) routineElements[DETERMINISTIC]; boolean isDeterministic = (isDeterministicO == null) ? false : isDeterministicO.booleanValue(); + Boolean hasVarargsO = (Boolean) routineElements[ VARARGS ]; + boolean hasVarargs = (hasVarargsO == null) ? false : hasVarargsO.booleanValue(); + Boolean definersRightsO = (Boolean) routineElements[ROUTINE_SECURITY_DEFINER]; boolean definersRights = @@ -300,6 +303,7 @@ public class CreateAliasNode extends DDL ((Short) routineElements[PARAMETER_STYLE]).shortValue(), sqlAllowed, isDeterministic, + hasVarargs, definersRights, calledOnNullInput, returnType ); @@ -362,14 +366,42 @@ public class CreateAliasNode extends DDL //Are we dealing with user defined function or procedure? if (aliasType == AliasInfo.ALIAS_TYPE_FUNCTION_AS_CHAR || aliasType == AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR) { + + RoutineAliasInfo rai = (RoutineAliasInfo)aliasInfo; // Set the collation for all string types in parameters // and return types including row multi-sets to be that of // the schema the routine is being defined in. - ((RoutineAliasInfo)aliasInfo).setCollationTypeForAllStringTypes( + rai.setCollationTypeForAllStringTypes( getSchemaDescriptor().getCollationType()); bindParameterTypes( (RoutineAliasInfo)aliasInfo ); + + if ( rai.hasVarargs() ) + { + switch ( rai.getParameterStyle() ) + { + case RoutineAliasInfo.PS_DERBY_JDBC_RESULT_SET: + case RoutineAliasInfo.PS_DERBY: + break; + + default: + throw StandardException.newException( SQLState.LANG_VARARGS_PARAMETER_STYLE ); + } + + if ( rai.getMaxDynamicResultSets() > 0 ) + { + throw StandardException.newException( SQLState.LANG_VARARGS_RETURN_RESULT_SETS ); + } + } + + if ( + (rai.getParameterStyle() == RoutineAliasInfo.PS_DERBY) && + !rai.hasVarargs() + ) + { + throw StandardException.newException( SQLState.LANG_DERBY_PARAMETER_STYLE ); + } } // validity checking for UDTs Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Thu Dec 6 13:18:54 2012 @@ -171,17 +171,20 @@ public class SQLParser /* Keep in synch with CreateAliasNode's index constants */ private static final String[] ROUTINE_CLAUSE_NAMES = - {null, - "SPECIFIC", - "RESULT SET", - "LANGUAGE", - "EXTERNAL NAME", - "PARAMETER STYLE", - "SQL", - "DETERMINISTIC", - "ON NULL INPUT", - "RETURN TYPE", - "EXTERNAL SECURITY"}; + { + null, + "SPECIFIC", + "RESULT SET", + "LANGUAGE", + "EXTERNAL NAME", + "PARAMETER STYLE", + "SQL", + "DETERMINISTIC", + "ON NULL INPUT", + "RETURN TYPE", + "EXTERNAL SECURITY", + null, + }; /** Clauses required for Java routines. Numbers correspond to offsets in ROUTINE_CLAUSE_NAMES. @@ -2696,6 +2699,7 @@ TOKEN : | | | "> +| } TOKEN : @@ -10764,7 +10768,7 @@ procedureDefinition() throws StandardExc } { procedureName = qualifiedName(Limits.MAX_IDENTIFIER_LENGTH) - procedureElements[0] = procedureParameterList() + procedureElements[0] = procedureParameterList( procedureElements ) ( routineElement(true, false, procedureElements) ) + { checkRequiredRoutineClause(JAVA_ROUTINE_CLAUSES, procedureElements); @@ -10908,22 +10912,33 @@ Short parameterStyle( boolean isTableFun return ReuseFactory.getShort(RoutineAliasInfo.PS_DERBY_JDBC_RESULT_SET); } +| + + { + checkVersion(DataDictionary.DD_VERSION_DERBY_10_10, "DERBY"); + + return ReuseFactory.getShort( RoutineAliasInfo.PS_DERBY ); + } } Object[] -procedureParameterList() throws StandardException : +procedureParameterList( Object[] procedureElements ) throws StandardException : { Vector[] list = new Vector[3]; list[0] = new Vector(); // name list[1] = new Vector(); // type list[2] = new Vector(); // in/out + Boolean ellipsis = null; } { [ procedureParameterDefinition(list) - ( procedureParameterDefinition(list) )* ] + ( procedureParameterDefinition(list) )* + [ ellipsis = ellipsis() ] + ] { + procedureElements[ CreateAliasNode.VARARGS ] = ellipsis; return list; } } @@ -10992,7 +11007,7 @@ functionDefinition() throws StandardExce } { functionName = qualifiedName(Limits.MAX_IDENTIFIER_LENGTH) - functionElements[0] = functionParameterList() + functionElements[0] = functionParameterList( functionElements ) returnType = functionReturnDataType() ( routineElement(false, returnType.isRowMultiSet(), functionElements) ) + { @@ -11008,23 +11023,38 @@ functionDefinition() throws StandardExce } Object[] -functionParameterList() throws StandardException : +functionParameterList( Object[] functionElements ) throws StandardException : { Vector[] list = new Vector[3]; list[0] = new Vector(); // name list[1] = new Vector(); // type list[2] = new Vector(); // in/out - ALWAYS IN + Boolean ellipsis = null; } { [ functionParameterDefinition(list) - ( functionParameterDefinition(list) )* ] + ( functionParameterDefinition(list) )* + [ ellipsis = ellipsis() ] + ] { + functionElements[ CreateAliasNode.VARARGS ] = ellipsis; return list; } } +Boolean +ellipsis() throws StandardException : +{} +{ + + { + checkVersion( DataDictionary.DD_VERSION_DERBY_10_10, "..." ); + return Boolean.TRUE; + } +} + /* * functionParameterDefinition */ Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Thu Dec 6 13:18:54 2012 @@ -3016,6 +3016,21 @@ Guide. detailedMessage + + 42ZC9 + A varargs routine must have parameter style DERBY or DERBY_JDBC_RESULT_SET. + + + + 42ZCA + Parameter style DERBY is only allowed for varargs routines. + + + + 42ZCB + A varargs procedure may not return result sets. + + Modified: db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java (original) +++ db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java Thu Dec 6 13:18:54 2012 @@ -1127,6 +1127,10 @@ public interface SQLState { String LANG_UDA_WRONG_RETURN_TYPE = "42ZC7"; String LANG_UDA_INSTANTIATION = "42ZC8"; + String LANG_VARARGS_PARAMETER_STYLE = "42ZC9"; + String LANG_DERBY_PARAMETER_STYLE = "42ZCA"; + String LANG_VARARGS_RETURN_RESULT_SETS = "42ZCB"; + //following 3 matches the DB2 sql states String LANG_DECLARED_GLOBAL_TEMP_TABLE_ONLY_IN_SESSION_SCHEMA = "428EK"; String LANG_NOT_ALLOWED_FOR_DECLARED_GLOBAL_TEMP_TABLE = "42995"; Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net.out Thu Dec 6 13:18:54 2012 @@ -173,6 +173,36 @@ false ----- +VARARGSDERBYSTYLE +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL CALLED ON NULL INPUT + +----- + +VARARGSDERBYSTYLE +APP +Foo +P +P +false +foo(IN "A" INTEGER ... ) LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL + +----- + +VARARGSTABLEFUNCTION +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS TABLE ( "B" INTEGER ) LANGUAGE JAVA PARAMETER STYLE DERBY_JDBC_RESULT_SET NO SQL CALLED ON NULL INPUT + +----- + func "' schema "' java.lang.Integer Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/dblook_test_net_territory.out Thu Dec 6 13:18:54 2012 @@ -173,6 +173,36 @@ false ----- +VARARGSDERBYSTYLE +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL CALLED ON NULL INPUT + +----- + +VARARGSDERBYSTYLE +APP +Foo +P +P +false +foo(IN "A" INTEGER ... ) LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL + +----- + +VARARGSTABLEFUNCTION +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS TABLE ( "B" INTEGER ) LANGUAGE JAVA PARAMETER STYLE DERBY_JDBC_RESULT_SET NO SQL CALLED ON NULL INPUT + +----- + func "' schema "' java.lang.Integer Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test.out Thu Dec 6 13:18:54 2012 @@ -166,6 +166,36 @@ false ---- +VARARGSDERBYSTYLE +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL CALLED ON NULL INPUT + +---- + +VARARGSDERBYSTYLE +APP +Foo +P +P +false +foo(IN "A" INTEGER ... ) LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL + +---- + +VARARGSTABLEFUNCTION +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS TABLE ( "B" INTEGER ) LANGUAGE JAVA PARAMETER STYLE DERBY_JDBC_RESULT_SET NO SQL CALLED ON NULL INPUT + +---- + func "' schema "' java.lang.Integer @@ -2401,6 +2431,36 @@ false ---- +VARARGSDERBYSTYLE +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL CALLED ON NULL INPUT + +---- + +VARARGSDERBYSTYLE +APP +Foo +P +P +false +foo(IN "A" INTEGER ... ) LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL + +---- + +VARARGSTABLEFUNCTION +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS TABLE ( "B" INTEGER ) LANGUAGE JAVA PARAMETER STYLE DERBY_JDBC_RESULT_SET NO SQL CALLED ON NULL INPUT + +---- + func "' schema "' java.lang.Integer Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dblook_test_territory.out Thu Dec 6 13:18:54 2012 @@ -166,6 +166,36 @@ false ---- +VARARGSDERBYSTYLE +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL CALLED ON NULL INPUT + +---- + +VARARGSDERBYSTYLE +APP +Foo +P +P +false +foo(IN "A" INTEGER ... ) LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL + +---- + +VARARGSTABLEFUNCTION +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS TABLE ( "B" INTEGER ) LANGUAGE JAVA PARAMETER STYLE DERBY_JDBC_RESULT_SET NO SQL CALLED ON NULL INPUT + +---- + func "' schema "' java.lang.Integer @@ -2401,6 +2431,36 @@ false ---- +VARARGSDERBYSTYLE +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL CALLED ON NULL INPUT + +---- + +VARARGSDERBYSTYLE +APP +Foo +P +P +false +foo(IN "A" INTEGER ... ) LANGUAGE JAVA PARAMETER STYLE DERBY NO SQL + +---- + +VARARGSTABLEFUNCTION +APP +Foo +F +F +false +foo("A" INTEGER ... ) RETURNS TABLE ( "B" INTEGER ) LANGUAGE JAVA PARAMETER STYLE DERBY_JDBC_RESULT_SET NO SQL CALLED ON NULL INPUT + +---- + func "' schema "' java.lang.Integer Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/VarargsTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/VarargsTest.java?rev=1417835&view=auto ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/VarargsTest.java (added) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/VarargsTest.java Thu Dec 6 13:18:54 2012 @@ -0,0 +1,189 @@ +/* + + Derby - Class org.apache.derbyTesting.functionTests.tests.lang.VarargsTest + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to you under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + */ + +package org.apache.derbyTesting.functionTests.tests.lang; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.apache.derbyTesting.junit.Decorator; +import org.apache.derbyTesting.junit.TestConfiguration; +import org.apache.derbyTesting.junit.JDBC; + +/** + *

+ * Test routines with varargs. See DERBY-3069. + *

+ */ +public class VarargsTest extends GeneratedColumnsHelper +{ + /////////////////////////////////////////////////////////////////////////////////// + // + // CONSTANTS + // + /////////////////////////////////////////////////////////////////////////////////// + + private static final String NEEDS_DERBY_STYLE = "42ZC9"; + private static final String NEEDS_JAVA_STYLE = "42ZCA"; + private static final String RETURNS_RESULT_SETS = "42ZCB"; + + /////////////////////////////////////////////////////////////////////////////////// + // + // STATE + // + /////////////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////////////// + // + // CONSTRUCTOR + // + /////////////////////////////////////////////////////////////////////////////////// + + + /** + * Create a new instance. + */ + + public VarargsTest(String name) + { + super(name); + } + + /////////////////////////////////////////////////////////////////////////////////// + // + // JUnit BEHAVIOR + // + /////////////////////////////////////////////////////////////////////////////////// + + + /** + * Construct top level suite in this JUnit test + */ + public static Test suite() + { + TestSuite suite = new TestSuite( "UserDefinedAggregatesTest" ); + + suite.addTest( TestConfiguration.defaultSuite( VarargsTest.class ) ); + + return suite; + } + + /////////////////////////////////////////////////////////////////////////////////// + // + // TESTS + // + /////////////////////////////////////////////////////////////////////////////////// + + /** + *

+ * Basic syntax. + *

+ */ + public void test_01_basicSyntax() throws Exception + { + Connection conn = getConnection(); + + goodStatement + ( conn, + "create function varargsDerbyStyle( a int ... ) returns int\n" + + "parameter style derby language java no sql\n" + + "external name 'Foo.foo'\n" + ); + goodStatement + ( conn, + "create function varargsTableFunction( a int ... )\n" + + "returns table( b int )\n" + + "language java parameter style derby_jdbc_result_set no sql\n" + + "external name 'Foo.foo'\n" + ); + goodStatement + ( conn, + "create function nonvarargsJavaStyle( a int ) returns int\n" + + "parameter style java language java no sql\n" + + "external name 'Foo.foo'\n" + ); + goodStatement + ( conn, + "create procedure varargsDerbyStyle( a int ... )\n" + + "language java parameter style derby no sql\n" + + "external name 'Foo.foo'\n" + ); + goodStatement + ( conn, + "create procedure nonvarargsJavaStyle( a int )\n" + + "language java parameter style java no sql\n" + + "external name 'Foo.foo'\n" + ); + + // bad parameter style + expectCompilationError + ( NEEDS_DERBY_STYLE, + "create function varargsJavaStyle( a int ... ) returns int\n" + + "parameter style java language java no sql\n" + + "external name 'Foo.foo'\n" + ); + expectCompilationError + ( NEEDS_JAVA_STYLE, + "create function nonvarargsDerbyStyle( a int ) returns int\n" + + "parameter style derby language java no sql\n" + + "external name 'Foo.foo'\n" + ); + expectCompilationError + ( NEEDS_DERBY_STYLE, + "create procedure varargsDerbyStyle( a int ... )\n" + + "language java parameter style java no sql\n" + + "external name 'Foo.foo'\n" + ); + expectCompilationError + ( NEEDS_JAVA_STYLE, + "create procedure nonvarargsDerbyStyle( a int )\n" + + "language java parameter style derby no sql\n" + + "external name 'Foo.foo'\n" + ); + + // need at least one parameter in order to use varargs + expectCompilationError + ( SYNTAX_ERROR, + "create function varargsDerbyStyleNoParam( ... ) returns int\n" + + "parameter style derby language java no sql\n" + + "external name 'Foo.foo'\n" + ); + expectCompilationError + ( SYNTAX_ERROR, + "create procedure varargsDerbyStyleNoParam( ... )\n" + + "language java parameter style derby no sql\n" + + "external name 'Foo.foo'\n" + ); + + // bad because returns result sets + expectCompilationError + ( RETURNS_RESULT_SETS, + "create procedure varargsDerbyStyle( a int ... )\n" + + "language java parameter style derby no sql result sets 1\n" + + "external name 'Foo.foo'\n" + ); + } + +} Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/VarargsTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java Thu Dec 6 13:18:54 2012 @@ -133,6 +133,7 @@ public class _Suite extends BaseTestCase suite.addTest(CharUTF8Test.suite()); suite.addTest(AggregateClassLoadingTest.suite()); suite.addTest(TableFunctionTest.suite()); + suite.addTest(VarargsTest.suite()); suite.addTest(DeclareGlobalTempTableJavaTest.suite()); suite.addTest(PrimaryKeyTest.suite()); suite.addTest(RenameTableTest.suite()); Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/dblook_makeDB.sql Thu Dec 6 13:18:54 2012 @@ -79,6 +79,8 @@ create procedure p_not_deterministic() l create procedure p_definers_rights() language java parameter style java modifies sql data external name 'foo.bar.wibble' external security definer; +create procedure varargsDerbyStyle( a int ... ) language java parameter style derby no sql external name 'Foo.foo'; + -- ---------------------------------------------- -- Functions. -- ---------------------------------------------- @@ -95,6 +97,10 @@ create function f_not_deterministic() re create function f_definers_rights() returns int language java parameter style java no sql not deterministic external name 'foo.bar.wibble' external security definer; +create function varargsDerbyStyle( a int ... ) returns int parameter style derby language java no sql external name 'Foo.foo'; + +create function varargsTableFunction( a int ... ) returns table( b int ) language java parameter style derby_jdbc_result_set no sql external name 'Foo.foo'; + -- ---------------------------------------------- -- Tables Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java?rev=1417835&r1=1417834&r2=1417835&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_10.java Thu Dec 6 13:18:54 2012 @@ -59,6 +59,7 @@ public class Changes10_10 extends Upgrad private static final String SYNTAX_ERROR = "42X01"; private static final String HARD_UPGRADE_REQUIRED = "XCL47"; + private static final String NEEDS_JAVA_STYLE = "42ZCA"; /////////////////////////////////////////////////////////////////////////////////// // @@ -200,4 +201,51 @@ public class Changes10_10 extends Upgrad st.close(); } + /** + * Verify upgrade behavior for vararg routines. + */ + public void testVarargss() throws Exception + { + Statement st = createStatement(); + + String createVarargsProc = "create procedure varargsderbystyle ( a int ... ) language java parameter style derby no sql external name 'Foo.foo'"; + String createVarargsFunc = "create function varargsderbystyle ( a int ... ) returns integer language java parameter style derby no sql external name 'Foo.foo'"; + String createVarargsTableFunc = "create function varargstablefunction ( a int ... ) returns table ( b int ) language java parameter style derby_jdbc_result_set no sql external name 'Foo.foo'"; + String createNonVarargsProcDerbyStyle = "create procedure nonvarargsderbystyle ( a int ) language java parameter style derby no sql external name 'Foo.foo'"; + String createNonVarargsFuncDerbyStyle = "create function nonvarargsderbystyle ( a int ) returns integer language java parameter style derby no sql external name 'Foo.foo'"; + + // table functions were introduced by 10.4 + boolean tableFunctionsOK = oldAtLeast( 10, 4 ); + + switch ( getPhase() ) + { + case PH_CREATE: // create with old version + case PH_POST_SOFT_UPGRADE: // soft-downgrade: boot with old version after soft-upgrade + assertStatementError( SYNTAX_ERROR, st, createVarargsProc ); + assertStatementError( SYNTAX_ERROR, st, createVarargsFunc ); + if ( tableFunctionsOK ) { assertStatementError( SYNTAX_ERROR, st, createVarargsTableFunc ); } + assertStatementError( SYNTAX_ERROR, st, createNonVarargsProcDerbyStyle ); + assertStatementError( SYNTAX_ERROR, st, createNonVarargsFuncDerbyStyle ); + break; + + case PH_SOFT_UPGRADE: // boot with new version and soft-upgrade + assertStatementError( HARD_UPGRADE_REQUIRED, st, createVarargsProc ); + assertStatementError( HARD_UPGRADE_REQUIRED, st, createVarargsFunc ); + if ( tableFunctionsOK ) { assertStatementError( HARD_UPGRADE_REQUIRED, st, createVarargsTableFunc ); } + assertStatementError( HARD_UPGRADE_REQUIRED, st, createNonVarargsProcDerbyStyle ); + assertStatementError( HARD_UPGRADE_REQUIRED, st, createNonVarargsFuncDerbyStyle ); + break; + + case PH_HARD_UPGRADE: // boot with new version and hard-upgrade + st.execute( createVarargsProc ); + st.execute( createVarargsFunc ); + st.execute( createVarargsTableFunc ); + assertStatementError( NEEDS_JAVA_STYLE, st, createNonVarargsProcDerbyStyle ); + assertStatementError( NEEDS_JAVA_STYLE, st, createNonVarargsFuncDerbyStyle ); + break; + } + + st.close(); + } + }