db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r787754 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/catalog/ testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/
Date Tue, 23 Jun 2009 17:21:54 GMT
Author: rhillegas
Date: Tue Jun 23 17:21:53 2009
New Revision: 787754

URL: http://svn.apache.org/viewvc?rev=787754&view=rev
Log:
DERBY-4215: remove bad permissions tuple during 10.6 upgrade.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTrajectoryTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java?rev=787754&r1=787753&r2=787754&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java Tue
Jun 23 17:21:53 2009
@@ -451,11 +451,13 @@
             bootingDictionary.create_10_5_system_procedures(tc, newlyCreatedRoutines);
         }
 
-        // change the return type of SYSIBM.CLOBGETSUBSTRING if necessary. See
+        //
+        // Change the return type of SYSIBM.CLOBGETSUBSTRING if necessary. See
         // DERBY-4214. That function was added in 10.3 and the return type was
         // changed (but not upgraded) in 10.5. We can't distinguish
         // between databases which were originally created by 10.5 and databases
         // which were upgraded to 10.5.
+        //
         if (
             ( fromMajorVersionNumber > DataDictionary.DD_VERSION_DERBY_10_2) &&
             ( fromMajorVersionNumber < DataDictionary.DD_VERSION_DERBY_10_6)
@@ -463,6 +465,20 @@
         {
             bootingDictionary.upgradeCLOBGETSUBSTRING_10_6( tc );
         }
+
+        //
+        // Remove the bad permissions tuple for SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE if
necessary.
+        // See DERBY-4215. That procedure will have an extra permissions tuple
+        // with a null GRANTOR field if the database was created by 10.0 and then
+        // hard-upgraded to 10.2 or higher without an intermediate upgrade to 10.1.
+        //
+        if (
+            ( fromMajorVersionNumber > DataDictionary.DD_VERSION_DERBY_10_1) &&
+            ( fromMajorVersionNumber < DataDictionary.DD_VERSION_DERBY_10_6)
+            )
+        {
+            bootingDictionary.upgradeSYSROUTINEPERMS_10_6( tc );
+        }
         
         // Grant PUBLIC access to some system routines
         bootingDictionary.grantPublicAccessToSystemRoutines(newlyCreatedRoutines, tc, aid);

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=787754&r1=787753&r2=787754&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
Tue Jun 23 17:21:53 2009
@@ -2481,6 +2481,54 @@
              );
     }
 
+    /**
+     * 10.6 upgrade logic to update the permissions granted to SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE.
+     * If a 10.0 database was upgraded to 10.2, 10.3, or 10.4, then there will
+     * be an extra permissions tuple in SYSROUTINEPERMS--that tuple will have a
+     * null grantor field. We must delete this tuple. See DERBY-4215.
+     */
+    void upgradeSYSROUTINEPERMS_10_6( TransactionController tc )
+        throws StandardException
+    {
+        //
+        // Get the aliasID of SYSCS_INPLACE_COMPRESS_TABLE
+        //
+		TabInfoImpl          aliasTI = getNonCoreTI(SYSALIASES_CATALOG_NUM);
+		ExecIndexRow         aliasKeyRow = exFactory.getIndexableRow(3);
+		DataValueDescriptor  aliasNameOrderable = new SQLVarchar( "SYSCS_INPLACE_COMPRESS_TABLE"
);;
+		DataValueDescriptor	 nameSpaceOrderable = new SQLChar
+            ( new String( new char[] { AliasInfo.ALIAS_TYPE_PROCEDURE_AS_CHAR } ) );
+        
+		aliasKeyRow.setColumn(1, new SQLChar( SchemaDescriptor.SYSCS_UTIL_SCHEMA_UUID ));
+		aliasKeyRow.setColumn(2, aliasNameOrderable);
+		aliasKeyRow.setColumn(3, nameSpaceOrderable);
+
+        AliasDescriptor      oldAD = (AliasDescriptor) getDescriptorViaIndex
+            (
+             SYSALIASESRowFactory.SYSALIASES_INDEX1_ID,
+             aliasKeyRow,
+             (ScanQualifier [][]) null,
+             aliasTI,
+             (TupleDescriptor) null,
+             (List) null,
+             true,
+             TransactionController.ISOLATION_REPEATABLE_READ,
+             tc);
+        UUID                 aliasID = oldAD.getUUID();
+
+        //
+        // Now delete the permissions tuple which has a null grantor
+        //
+		TabInfoImpl          rpTI = getNonCoreTI(SYSROUTINEPERMS_CATALOG_NUM);
+		ExecIndexRow         rpKeyRow = exFactory.getIndexableRow(3);
+
+		rpKeyRow.setColumn(1, new SQLVarchar( "PUBLIC" ));
+		rpKeyRow.setColumn(2, new SQLChar( aliasID.toString() ));
+		rpKeyRow.setColumn(3, new SQLVarchar( (String) null ) );
+
+		int deleteCount = rpTI.deleteRow(tc, rpKeyRow, SYSROUTINEPERMSRowFactory.GRANTEE_ALIAS_GRANTOR_INDEX_NUM);
+    }
+    
 	/**
 	 * Drop all table descriptors for a schema.
 	 *

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java?rev=787754&r1=787753&r2=787754&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_6.java
Tue Jun 23 17:21:53 2009
@@ -56,7 +56,15 @@
 public class Changes10_6 extends UpgradeChange {
 
     private static  final   String  BAD_SYNTAX = "42X01";
+    private static  final   String  TABLE_DOES_NOT_EXIST = "42X05";
 
+    private static  final   String  QUERY_4215 =
+        "select r.grantor\n" +
+        "from sys.sysroutineperms r, sys.sysaliases a\n" +
+        "where r.aliasid = a.aliasid\n" +
+        "and a.alias = 'SYSCS_INPLACE_COMPRESS_TABLE'\n"
+        ;
+    
     public Changes10_6(String name) {
         super(name);
     }
@@ -179,6 +187,67 @@
     }
 
     /**
+     * Make sure that SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE  has the correct
+     * permissons granted to it.
+     * See https://issues.apache.org/jira/browse/DERBY-4215
+     */
+    public void testSYSCS_INPLACE_COMPRESS_TABLE() throws Exception
+    {
+        Version initialVersion = new Version( getOldMajor(), getOldMinor(), 0, 0 );
+        Version firstVersionHavingPermissions = new Version( 10, 2, 0, 0 );
+        boolean beforePermissionsWereAdded = ( initialVersion.compareTo( firstVersionHavingPermissions
) < 0 );
+        
+    	Statement s = createStatement();
+        
+        switch (getPhase())
+        {
+        case PH_CREATE:
+        case PH_SOFT_UPGRADE:
+        case PH_POST_SOFT_UPGRADE:
+            
+            if ( beforePermissionsWereAdded )
+            {
+                assertStatementError( TABLE_DOES_NOT_EXIST, s, QUERY_4215 );
+            }
+            else
+            {
+                vetDERBY_4215( s );
+            }
+
+            break;
+
+        case PH_HARD_UPGRADE:
+
+            vetDERBY_4215( s );
+            
+            break;
+        }
+
+        s.close();
+    }
+
+    /**
+     * Vet the permissions on SYSCS_UTIL.SYSCS_INPLACE_COMPRESS_TABLE.
+     * There should be only one permissions tuple for this system procedure and
+     * the grantor should be APP.
+     */
+    private void vetDERBY_4215( Statement s ) throws Exception
+    {
+        String    expectedGrantor = "APP";
+        ResultSet rs = s.executeQuery( QUERY_4215 );
+
+        assertTrue( rs.next() );
+
+        String actualGrantor = rs.getString( 1 );
+        assertEquals( expectedGrantor, actualGrantor );
+
+        assertFalse( rs.next() );
+
+        rs.close();
+    }
+
+    
+    /**
      * We would like to just cast the alias descriptor to
      * RoutineAliasDescriptor. However, this doesn't work if we are running on
      * an old version because the descriptor comes from a different class

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTrajectoryTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTrajectoryTest.java?rev=787754&r1=787753&r2=787754&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTrajectoryTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeTrajectoryTest.java
Tue Jun 23 17:21:53 2009
@@ -148,12 +148,16 @@
     public static Version VERSION_10_0_2_1 = new Version( 10, 0, 2, 1 );
     public static Version VERSION_10_1_3_1 = new Version( 10, 1, 3, 1 );
     public static Version VERSION_10_5_1_1 = new Version( 10, 5, 1, 1 );
+    public static Version VERSION_10_6_0_0 = new Version( 10, 6, 0, 0 );
 
     public static Version.Trajectory TRAJECTORY_10_0_2_1_TO_10_1_3_1 = new Version.Trajectory(
new Version[] { VERSION_10_0_2_1, VERSION_10_1_3_1 } );
-    public static Version.Trajectory TRAJECTORY_10_0_2_1_TO_10_5_1_1 = new Version.Trajectory(
new Version[] { VERSION_10_0_2_1, VERSION_10_5_1_1 } );
 
     public static String BRANCH_10_0 = "10.0";
     public static String BRANCH_10_1 = "10.1";
+    public static String BRANCH_10_2 = "10.2";
+    public static String BRANCH_10_3 = "10.3";
+    public static String BRANCH_10_4 = "10.4";
+    public static String BRANCH_10_5 = "10.5";
 
     public static final String UPGRADED_DATABASE = "old_database";
     public static final String VIRGIN_DATABASE = "new_database";
@@ -321,6 +325,8 @@
         {
             new Version.Trajectory( new Version[] { new Version( 10, 0, 2, 1), new Version(
10, 1, 3, 1 ) } ),
             new Version.Trajectory( new Version[] { new Version( 10, 0, 2, 1), new Version(
10, 3, 3, 0 ) } ),
+            new Version.Trajectory( new Version[] { new Version( 10, 0, 2, 1), new Version(
10, 3, 3, 0 ), new Version( 10, 5, 1, 1 ) } ),
+            new Version.Trajectory( new Version[] { new Version( 10, 0, 2, 1), new Version(
10, 3, 3, 0 ), new Version( 10, 6, 0, 0 ) } ),
             new Version.Trajectory( new Version[] { new Version( 10, 0, 2, 1), new Version(
10, 5, 1, 1 ) } ),
             new Version.Trajectory( new Version[] { new Version( 10, 4, 2, 1), new Version(
10, 5, 1, 1 ) } ),
         };
@@ -1344,7 +1350,12 @@
                      SYSROUTINEPERMS.equals( tableName ) &&
                      _trajectory.startsAt( BRANCH_10_0 ) &&
                      ( !_trajectory.contains( BRANCH_10_1 ) ) &&
-                     ( !_trajectory.equals( TRAJECTORY_10_0_2_1_TO_10_5_1_1 ) )
+                     (
+                      _trajectory.contains( BRANCH_10_2 ) ||
+                      _trajectory.contains( BRANCH_10_3 ) ||
+                      _trajectory.contains( BRANCH_10_4 )
+                      ) &&
+                     ( _trajectory.getEndingVersion().compareTo( VERSION_10_6_0_0 )  <
0 )
                  );
     }
     

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java?rev=787754&r1=787753&r2=787754&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Version.java
Tue Jun 23 17:21:53 2009
@@ -284,6 +284,16 @@
 
         /**
          * <p>
+         * Return the ending Version of this Trajectory.
+         * </p>
+         */
+        public Version getEndingVersion()
+        {
+            return getVersion( getVersionCount() -1 );
+        }
+        
+        /**
+         * <p>
          * Return true if this Trajectory starts at the desired Version.
          * </p>
          */



Mime
View raw message