db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1400024 - in /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql: compile/CursorNode.java execute/BaseActivation.java execute/CursorActivation.java
Date Fri, 19 Oct 2012 10:19:12 GMT
Author: kahatlen
Date: Fri Oct 19 10:19:12 2012
New Revision: 1400024

URL: http://svn.apache.org/viewvc?rev=1400024&view=rev
Log:
DERBY-5947: Factor out common code from generated classes

Move authorization check for CursorNodes from generated code to
CursorActivation.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CursorActivation.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java?rev=1400024&r1=1400023&r2=1400024&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java Fri
Oct 19 10:19:12 2012
@@ -634,9 +634,6 @@ public class CursorNode extends DMLState
 		// result set of the statement.
 		resultSet.markStatementResultSet();
 
-		generateAuthorizeCheck(acb, mb,
-				org.apache.derby.iapi.sql.conn.Authorizer.SQL_SELECT_OP);
-
 		// this will generate an expression that will be a ResultSet
 	    resultSet.generate(acb, mb);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java?rev=1400024&r1=1400023&r2=1400024&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/BaseActivation.java
Fri Oct 19 10:19:12 2012
@@ -276,16 +276,22 @@ public abstract class BaseActivation imp
 
         // Create the result set tree on the first execution.
         if (resultSet == null) {
-             resultSet = createResultSet();
-             if (isCursorActivation()) {
-                 ((NoPutResultSet) resultSet).markAsTopResultSet();
-             }
+             resultSet = decorateResultSet();
         }
 
         return resultSet;
     }
 
     /**
+     * Create the ResultSet tree for this statement, and possibly perform
+     * extra checks or initialization required by specific sub-classes.
+     * @return the root of the ResultSet tree for this statement
+     */
+    ResultSet decorateResultSet() throws StandardException {
+        return createResultSet();
+    }
+
+    /**
      * Create the ResultSet tree for this statement.
      * @return the root of the ResultSet tree for this statement
      */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CursorActivation.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CursorActivation.java?rev=1400024&r1=1400023&r2=1400024&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CursorActivation.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CursorActivation.java
Fri Oct 19 10:19:12 2012
@@ -21,6 +21,11 @@
 
 package org.apache.derby.impl.sql.execute;
 
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.sql.ResultSet;
+import org.apache.derby.iapi.sql.conn.Authorizer;
+import org.apache.derby.iapi.sql.execute.NoPutResultSet;
+
 /**
  *
  * In the family of activation support classes,
@@ -46,4 +51,17 @@ public abstract class CursorActivation 
 	{
 		return true;
 	}
+
+    /** @see BaseActivation#decorateResultSet */
+    ResultSet decorateResultSet() throws StandardException {
+        // CursorActivation means it's a query that returns rows. Check that
+        // the caller is authorized to run SQL read operations.
+        getLanguageConnectionContext().getAuthorizer().authorize(
+                this, Authorizer.SQL_SELECT_OP);
+
+        // The top-level result set should be marked as such.
+        NoPutResultSet rs = (NoPutResultSet) createResultSet();
+        rs.markAsTopResultSet();
+        return rs;
+    }
 }



Mime
View raw message