*
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.299.4.3 2008/01/03 21:25:00 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.299.4.4 2008/02/11 19:14:53 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
                free_space += vacpage->free;
 
                /*
-                * Add the page to fraged_pages if it has a useful amount of free
-                * space.  "Useful" means enough for a minimal-sized tuple. But we
-                * don't know that accurately near the start of the relation, so
-                * add pages unconditionally if they have >= BLCKSZ/10 free space.
+                * Add the page to vacuum_pages if it requires reaping, and add it to
+                * fraged_pages if it has a useful amount of free space.  "Useful"
+                * means enough for a minimal-sized tuple.  But we don't know that
+                * accurately near the start of the relation, so add pages
+                * unconditionally if they have >= BLCKSZ/10 free space.  Also
+                * forcibly add pages with no live tuples, to avoid confusing the
+                * empty_end_pages logic.  (In the presence of unreasonably small
+                * fillfactor, it seems possible that such pages might not pass
+                * the free-space test, but they had better be in the list anyway.)
                 */
-               do_frag = (vacpage->free >= min_tlen || vacpage->free >= BLCKSZ / 10);
+               do_frag = (vacpage->free >= min_tlen || vacpage->free >= BLCKSZ / 10 ||
+                                  notup);
 
                if (do_reap || do_frag)
                {