db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1351714 - in /db/derby/code/trunk/java: engine/org/apache/derby/diag/SpaceTable.java testing/org/apache/derbyTesting/functionTests/tests/lang/SysDiagVTIMappingTest.java
Date Tue, 19 Jun 2012 13:49:55 GMT
Author: rhillegas
Date: Tue Jun 19 13:49:54 2012
New Revision: 1351714

URL: http://svn.apache.org/viewvc?rev=1351714&view=rev
Log:
DERBY-5554: Add a trailing tableid column to the SPACE_TABLE vti.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/diag/SpaceTable.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=1351714&r1=1351713&r2=1351714&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 13:49:54
2012
@@ -91,6 +91,7 @@ import org.apache.derby.vti.VTIEnvironme
 	</LI>
 	<LI>ESTIMSPACESAVING bigint - not nullable.  The estimated space which 
     could possibly be saved by compressing the conglomerate, in bytes.</LI>
+	<LI>TABLEID char(36) - not nullable.  The UUID of the table.</LI>
 	</UL>
 
 
@@ -147,10 +148,15 @@ public class SpaceTable extends VTITempl
         // initialize spaceTable
         conglomTable = new ConglomInfo[cds.length];
         for (int i = 0; i < cds.length; i++)
-            conglomTable[i] = new ConglomInfo(
-                cds[i].getConglomerateNumber(),
-                cds[i].isIndex() ? cds[i].getConglomerateName() : tableName,
-                cds[i].isIndex());
+        {
+            conglomTable[i] = new ConglomInfo
+                (
+                 cds[i].getTableID().toString(),
+                 cds[i].getConglomerateNumber(),
+                 cds[i].isIndex() ? cds[i].getConglomerateName() : tableName,
+                 cds[i].isIndex()
+                 );
+        }
     }
 
 
@@ -227,7 +233,19 @@ public class SpaceTable extends VTITempl
 	public String getString(int columnNumber)
 	{
 		ConglomInfo conglomInfo = conglomTable[currentRow];
-		String str = conglomInfo.getConglomName();
+        String          str = null;
+        
+		switch( columnNumber )
+		{
+		    case 1:
+			    str = conglomInfo.getConglomName();
+                break;
+    		case 8:
+			    str = conglomInfo.getTableID();
+                break;
+		    default:
+			    break;
+		}
    		wasNull = (str == null);
 		return str;
 	}
@@ -335,6 +353,7 @@ public class SpaceTable extends VTITempl
 		EmbedResultSetMetaData.getResultColumnDescriptor("NUMUNFILLEDPAGES",  Types.BIGINT, false),
 		EmbedResultSetMetaData.getResultColumnDescriptor("PAGESIZE",          Types.INTEGER, false),
 		EmbedResultSetMetaData.getResultColumnDescriptor("ESTIMSPACESAVING",  Types.BIGINT, false),
+		EmbedResultSetMetaData.getResultColumnDescriptor("TABLEID",  Types.CHAR, false, 36),
 	};
 	
 	private static final ResultSetMetaData metadata = new EmbedResultSetMetaData(columnInfo);
@@ -343,17 +362,21 @@ public class SpaceTable extends VTITempl
 
 class ConglomInfo
 {
+    private String  tableID;
     private long conglomId;
     private String conglomName;
     private boolean isIndex;
 
-    public ConglomInfo(long conglomId, String conglomName, boolean isIndex)
+    public ConglomInfo(String tableID, long conglomId, String conglomName, boolean isIndex)
     {
+        this.tableID = tableID;
         this.conglomId = conglomId;
         this.conglomName = conglomName;
         this.isIndex = isIndex;
     }
 
+    public String getTableID()  { return tableID; }
+
     public long getConglomId()
     {
         return conglomId;

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=1351714&r1=1351713&r2=1351714&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 13:49:54 2012
@@ -146,20 +146,33 @@ public final class SysDiagVTIMappingTest
         
         st.executeUpdate("set schema APP");
 
+        // get table id
+        ResultSet   rs1 = st.executeQuery
+            (
+             "select t.tableid from sys.systables t, sys.sysschemas s\n" +
+             "where t.schemaid = s.schemaid\n" +
+             "and s.schemaname = 'APP'\n" +
+             "and t.tablename = 'T1'"
+             );
+        rs1.next();
+        String      tableID = rs1.getString( 1 );
+        rs1.close();
+
         // These should all return 1 row for APP.T1.
         
         // Two-argument direct call.
         ResultSet rs = st.executeQuery(
             "select * from TABLE(SYSCS_DIAG.SPACE_TABLE('APP', 'T1')) x");
         
-        String [] expColNames = new String [] {
+        String [] allColNames = new String [] {
             "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
+            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING", "TABLEID" };
+        String [] expColNames = allColNames;
         JDBC.assertColumnNames(rs, expColNames);
         
         String [][] expRS = new String [][]
         {
-            {"T1", "0", "1", "0", "1", "4096", "0"}
+            {"T1", "0", "1", "0", "1", "4096", "0", tableID}
         };
         
         JDBC.assertFullResultSet(rs, expRS, true);
@@ -168,14 +181,11 @@ public final class SysDiagVTIMappingTest
         rs = st.executeQuery(
             " select * from TABLE(SYSCS_DIAG.SPACE_TABLE('T1')) x");
         
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         
         expRS = new String [][]
         {
-            {"T1", "0", "1", "0", "1", "4096", "0"}
+            {"T1", "0", "1", "0", "1", "4096", "0", tableID}
         };
         
         JDBC.assertFullResultSet(rs, expRS, true);
@@ -188,14 +198,11 @@ public final class SysDiagVTIMappingTest
         pSt.setString(2, "T1");
 
         rs = pSt.executeQuery();
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-             "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         
         expRS = new String [][]
         {
-            {"T1", "0", "1", "0", "1", "4096", "0"}
+            {"T1", "0", "1", "0", "1", "4096", "0", tableID}
         };
         
         JDBC.assertFullResultSet(rs, expRS, true);
@@ -207,14 +214,11 @@ public final class SysDiagVTIMappingTest
         pSt.setString(1, "T1");
 
         rs = pSt.executeQuery();
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         
         expRS = new String [][]
         {
-            {"T1", "0", "1", "0", "1", "4096", "0"}
+            {"T1", "0", "1", "0", "1", "4096", "0", tableID}
         };
         
         JDBC.assertFullResultSet(rs, expRS, true);
@@ -225,9 +229,6 @@ public final class SysDiagVTIMappingTest
         rs = st.executeQuery(
             "select * from TABLE(SYSCS_DIAG.SPACE_TABLE('APP')) x");
         
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         JDBC.assertDrainResults(rs, 0);
         
@@ -235,9 +236,6 @@ public final class SysDiagVTIMappingTest
             "select * from TABLE(SYSCS_DIAG.SPACE_TABLE('APP', "
             + "'NOTTHERE')) x");
         
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         JDBC.assertDrainResults(rs, 0);
         
@@ -245,9 +243,6 @@ public final class SysDiagVTIMappingTest
             "select * from "
             + "TABLE(SYSCS_DIAG.SPACE_TABLE('SYSCS_DIAG', 'NOTTHERE')) x");
         
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         JDBC.assertDrainResults(rs, 0);
         
@@ -258,9 +253,6 @@ public final class SysDiagVTIMappingTest
             "select * from "
             + "TABLE(SYSCS_DIAG.SPACE_TABLE('SYSCS_DIAG', 'LOCK_TABLE')) x");
         
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         JDBC.assertDrainResults(rs, 0);
         
@@ -278,14 +270,11 @@ public final class SysDiagVTIMappingTest
         pSt.setString(2, "T1");
 
         rs = pSt.executeQuery();
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         
         expRS = new String [][]
         {
-            {"T1", "0", "1", "0", "1", "4096", "0"}
+            {"T1", "0", "1", "0", "1", "4096", "0", tableID}
         };
         
         JDBC.assertFullResultSet(rs, expRS, true);
@@ -297,9 +286,6 @@ public final class SysDiagVTIMappingTest
         pSt.setString(1, "T1");
 
         rs = pSt.executeQuery();
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         JDBC.assertDrainResults(rs, 0);
         
@@ -309,9 +295,6 @@ public final class SysDiagVTIMappingTest
         rs = st.executeQuery(
             "select * from TABLE(SPACE_TABLE('LOCK_TABLE')) x");
         
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
         JDBC.assertColumnNames(rs, expColNames);
         JDBC.assertDrainResults(rs, 0);
         
@@ -343,14 +326,11 @@ public final class SysDiagVTIMappingTest
         rs = st.executeQuery(
             "SELECT * FROM NEW org.apache.derby.diag.SpaceTable('T1') as x");
         
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
-        JDBC.assertColumnNames(rs, expColNames);
+        JDBC.assertColumnNames(rs, allColNames);
         
         expRS = new String [][]
         {
-            {"T1", "0", "1", "0", "1", "4096", "0"}
+            {"T1", "0", "1", "0", "1", "4096", "0", tableID}
         };
         
         JDBC.assertFullResultSet(rs, expRS, true);
@@ -359,14 +339,11 @@ public final class SysDiagVTIMappingTest
             "SELECT * FROM NEW "
             + "org.apache.derby.diag.SpaceTable('APP', 'T1') as x");
         
-        expColNames = new String [] {
-            "CONGLOMERATENAME", "ISINDEX", "NUMALLOCATEDPAGES", "NUMFREEPAGES",
-            "NUMUNFILLEDPAGES", "PAGESIZE", "ESTIMSPACESAVING"};
-        JDBC.assertColumnNames(rs, expColNames);
+        JDBC.assertColumnNames(rs, allColNames);
         
         expRS = new String [][]
         {
-            {"T1", "0", "1", "0", "1", "4096", "0"}
+            {"T1", "0", "1", "0", "1", "4096", "0", tableID}
         };
         
         JDBC.assertFullResultSet(rs, expRS, true);



Mime
View raw message