db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r701367 - in /db/derby/code/trunk/java: engine/org/apache/derby/catalog/types/ engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ te...
Date Fri, 03 Oct 2008 12:44:35 GMT
Author: rhillegas
Date: Fri Oct  3 05:44:34 2008
New Revision: 701367

URL: http://svn.apache.org/viewvc?rev=701367&view=rev
Log:
DERBY-3570: Add ability to declare DETERMINISTIC routines.

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/compile/sqlgrammar.jj
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out
    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/GeneratedColumnsTest.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_5.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=701367&r1=701366&r2=701367&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 Fri
Oct  3 05:44:34 2008
@@ -366,11 +366,16 @@
 		}
 
 		sb.append(" LANGUAGE JAVA PARAMETER STYLE " );
+
 		switch( parameterStyle )
 		{
 		    case PS_JAVA:    sb.append( "JAVA " ); break;
 		    case PS_DERBY_JDBC_RESULT_SET:    sb.append( "DERBY_JDBC_RESULT_SET " ); break;
 		}
+        
+        if ( isDeterministic() )
+        { sb.append( " DETERMINISTIC " ); }
+        
 		sb.append(RoutineAliasInfo.SQL_CONTROL[getSQLAllowed()]);
 		if ((returnType == null) &&
 			(dynamicResultSets != 0))

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=701367&r1=701366&r2=701367&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 Fri Oct
 3 05:44:34 2008
@@ -2151,6 +2151,7 @@
 |	<DATE: "date">
 |	<DAY: "day">
 |	<DEFINER: "definer">
+|	<DETERMINISTIC: "deterministic">
 |   <DYNAMIC: "dynamic">
 |	<FORTRAN: "fortran">
 |   <GENERATED: "generated">
@@ -10027,6 +10028,20 @@
 	|
 		<LANGUAGE>  <JAVA> { clauseValue = "JAVA"; clausePosition = CreateAliasNode.LANGUAGE;
}
 	|
+		<DETERMINISTIC>
+        {
+            clauseValue = Boolean.TRUE;
+            clausePosition = CreateAliasNode.DETERMINISTIC;
+            checkVersion(DataDictionary.DD_VERSION_DERBY_10_5, "DETERMINISTIC");
+        }
+	|
+		<NOT> <DETERMINISTIC>
+        {
+            clauseValue = Boolean.FALSE;
+            clausePosition = CreateAliasNode.DETERMINISTIC; 
+            checkVersion(DataDictionary.DD_VERSION_DERBY_10_5, "DETERMINISTIC");
+        }
+	|
 		<EXTERNAL> <NAME> clauseValue = string() { clausePosition = CreateAliasNode.EXTERNAL_NAME;
}
 	|
 		<PARAMETER> <STYLE> clauseValue = parameterStyle( isTableFunction ) { clausePosition
= CreateAliasNode.PARAMETER_STYLE; }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out?rev=701367&r1=701366&r2=701367&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net.out
Fri Oct  3 05:44:34 2008
@@ -23,6 +23,26 @@
 <systemname>
 -----
 <systemid>
+F_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC NO SQL CALLED
ON NULL INPUT
+<systemname>
+-----
+<systemid>
+F_NOT_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL CALLED ON NULL INPUT
+<systemname>
+-----
+<systemid>
 GATP2
 FOO
 org.apache.derbyTesting.functionTests.util.TestPropertyInfo
@@ -73,6 +93,26 @@
 <systemname>
 -----
 <systemid>
+P_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC MODIFIES SQL DATA
+<systemname>
+-----
+<systemid>
+P_NOT_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA
+<systemname>
+-----
+<systemid>
 SQQLCONTROL_1
 FOO
 org.apache.derbyTesting.functionTests.util.ProcedureTest

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out?rev=701367&r1=701366&r2=701367&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/dblook_test_net_territory.out
Fri Oct  3 05:44:34 2008
@@ -23,6 +23,26 @@
 <systemname>
 -----
 <systemid>
+F_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC NO SQL CALLED
ON NULL INPUT
+<systemname>
+-----
+<systemid>
+F_NOT_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL CALLED ON NULL INPUT
+<systemname>
+-----
+<systemid>
 GATP2
 FOO
 org.apache.derbyTesting.functionTests.util.TestPropertyInfo
@@ -73,6 +93,26 @@
 <systemname>
 -----
 <systemid>
+P_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC MODIFIES SQL DATA
+<systemname>
+-----
+<systemid>
+P_NOT_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA
+<systemname>
+-----
+<systemid>
 SQQLCONTROL_1
 FOO
 org.apache.derbyTesting.functionTests.util.ProcedureTest

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=701367&r1=701366&r2=701367&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
Fri Oct  3 05:44:34 2008
@@ -23,6 +23,26 @@
 <systemname>
 -----
 <systemid>
+F_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC NO SQL CALLED
ON NULL INPUT
+<systemname>
+-----
+<systemid>
+F_NOT_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL CALLED ON NULL INPUT
+<systemname>
+-----
+<systemid>
 GATP2
 FOO
 org.apache.derbyTesting.functionTests.util.TestPropertyInfo
@@ -73,6 +93,26 @@
 <systemname>
 -----
 <systemid>
+P_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC MODIFIES SQL DATA
+<systemname>
+-----
+<systemid>
+P_NOT_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA
+<systemname>
+-----
+<systemid>
 SQQLCONTROL_1
 FOO
 org.apache.derbyTesting.functionTests.util.ProcedureTest

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=701367&r1=701366&r2=701367&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
Fri Oct  3 05:44:34 2008
@@ -23,6 +23,26 @@
 <systemname>
 -----
 <systemid>
+F_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC NO SQL CALLED
ON NULL INPUT
+<systemname>
+-----
+<systemid>
+F_NOT_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL CALLED ON NULL INPUT
+<systemname>
+-----
+<systemid>
 GATP2
 FOO
 org.apache.derbyTesting.functionTests.util.TestPropertyInfo
@@ -73,6 +93,26 @@
 <systemname>
 -----
 <systemid>
+P_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC MODIFIES SQL DATA
+<systemname>
+-----
+<systemid>
+P_NOT_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA
+<systemname>
+-----
+<systemid>
 SQQLCONTROL_1
 FOO
 org.apache.derbyTesting.functionTests.util.ProcedureTest

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=701367&r1=701366&r2=701367&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
Fri Oct  3 05:44:34 2008
@@ -16,6 +16,26 @@
 <systemname>
 ----
 <systemid>
+F_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC NO SQL CALLED
ON NULL INPUT
+<systemname>
+----
+<systemid>
+F_NOT_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL CALLED ON NULL INPUT
+<systemname>
+----
+<systemid>
 GATP2
 FOO
 org.apache.derbyTesting.functionTests.util.TestPropertyInfo
@@ -66,6 +86,26 @@
 <systemname>
 ----
 <systemid>
+P_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC MODIFIES SQL DATA
+<systemname>
+----
+<systemid>
+P_NOT_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA
+<systemname>
+----
+<systemid>
 SQQLCONTROL_1
 FOO
 org.apache.derbyTesting.functionTests.util.ProcedureTest
@@ -2003,6 +2043,26 @@
 <systemname>
 ----
 <systemid>
+F_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC NO SQL CALLED
ON NULL INPUT
+<systemname>
+----
+<systemid>
+F_NOT_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL CALLED ON NULL INPUT
+<systemname>
+----
+<systemid>
 GATP2
 FOO
 org.apache.derbyTesting.functionTests.util.TestPropertyInfo
@@ -2053,6 +2113,26 @@
 <systemname>
 ----
 <systemid>
+P_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC MODIFIES SQL DATA
+<systemname>
+----
+<systemid>
+P_NOT_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA
+<systemname>
+----
+<systemid>
 SQQLCONTROL_1
 FOO
 org.apache.derbyTesting.functionTests.util.ProcedureTest

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=701367&r1=701366&r2=701367&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
Fri Oct  3 05:44:34 2008
@@ -16,6 +16,26 @@
 <systemname>
 ----
 <systemid>
+F_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC NO SQL CALLED
ON NULL INPUT
+<systemname>
+----
+<systemid>
+F_NOT_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL CALLED ON NULL INPUT
+<systemname>
+----
+<systemid>
 GATP2
 FOO
 org.apache.derbyTesting.functionTests.util.TestPropertyInfo
@@ -66,6 +86,26 @@
 <systemname>
 ----
 <systemid>
+P_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC MODIFIES SQL DATA
+<systemname>
+----
+<systemid>
+P_NOT_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA
+<systemname>
+----
+<systemid>
 SQQLCONTROL_1
 FOO
 org.apache.derbyTesting.functionTests.util.ProcedureTest
@@ -2003,6 +2043,26 @@
 <systemname>
 ----
 <systemid>
+F_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC NO SQL CALLED
ON NULL INPUT
+<systemname>
+----
+<systemid>
+F_NOT_DETERMINISTIC
+APP
+foo.bar
+F
+F
+false
+wibble() RETURNS INTEGER LANGUAGE JAVA PARAMETER STYLE JAVA NO SQL CALLED ON NULL INPUT
+<systemname>
+----
+<systemid>
 GATP2
 FOO
 org.apache.derbyTesting.functionTests.util.TestPropertyInfo
@@ -2053,6 +2113,26 @@
 <systemname>
 ----
 <systemid>
+P_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA  DETERMINISTIC MODIFIES SQL DATA
+<systemname>
+----
+<systemid>
+P_NOT_DETERMINISTIC
+APP
+foo.bar
+P
+P
+false
+wibble() LANGUAGE JAVA PARAMETER STYLE JAVA MODIFIES SQL DATA
+<systemname>
+----
+<systemid>
 SQQLCONTROL_1
 FOO
 org.apache.derbyTesting.functionTests.util.ProcedureTest

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java?rev=701367&r1=701366&r2=701367&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
Fri Oct  3 05:44:34 2008
@@ -53,6 +53,8 @@
     //
     ///////////////////////////////////////////////////////////////////////////////////
 
+    private static  final   String  REDUNDANT_CLAUSE = "42613";
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // STATE
@@ -94,7 +96,7 @@
 
     ///////////////////////////////////////////////////////////////////////////////////
     //
-    // SUCCESSFUL RESOLUTIONS
+    // TESTS
     //
     ///////////////////////////////////////////////////////////////////////////////////
 
@@ -102,7 +104,9 @@
      * <p>
      * Test that the stored system procedures and functions are non-deterministic. If you
want
      * a particular procedure/function to be deterministic, add some logic here.
+     * </p>
      *
+     * </p>
      * Also test that, by default, user-defined routines are created as NOT DETERMINISTIC.
      * </p>
      */
@@ -157,18 +161,219 @@
 
             RoutineAliasInfo    rai = (RoutineAliasInfo) rs.getObject( 5 );
 
-            assertFalse( aliasName, rai.isDeterministic() );
+            if ( isSystemAlias ) { assertFalse( aliasName, rai.isDeterministic() ); }
         }
 
         rs.close();
         ps.close();
     }
 
+    /**
+     * <p>
+     * Basic positive tests for DETERMINISTIC keyword.
+     * </p>
+     */
+    public  void    test_002_determinism_positive()
+        throws Exception
+    {
+        Connection  conn = getConnection();
+
+        goodStatement
+            (
+             conn,
+             "create function f11()\n" +
+             "returns int\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "no sql\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        assertDeterministic( conn, "F11", false );
+        
+        goodStatement
+            (
+             conn,
+             "create function f12()\n" +
+             "returns int\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "deterministic\n" +
+             "no sql\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        assertDeterministic( conn, "F12", true );
+        
+        goodStatement
+            (
+             conn,
+             "create function f13()\n" +
+             "returns int\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "no sql\n" +
+             "not deterministic\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        assertDeterministic( conn, "F13", false );
+        
+        goodStatement
+            (
+             conn,
+             "create procedure p11()\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "modifies sql data\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        assertDeterministic( conn, "P11", false );
+        
+        goodStatement
+            (
+             conn,
+             "create procedure p12()\n" +
+             "deterministic\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "modifies sql data\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        assertDeterministic( conn, "P12", true );
+        
+        goodStatement
+            (
+             conn,
+             "create procedure p13()\n" +
+             "language java\n" +
+             "not deterministic\n" +
+             "parameter style java\n" +
+             "modifies sql data\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        assertDeterministic( conn, "P13", false );
+    }
+
+    /**
+     * <p>
+     * Verify that we get errors when there is more than one determinism clause
+     * in a routine declaration.
+     * </p>
+     */
+    public  void    test_003_determinism_redundantClause()
+        throws Exception
+    {
+        Connection  conn = getConnection();
 
+        expectError
+            (
+             REDUNDANT_CLAUSE,
+             "create function f_fail()\n" +
+             "returns int\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "deterministic\n" +
+             "deterministic\n" +
+             "no sql\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        expectError
+            (
+             REDUNDANT_CLAUSE,
+             "create function f_fail()\n" +
+             "returns int\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "not deterministic\n" +
+             "deterministic\n" +
+             "no sql\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        expectError
+            (
+             REDUNDANT_CLAUSE,
+             "create procedure p_fail()\n" +
+             "language java\n" +
+             "deterministic\n" +
+             "parameter style java\n" +
+             "modifies sql data\n" +
+             "deterministic\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        expectError
+            (
+             REDUNDANT_CLAUSE,
+             "create procedure p_fail()\n" +
+             "language java\n" +
+             "not deterministic\n" +
+             "parameter style java\n" +
+             "modifies sql data\n" +
+             "not deterministic\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // MINIONS
     //
     ///////////////////////////////////////////////////////////////////////////////////
 
+    /**
+     * Run good DDL.
+     * @throws SQLException 
+     */
+    private void    goodStatement( Connection conn, String ddl ) throws SQLException
+    {
+        PreparedStatement    ps = chattyPrepare( conn, ddl );
+
+        ps.execute();
+        ps.close();
+    }
+    
+    /**
+     * Prepare a statement and report its sql text.
+     */
+    private PreparedStatement   chattyPrepare( Connection conn, String text )
+        throws SQLException
+    {
+        println( "Preparing statement:\n\t" + text );
+        
+        return conn.prepareStatement( text );
+    }
+
+    /**
+     * Assert that the statement text, when compiled, raises an exception
+     */
+    private void    expectError( String sqlState, String query )
+    {
+        println( "\nExpecting " + sqlState + " when preparing:\n\t" + query );
+
+        assertCompileError( sqlState, query );
+    }
+
+    /**
+     * <p>
+     * Assert whether a routine is expected to be DETERMINISTIC.
+     * </p>
+     */
+    public  void    assertDeterministic( Connection conn, String routineName, boolean isDeterministic
)
+        throws Exception
+    {
+        PreparedStatement   ps = conn.prepareStatement
+            (
+             "select a.aliasinfo\n" +
+             "from sys.sysaliases a\n" +
+             "where alias =  ?"
+             );
+        ps.setString( 1, routineName );
+        ResultSet               rs = ps.executeQuery();
+
+        rs.next();
+        RoutineAliasInfo    rai = (RoutineAliasInfo) rs.getObject( 1 );
+
+        assertEquals( isDeterministic, rai.isDeterministic() );
+
+        rs.close();
+        ps.close();
+    }
+
 }
\ No newline at end of file

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=701367&r1=701366&r2=701367&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
Fri Oct  3 05:44:34 2008
@@ -71,6 +71,10 @@
 
 create procedure """proc ""In Quotes with spaces""" (INOUT a CHAR(10), IN b int) language
java external name 'org.apache.derbyTesting.functionTests.util.ProcedureTest.inoutparams3'
parameter style java dynamic result sets 2 modifies sql data;
 
+create procedure p_deterministic() deterministic language java parameter style java modifies
sql data external name 'foo.bar.wibble';
+
+create procedure p_not_deterministic() language java not deterministic parameter style java
modifies sql data external name 'foo.bar.wibble';
+
 -- ----------------------------------------------
 -- Functions.
 -- ----------------------------------------------
@@ -79,6 +83,10 @@
 
 create function foo.gatp2(SCH VARCHAR(128), TBL VARCHAR(128)) RETURNS VARCHAR(1000) EXTERNAL
NAME 'org.apache.derbyTesting.functionTests.util.TestPropertyInfo.getAllTableProperties' LANGUAGE
JAVA PARAMETER STYLE JAVA RETURNS NULL ON NULL INPUT;
 
+create function f_deterministic() returns int language java parameter style java deterministic
no sql external name 'foo.bar.wibble';
+
+create function f_not_deterministic() returns int language java parameter style java no sql
not deterministic external name 'foo.bar.wibble';
+
 -- ----------------------------------------------
 -- Tables
 -- ----------------------------------------------

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_5.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_5.java?rev=701367&r1=701366&r2=701367&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_5.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_5.java
Fri Oct  3 05:44:34 2008
@@ -44,6 +44,8 @@
  */
 public class Changes10_5 extends UpgradeChange {
 
+    private static  final   String  BAD_SYNTAX = "42X01";
+
     public Changes10_5(String name) {
         super(name);
     }
@@ -108,4 +110,75 @@
             break;
         }
     }
+
+    /**
+     * Test that the DETERMINISTIC keyword is not allowed until you
+     * hard-upgrade to 10.5.
+     *
+     */
+    public void testDeterminismKeyword() throws SQLException
+    {
+        String  sqlstate = null;
+        
+        switch (getPhase())
+        {
+        case PH_SOFT_UPGRADE:
+            sqlstate = SQLSTATE_NEED_UPGRADE;
+            break;
+            
+        case PH_POST_SOFT_UPGRADE:
+            sqlstate = BAD_SYNTAX;
+            break;
+
+        case PH_HARD_UPGRADE:
+            sqlstate = null;
+            break;
+
+        default:
+            return;
+        }
+        
+        possibleError
+            (
+             sqlstate,
+             "create function f_3570_12()\n" +
+             "returns int\n" +
+             "language java\n" +
+             "parameter style java\n" +
+             "deterministic\n" +
+             "no sql\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+        possibleError
+            (
+             sqlstate,
+             "create procedure p_3570_13()\n" +
+             "language java\n" +
+             "not deterministic\n" +
+             "parameter style java\n" +
+             "modifies sql data\n" +
+             "external name 'foo.bar.wibble'\n"
+             );
+    }
+
+    /**
+     * <p>
+     * Run a statement. If the sqlstate is not null, then we expect that error.
+     * </p>
+     */
+    private void    possibleError( String sqlstate, String text )
+        throws SQLException
+    {
+        if ( sqlstate != null )
+        {
+            assertCompileError( sqlstate, text );
+        }
+        else
+        {
+            Statement   s = createStatement();
+            s.execute( text );
+            s.close();
+        }
+    }
+
 }



Mime
View raw message