db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r583956 - /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
Date Thu, 11 Oct 2007 21:22:13 GMT
Author: kahatlen
Date: Thu Oct 11 14:22:12 2007
New Revision: 583956

URL: http://svn.apache.org/viewvc?rev=583956&view=rev
Log:
DERBY-3099: Pages not freed on rollback to savepoint

svn merge -c 583691 ../trunk

Modified:
    db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java

Modified: db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java?rev=583956&r1=583955&r2=583956&view=diff
==============================================================================
--- db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
(original)
+++ db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
Thu Oct 11 14:22:12 2007
@@ -369,10 +369,9 @@
      * This is used as the threshold for a long column.
      * 
      * maxFieldSize = 
-     *      totalSpace * (1 - spareSpace/100) - 
-     *      slotEntrySize * - 16 - OVERFLOW_POINTER_SIZE;
+     *      totalSpace - slotEntrySize - 16 - OVERFLOW_POINTER_SIZE;
      **/
-	protected int maxFieldSize;
+    private int maxFieldSize;
 
 
     /**
@@ -696,14 +695,14 @@
 		if (rawDataIn != null)
 			rawDataIn.setData(pageData);
 
-        initSpace();
+        // Note that the slotFieldSize and slotEntrySize need to be
+        // calculated BEFORE initSpace() is called, because the
+        // maxFieldSize computation in initSpace() includes these
+        // values in its calculations. (DERBY-3099)
+        slotFieldSize = calculateSlotFieldSize(pageSize);
+        slotEntrySize = 3 * slotFieldSize;
 
-		if (pageSize >= 65536)
-			slotFieldSize = LARGE_SLOT_SIZE;
-		else
-			slotFieldSize = SMALL_SLOT_SIZE;
-		
-		slotEntrySize = 3 * slotFieldSize;
+        initSpace();
 
         // offset of slot table entry[0]
         slotTableOffsetToFirstEntry = 
@@ -721,6 +720,21 @@
 			rawDataOut.setData(pageData);
 	}
 
+    /**
+     * Calculate the slot field size from the page size.
+     *
+     * @param pageSize page size in bytes
+     * @return slot field size in bytes
+     */
+    private int calculateSlotFieldSize(int pageSize) {
+        if (pageSize < 65536) {
+            // slots are 2 bytes (unsigned short data type) for pages <64KB
+            return SMALL_SLOT_SIZE;
+        } else {
+            // slots are 4 bytes (int data type) for pages >=64KB
+            return LARGE_SLOT_SIZE;
+        }
+    }
 
     /**
      * Create a new StoredPage.
@@ -3338,8 +3352,16 @@
 
 		maxFieldSize = totalSpace - slotEntrySize - 16 - OVERFLOW_POINTER_SIZE;
 
-        if (SanityManager.DEBUG)
+        if (SanityManager.DEBUG) {
             SanityManager.ASSERT(maxFieldSize >= 0);
+            // DERBY-3099: maxFieldSize was calculated before slotFieldSize and
+            // slotEntrySize had been initialized.
+            int expectedFieldSize = calculateSlotFieldSize(pageData.length);
+            SanityManager.ASSERT(slotFieldSize == expectedFieldSize,
+                                 "slotFieldSize uninitialized");
+            SanityManager.ASSERT(slotEntrySize == 3 * expectedFieldSize,
+                                 "slotEntrySize uninitialized");
+        }
 	}
 
     /**



Mime
View raw message