db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r672834 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
Date Mon, 30 Jun 2008 17:35:34 GMT
Author: mikem
Date: Mon Jun 30 10:35:33 2008
New Revision: 672834

URL: http://svn.apache.org/viewvc?rev=672834&view=rev
Log:
DERBY-3625

Adding space check to case where we try to move row to a new page.  I could
not come up with a repro for this case, but seems safer to check for space
than not.  The case the code is trying to avoid is a free page that has been
reclaimed with a nextid that requires more space than the row on the source
page.


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

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java?rev=672834&r1=672833&r2=672834&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/store/raw/data/StoredPage.java Mon
Jun 30 10:35:33 2008
@@ -6921,8 +6921,24 @@
                 // last and unfilled page did not work, try getting a free page
                 dest_page = (StoredPage) owner.addPage();
 
-                if (dest_page.getPageNumber() >= getPageNumber())
+                if ((dest_page.getPageNumber() >= getPageNumber()) ||
+                    (!dest_page.spaceForCopy(row_size, record_id)))
                 {
+                    // The only time a new page might not have enough space is
+                    // if the source row fills or almost fills a page by itself
+                    // and has a record id that is smaller than the record id
+                    // will be on the destination page such that the increase
+                    // in space.  Record id's are stored on the page in a 
+                    // compressed format such that depending on the value they
+                    // may store in 1, 2, or 4 bytes, thus the destination page
+                    // may need an additional 1, 2 or 3 bytes
+                    // depending on the source and destination row id's.
+                    // Because of record header overhead this can only happen
+                    // if there is just one row on a page.  For now just going
+                    // to give up on moving this row.  Future work could 
+                    // improve the algorithm to find a page with an equal or
+                    // smaller stored record id in this case.
+                
                     owner.removePage(dest_page);
                     dest_page = null;
                 }



Mime
View raw message