db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r676943 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java
Date Tue, 15 Jul 2008 15:50:35 GMT
Author: dag
Date: Tue Jul 15 08:50:35 2008
New Revision: 676943

URL: http://svn.apache.org/viewvc?rev=676943&view=rev
Log:
DERBY-3223 SQL roles: make use of privileges granted to roles in actual privilege checking

Follow-up patch derby-3223-activate-roles-2b: small improvements to RolesConferredPrivilegesTest.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java?rev=676943&r1=676942&r2=676943&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RolesConferredPrivilegesTest.java
Tue Jul 15 08:50:35 2008
@@ -54,8 +54,8 @@
     private final static String NOCOLUMNPERMISSION   = "42502";
     private final static String TABLENOTFOUND        = "42X05";
     private final static String OBJECTNOTFOUND       = "42X94";
-	private final static String FKVIOLATION          = "23503";
-	private final static String CHECKCONSTRAINTVIOLATED = "23513";
+    private final static String FKVIOLATION          = "23503";
+    private final static String CHECKCONSTRAINTVIOLATED = "23513";
     private final static String ALREADYCLOSED        = "XJ012";
     private final static String CONSTRAINTDROPPED    = "01500";
     private final static String VIEWDROPPED          = "01501";
@@ -410,19 +410,25 @@
                                         Connection c,
                                         String schema,
                                         String function) throws SQLException {
+        Statement stm = c.createStatement();
+
         try {
             ResultSet rs =
-                c.createStatement().
-                executeQuery("values " + schema + "." + function + "()");
+                stm.executeQuery("values " + schema + "." + function + "()");
 
             rs.next();
             rs.close();
+            stm.close();
 
             if (hasPrivilege == NOPRIV) {
                 fail("expected no EXECUTE privilege on function. " +
                      formatArgs(c, schema, function));
             }
         } catch (SQLException e) {
+            if (stm != null) {
+                stm.close();
+            }
+
             if (hasPrivilege == NOPRIV)
                 assertSQLState(NOEXECUTEPERMISSION, e);
             else {
@@ -674,8 +680,6 @@
                                        String schema,
                                        String table,
                                        String[] columns) throws SQLException {
-        Statement s = c.createStatement();
-
         assertSelectPrivilege
             (hasPrivilege, c, schema, table, columns, NOCOLUMNPERMISSION);
     }
@@ -783,10 +787,12 @@
                                          String table,
                                          String[] columns) throws SQLException {
         ResultSet rs;
-        rs = c.createStatement().executeQuery("values current_user");
+        Statement stm = c.createStatement();
+        rs = stm.executeQuery("values current_user");
         rs.next();
         String user = rs.getString(1);
         rs.close();
+        stm.close();
 
         if (isOwner(schema, user)) {
             //  NOTE: Does not work for table owner, who has no manifest entry
@@ -893,12 +899,14 @@
 
     private boolean isOwner(String schema, String user) throws SQLException {
         Connection c = getConnection();
-        ResultSet rs = c.createStatement().executeQuery
+        Statement stm = c.createStatement();
+        ResultSet rs = stm.executeQuery
             ("select schemaname, authorizationid from sys.sysschemas " +
              "where schemaname='" + JDBC.identifierToCNF(schema) + "'");
         rs.next();
         boolean result = rs.getString(2).equals(JDBC.identifierToCNF(user));
         rs.close();
+        stm.close();
         return result;
     }
 
@@ -969,8 +977,8 @@
                                      String dbObject)  throws SQLException {
 
         ResultSet rs;
-
-        rs = c.createStatement().executeQuery("values current_user");
+        Statement stm =  c.createStatement();
+        rs = stm.executeQuery("values current_user");
         rs.next();
         String user = rs.getString(1);
 
@@ -978,6 +986,7 @@
         rs.next();
         String role = rs.getString(1);
         rs.close();
+        stm.close();
 
         return
             "User: " + user +



Mime
View raw message