db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1351795 - in /db/derby/code/trunk/java: engine/org/apache/derby/diag/ engine/org/apache/derby/iapi/sql/dictionary/ engine/org/apache/derby/impl/sql/catalog/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Tue, 19 Jun 2012 18:29:01 GMT
Author: rhillegas
Date: Tue Jun 19 18:29:00 2012
New Revision: 1351795

URL: http://svn.apache.org/viewvc?rev=1351795&view=rev
Log:
DERBY-5554: Add 0-arg constructor to SPACE_TABLE vti.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.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/lang/SysDiagVTIMappingTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java?rev=1351795&r1=1351794&r2=1351795&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.java Tue Jun 19 18:29:00
2012
@@ -116,6 +116,7 @@ public class SpaceTable extends VTITempl
     private SpaceInfo spaceInfo;
     private TransactionController tc;
 
+    public  SpaceTable() {}
 
     public SpaceTable(String schemaName, String tableName)
     {
@@ -134,26 +135,46 @@ public class SpaceTable extends VTITempl
         DataDictionary dd = lcc.getDataDictionary();
 		
 		if (schemaName == null)
-			schemaName = lcc.getCurrentSchemaName();
+		{ schemaName = lcc.getCurrentSchemaName(); }
 
-        // if schemaName is null, it gets the default schema
-        SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, tc, true);
-        TableDescriptor td = dd.getTableDescriptor(tableName,sd, tc);
-        if (td == null)  // table does not exist
+        ConglomerateDescriptor[] cds;
+
+        if ( tableName != null )
+        {
+            // if schemaName is null, it gets the default schema
+            SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, tc, true);
+            TableDescriptor td = dd.getTableDescriptor(tableName,sd, tc);
+            if (td == null)  // table does not exist
+            {
+                conglomTable = new ConglomInfo[0];   // make empty conglom table
+                return;
+            }
+            cds = td.getConglomerateDescriptors();
+        }
+        else // 0-arg constructor, no table name, get all conglomerates
         {
-            conglomTable = new ConglomInfo[0];   // make empty conglom table
-            return;
+            cds = dd.getConglomerateDescriptors( null );
         }
-        ConglomerateDescriptor[] cds = td.getConglomerateDescriptors();
+        
         // initialize spaceTable
         conglomTable = new ConglomInfo[cds.length];
         for (int i = 0; i < cds.length; i++)
         {
+            String  conglomerateName;
+
+            if ( cds[i].isIndex() ) { conglomerateName = cds[i].getConglomerateName(); }
+            else if ( tableName != null ) { conglomerateName = tableName; }
+            else
+            {
+                // 0-arg constructor. need to ask data dictionary for name of table
+                conglomerateName = dd.getTableDescriptor( cds[i].getTableID() ).getName();
+            }
+            
             conglomTable[i] = new ConglomInfo
                 (
                  cds[i].getTableID().toString(),
                  cds[i].getConglomerateNumber(),
-                 cds[i].isIndex() ? cds[i].getConglomerateName() : tableName,
+                 conglomerateName,
                  cds[i].isIndex()
                  );
         }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java?rev=1351795&r1=1351794&r2=1351795&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
Tue Jun 19 18:29:00 2012
@@ -1430,7 +1430,8 @@ public interface DataDictionary
 	/**
 	 * Get an array of ConglomerateDescriptors given the UUID.  If it is a
 	 * heap conglomerate or an index conglomerate not shared by a duplicate
-	 * index, the size of the return array is 1.
+	 * index, the size of the return array is 1. If the uuid argument is null, then
+     * this method retrieves descriptors for all of the conglomerates in the database.
 	 *
 	 * @param uuid	The UUID
 	 *

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=1351795&r1=1351794&r2=1351795&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 19 18:29:00 2012
@@ -7033,7 +7033,8 @@ public final class	DataDictionaryImpl
 	/**
 	 * Get an array of ConglomerateDescriptors given the UUID.  If it is a
 	 * heap conglomerate or an index conglomerate not shared by a duplicate
-	 * index, the size of the return array is 1.
+	 * index, the size of the return array is 1. If the uuid argument is null, then
+     * this method retrieves descriptors for all of the conglomerates in the database.
 	 *
 	 * @param uuid	The UUID
 	 *
@@ -7049,23 +7050,37 @@ public final class	DataDictionaryImpl
 		DataValueDescriptor		UUIDStringOrderable;
 		TabInfoImpl					ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
 
-		/* Use UUIDStringOrderable in both start and stop positions for scan */
-		UUIDStringOrderable = getIDValueAsCHAR(uuid);
-
-		/* Set up the start/stop position for the scan */
-		ExecIndexRow keyRow = exFactory.getIndexableRow(1);
-		keyRow.setColumn(1, UUIDStringOrderable);
-
 		List cdl = newSList();
 
-		getDescriptorViaIndex(
-						SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX1_ID,
-						keyRow,
-						(ScanQualifier [][]) null,
-						ti,
-						(TupleDescriptor) null,
-						cdl,
-						false);
+        if ( uuid != null )
+        {
+            /* Use UUIDStringOrderable in both start and stop positions for scan */
+            UUIDStringOrderable = getIDValueAsCHAR(uuid);
+
+            /* Set up the start/stop position for the scan */
+            ExecIndexRow keyRow = exFactory.getIndexableRow(1);
+            keyRow.setColumn(1, UUIDStringOrderable);
+
+            getDescriptorViaIndex(
+                                  SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX1_ID,
+                                  keyRow,
+                                  (ScanQualifier [][]) null,
+                                  ti,
+                                  (TupleDescriptor) null,
+                                  cdl,
+                                  false);
+        }
+        else
+        {
+            getDescriptorViaHeap
+                (
+                 null,
+                 (ScanQualifier[][]) null,
+                 ti,
+                 (TupleDescriptor) null,
+                 cdl
+                 );
+        }
 
 		ConglomerateDescriptor[] cda = new ConglomerateDescriptor[cdl.size()];
 		cdl.toArray(cda);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SysDiagVTIMappingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SysDiagVTIMappingTest.java?rev=1351795&r1=1351794&r2=1351795&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SysDiagVTIMappingTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SysDiagVTIMappingTest.java
Tue Jun 19 18:29:00 2012
@@ -44,6 +44,12 @@ public final class SysDiagVTIMappingTest
     // Name of the log file to use when testing VTIs that expect one.
     private static final String testLogFile = "sys_vti_test_derby.tstlog";
 
+    private static  final   String[]    ALL_SPACE_TABLE_COLUMNS =
+    {
+        "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
+        "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING", "TABLEID"
+    };
+
     /**
      * Public constructor required for running test as standalone JUnit.
      */
@@ -164,10 +170,7 @@ public final class SysDiagVTIMappingTest
         ResultSet rs = st.executeQuery(
             "select * from TABLE(SYSCS_DIAG.SPACE_TABLE('APP', 'T1')) x");
         
-        String [] allColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING", "TABLEID" };
-        String [] expColNames = allColNames;
+        String [] expColNames = ALL_SPACE_TABLE_COLUMNS;
         JDBC.assertColumnNames(rs, expColNames);
         
         String [][] expRS = new String [][]
@@ -326,7 +329,7 @@ public final class SysDiagVTIMappingTest
         rs = st.executeQuery(
             "SELECT * FROM NEW org.apache.derby.diag.SpaceTable('T1') as x");
         
-        JDBC.assertColumnNames(rs, allColNames);
+        JDBC.assertColumnNames(rs, ALL_SPACE_TABLE_COLUMNS);
         
         expRS = new String [][]
         {
@@ -339,7 +342,7 @@ public final class SysDiagVTIMappingTest
             "SELECT * FROM NEW "
             + "org.apache.derby.diag.SpaceTable('APP', 'T1') as x");
         
-        JDBC.assertColumnNames(rs, allColNames);
+        JDBC.assertColumnNames(rs, ALL_SPACE_TABLE_COLUMNS);
         
         expRS = new String [][]
         {
@@ -347,6 +350,22 @@ public final class SysDiagVTIMappingTest
         };
         
         JDBC.assertFullResultSet(rs, expRS, true);
+
+        // verify the syntax showcased in the Reference Guide section on SPACE_TABLE
+        // (after the changes introduced by DERBY-5554)
+
+        rs = st.executeQuery
+            (
+             "select t2.*\n" +
+             "    from\n" +
+             "        sys.systables systabs,\n" +
+             "        table (syscs_diag.space_table()) as t2\n" +
+             "    where systabs.tabletype = 'T'\n" +
+             "    and systabs.tableid = t2.tableid\n"
+             );
+        
+        JDBC.assertColumnNames(rs, ALL_SPACE_TABLE_COLUMNS);
+        JDBC.assertFullResultSet(rs, expRS, true);
         
         // Now do some sanity checking to make sure SPACE_TABLE cannot be
         // used in any illegal ways.        
@@ -360,6 +379,104 @@ public final class SysDiagVTIMappingTest
     }
 
     /**
+     * Test the 0-arg constructor of the SPACE_TABLE vti. See DERBY-5554.
+     */
+    public void testSpaceTable_0argConstructor() throws Exception
+    {
+        Statement st = createStatement();
+        ResultSet   rs = st.executeQuery
+            (
+             "select conglomeratename, isindex, pagesize, tableid\n" +
+             "from table(syscs_diag.space_table()) x\n" +
+             "where conglomeratename like 'SYS%'\n" +
+             "order by conglomeratename"
+             );
+
+        String[]  columnNames =
+        {
+            "CONGLOMERATENAME", "ISINDEX", "PAGESIZE", "TABLEID"
+        };
+        JDBC.assertColumnNames( rs, columnNames );
+        
+        String[][]  expRS = new String [][]
+        {
+            { "SYSALIASES", "0", "4096", "c013800d-00d7-ddbd-08ce-000a0a411400" },
+            { "SYSALIASES_INDEX1", "1", "4096", "c013800d-00d7-ddbd-08ce-000a0a411400" },
+            { "SYSALIASES_INDEX2", "1", "4096", "c013800d-00d7-ddbd-08ce-000a0a411400" },
+            { "SYSALIASES_INDEX3", "1", "4096", "c013800d-00d7-ddbd-08ce-000a0a411400" },
+            { "SYSCHECKS", "0", "4096", "80000056-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSCHECKS_INDEX1", "1", "4096", "80000056-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSCOLPERMS", "0", "4096", "286cc01e-0103-0e39-b8e7-00000010f010" },
+            { "SYSCOLPERMS_INDEX1", "1", "4096", "286cc01e-0103-0e39-b8e7-00000010f010" },
+            { "SYSCOLPERMS_INDEX2", "1", "4096", "286cc01e-0103-0e39-b8e7-00000010f010" },
+            { "SYSCOLPERMS_INDEX3", "1", "4096", "286cc01e-0103-0e39-b8e7-00000010f010" },
+            { "SYSCOLUMNS", "0", "4096", "8000001e-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSCOLUMNS_INDEX1", "1", "4096", "8000001e-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSCOLUMNS_INDEX2", "1", "4096", "8000001e-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSCONGLOMERATES", "0", "4096", "80000010-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSCONGLOMERATES_INDEX1", "1", "4096", "80000010-00d0-fd77-3ed8-000a0a0b1900"
},
+            { "SYSCONGLOMERATES_INDEX2", "1", "4096", "80000010-00d0-fd77-3ed8-000a0a0b1900"
},
+            { "SYSCONGLOMERATES_INDEX3", "1", "4096", "80000010-00d0-fd77-3ed8-000a0a0b1900"
},
+            { "SYSCONSTRAINTS", "0", "4096", "8000002f-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSCONSTRAINTS_INDEX1", "1", "4096", "8000002f-00d0-fd77-3ed8-000a0a0b1900"
},
+            { "SYSCONSTRAINTS_INDEX2", "1", "4096", "8000002f-00d0-fd77-3ed8-000a0a0b1900"
},
+            { "SYSCONSTRAINTS_INDEX3", "1", "4096", "8000002f-00d0-fd77-3ed8-000a0a0b1900"
},
+            { "SYSDEPENDS", "0", "4096", "8000003e-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSDEPENDS_INDEX1", "1", "4096", "8000003e-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSDEPENDS_INDEX2", "1", "4096", "8000003e-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSDUMMY1", "0", "4096", "c013800d-00f8-5b70-bea3-00000019ed88" },
+            { "SYSFILES", "0", "4096", "80000000-00d3-e222-873f-000a0a0b1900" },
+            { "SYSFILES_INDEX1", "1", "4096", "80000000-00d3-e222-873f-000a0a0b1900" },
+            { "SYSFILES_INDEX2", "1", "4096", "80000000-00d3-e222-873f-000a0a0b1900" },
+            { "SYSFOREIGNKEYS", "0", "4096", "8000005b-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSFOREIGNKEYS_INDEX1", "1", "4096", "8000005b-00d0-fd77-3ed8-000a0a0b1900"
},
+            { "SYSFOREIGNKEYS_INDEX2", "1", "4096", "8000005b-00d0-fd77-3ed8-000a0a0b1900"
},
+            { "SYSKEYS", "0", "4096", "80000039-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSKEYS_INDEX1", "1", "4096", "80000039-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSPERMS", "0", "4096", "9810800c-0121-c5e1-a2f5-00000043e718" },
+            { "SYSPERMS_INDEX1", "1", "4096", "9810800c-0121-c5e1-a2f5-00000043e718" },
+            { "SYSPERMS_INDEX2", "1", "4096", "9810800c-0121-c5e1-a2f5-00000043e718" },
+            { "SYSPERMS_INDEX3", "1", "4096", "9810800c-0121-c5e1-a2f5-00000043e718" },
+            { "SYSROLES", "0", "4096", "e03f4017-0115-382c-08df-ffffe275b270" },
+            { "SYSROLES_INDEX1", "1", "4096", "e03f4017-0115-382c-08df-ffffe275b270" },
+            { "SYSROLES_INDEX2", "1", "4096", "e03f4017-0115-382c-08df-ffffe275b270" },
+            { "SYSROLES_INDEX3", "1", "4096", "e03f4017-0115-382c-08df-ffffe275b270" },
+            { "SYSROUTINEPERMS", "0", "4096", "2057c01b-0103-0e39-b8e7-00000010f010" },
+            { "SYSROUTINEPERMS_INDEX1", "1", "4096", "2057c01b-0103-0e39-b8e7-00000010f010"
},
+            { "SYSROUTINEPERMS_INDEX2", "1", "4096", "2057c01b-0103-0e39-b8e7-00000010f010"
},
+            { "SYSROUTINEPERMS_INDEX3", "1", "4096", "2057c01b-0103-0e39-b8e7-00000010f010"
},
+            { "SYSSCHEMAS", "0", "4096", "80000022-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSSCHEMAS_INDEX1", "1", "4096", "80000022-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSSCHEMAS_INDEX2", "1", "4096", "80000022-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSSEQUENCES", "0", "4096", "9810800c-0121-c5e2-e794-00000043e718" },
+            { "SYSSEQUENCES_INDEX1", "1", "4096", "9810800c-0121-c5e2-e794-00000043e718"
},
+            { "SYSSEQUENCES_INDEX2", "1", "4096", "9810800c-0121-c5e2-e794-00000043e718"
},
+            { "SYSSTATEMENTS", "0", "4096", "80000000-00d1-15f7-ab70-000a0a0b1500" },
+            { "SYSSTATEMENTS_INDEX1", "1", "4096", "80000000-00d1-15f7-ab70-000a0a0b1500"
},
+            { "SYSSTATEMENTS_INDEX2", "1", "4096", "80000000-00d1-15f7-ab70-000a0a0b1500"
},
+            { "SYSSTATISTICS", "0", "4096", "f81e0010-00e3-6612-5a96-009e3a3b5e00" },
+            { "SYSSTATISTICS_INDEX1", "1", "4096", "f81e0010-00e3-6612-5a96-009e3a3b5e00"
},
+            { "SYSTABLEPERMS", "0", "4096", "b8450018-0103-0e39-b8e7-00000010f010" },
+            { "SYSTABLEPERMS_INDEX1", "1", "4096", "b8450018-0103-0e39-b8e7-00000010f010"
},
+            { "SYSTABLEPERMS_INDEX2", "1", "4096", "b8450018-0103-0e39-b8e7-00000010f010"
},
+            { "SYSTABLEPERMS_INDEX3", "1", "4096", "b8450018-0103-0e39-b8e7-00000010f010"
},
+            { "SYSTABLES", "0", "4096", "80000018-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSTABLES_INDEX1", "1", "4096", "80000018-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSTABLES_INDEX2", "1", "4096", "80000018-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSTRIGGERS", "0", "4096", "c013800d-00d7-c025-4809-000a0a411200" },
+            { "SYSTRIGGERS_INDEX1", "1", "4096", "c013800d-00d7-c025-4809-000a0a411200" },
+            { "SYSTRIGGERS_INDEX2", "1", "4096", "c013800d-00d7-c025-4809-000a0a411200" },
+            { "SYSTRIGGERS_INDEX3",  "1", "4096", "c013800d-00d7-c025-4809-000a0a411200"
},
+            { "SYSUSERS", "0", "4096", "9810800c-0134-14a5-40c1-000004f61f90" },
+            { "SYSUSERS_INDEX1", "1", "4096", "9810800c-0134-14a5-40c1-000004f61f90" },
+            { "SYSVIEWS", "0", "4096", "8000004d-00d0-fd77-3ed8-000a0a0b1900" },
+            { "SYSVIEWS_INDEX1", "1", "4096", "8000004d-00d0-fd77-3ed8-000a0a0b1900" },
+        };
+        
+        JDBC.assertFullResultSet(rs, expRS, true);
+    }
+    
+    /**
      * Just run a couple of sanity checks to makes sure the table
      * mapping for org.apache.derby.diag.StatementDuration() works
      * correctly and fails where it is supposed to.



Mime
View raw message