You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2014/01/15 21:26:06 UTC

svn commit: r1558559 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/InsertNode.java testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java

Author: rhillegas
Date: Wed Jan 15 20:26:05 2014
New Revision: 1558559

URL: http://svn.apache.org/r1558559
Log:
DERBY-6434: Don't make INSERT statements require USAGE privilege on the datatypes of generated columns; fix remaining problem described by DERBY-6433; commit derby-6434-04-aa-dontNeedPrivOnGeneratedColumnTypeForInsert.diff.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java?rev=1558559&r1=1558558&r2=1558559&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/InsertNode.java Wed Jan 15 20:26:05 2014
@@ -265,7 +265,6 @@ public final class InsertNode extends DM
         IgnoreFilter    ignorePermissions = new IgnoreFilter();
         getCompilerContext().addPrivilegeFilter( ignorePermissions );
 		getResultColumnList();
-        getCompilerContext().removePrivilegeFilter( ignorePermissions );
 
 		/* If we have a target column list, then it must have the same # of
 		 * entries as the result set's RCL.
@@ -295,6 +294,8 @@ public final class InsertNode extends DM
 			getCompilerContext().popCurrentPrivType();
         }
 
+        getCompilerContext().removePrivilegeFilter( ignorePermissions );
+
 		/* Verify that all underlying ResultSets reclaimed their FromList */
 		if (SanityManager.DEBUG)
 		{

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java?rev=1558559&r1=1558558&r2=1558559&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GrantRevokeDDLTest.java Wed Jan 15 20:26:05 2014
@@ -12119,4 +12119,147 @@ public final class GrantRevokeDDLTest ex
              );
     }
     
+    /**
+     * Test that INSERT and UPDATEs run generation expressions with definer's rights.
+     */
+    public void test_6433()
+        throws Exception
+    {
+        Connection  dboConnection = openUserConnection( TEST_DBO );
+        Connection  ruthConnection = openUserConnection( RUTH );
+
+        //
+        // Schema
+        //
+        goodStatement
+            (
+             dboConnection,
+             "create function absoluteValue_6433( inputValue int ) returns int\n" +
+             "language java parameter style java deterministic no sql\n" +
+             "external name 'java.lang.Math.abs'\n"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create type hashmap_6433 external name 'java.util.HashMap' language java"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create function makeHashMap_6423() returns hashmap_6433\n" +
+             "language java parameter style java no sql\n" +
+             "external name 'org.apache.derbyTesting.functionTests.tests.lang.UDTTest.makeHashMap'\n"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create table t1_generated_function_6433\n" +
+             "(\n" +
+             "    a int,\n" +
+             "    b int generated always as ( absoluteValue_6433( a ) )\n" +
+             ")\n"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "create table t1_generated_type_6433\n" +
+             "(\n" +
+             "    a hashmap_6433,\n" +
+             "    b boolean generated always as ( a is null )\n" +
+             ")\n"
+             );
+        
+        //
+        // Data
+        //
+        goodStatement
+            (
+             dboConnection,
+             "insert into t1_generated_function_6433( a ) values -101"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "insert into t1_generated_type_6433( a ) values ( makeHashMap_6423() )"
+             );
+
+        //
+        // Privileges
+        //
+        goodStatement
+            (
+             dboConnection,
+             "grant insert on t1_generated_function_6433 to ruth"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "grant update on t1_generated_function_6433 to ruth"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "grant insert on t1_generated_type_6433 to ruth"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "grant update on t1_generated_type_6433 to ruth"
+             );
+        
+        //
+        // Verify that granted permissions are sufficient for ruth
+        // to INSERT and UPDATE the table.
+        //
+        goodStatement
+            (
+             ruthConnection,
+             "insert into test_dbo.t1_generated_function_6433( a ) values ( -102 )"
+             );
+        goodStatement
+            (
+             ruthConnection,
+             "update test_dbo.t1_generated_function_6433 set a = -103"
+             );
+        goodStatement
+            (
+             ruthConnection,
+             "insert into test_dbo.t1_generated_type_6433( a ) values ( null )"
+             );
+        goodStatement
+            (
+             ruthConnection,
+             "update test_dbo.t1_generated_type_6433 set a = null"
+             );
+        
+        //
+        // Drop schema
+        //
+        goodStatement
+            (
+             dboConnection,
+             "drop table t1_generated_type_6433"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "drop table t1_generated_function_6433"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "drop function makeHashMap_6423"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "drop type hashmap_6433 restrict"
+             );
+        goodStatement
+            (
+             dboConnection,
+             "drop function absoluteValue_6433"
+             );
+    }
+
 }