]> granicus.if.org Git - postgresql/commitdiff
Fix PageGetExactFreeSpace() so that it actually behaves sensibly
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 10 Feb 2008 20:39:08 +0000 (20:39 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 10 Feb 2008 20:39:08 +0000 (20:39 +0000)
if pd_lower > pd_upper, rather than merely claiming to.  This would
only matter if the page header were corrupt, which shouldn't occur,
but ...

src/backend/storage/page/bufpage.c

index 32b80c182f066e5b45cf1d0d91c53c8299431667..ad1c8c3ed3f61651d8329f3c328f309710bb3843 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.77 2008/01/01 19:45:52 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/storage/page/bufpage.c,v 1.78 2008/02/10 20:39:08 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -489,6 +489,9 @@ PageGetExactFreeSpace(Page page)
        space = (int) ((PageHeader) page)->pd_upper -
                (int) ((PageHeader) page)->pd_lower;
 
+       if (space < 0)
+               return 0;
+
        return (Size) space;
 }