*** commands/vacuum.c.orig Tue Dec 26 23:24:01 2000 --- commands/vacuum.c Wed Dec 27 00:36:46 2000 *************** *** 1025,1030 **** --- 1025,1031 ---- *idcur; int last_fraged_block, last_vacuum_block, + last_moved_in_block, i = 0; Size tuple_len; int num_moved, *************** *** 1060,1065 **** --- 1061,1067 ---- vacuumed_pages = vacuum_pages->vpl_num_pages - vacuum_pages->vpl_empty_end_pages; last_vacuum_page = vacuum_pages->vpl_pagedesc[vacuumed_pages - 1]; last_vacuum_block = last_vacuum_page->vpd_blkno; + last_moved_in_block = 0; Assert(last_vacuum_block >= last_fraged_block); cur_buffer = InvalidBuffer; num_moved = 0; *************** *** 1073,1078 **** --- 1075,1083 ---- /* if it's reapped page and it was used by me - quit */ if (blkno == last_fraged_block && last_fraged_page->vpd_offsets_used > 0) break; + /* couldn't shrink any more if this block has MOVED_IN tuplesit's - quit */ + if (blkno == last_moved_in_block) + break; buf = ReadBuffer(onerel, blkno); page = BufferGetPage(buf); *************** *** 1447,1452 **** --- 1452,1459 ---- pfree(newtup.t_data); newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid); ItemPointerSet(&(newtup.t_self), vtmove[ti].vpd->vpd_blkno, newoff); + if (vtmove[i].vpd->vpd_blkno > last_moved_in_block) + last_moved_in_block = vtmove[i].vpd->vpd_blkno; /* * Set t_ctid pointing to itself for last tuple in *************** *** 1579,1584 **** --- 1586,1593 ---- newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid); ItemPointerSet(&(newtup.t_data->t_ctid), cur_page->vpd_blkno, newoff); newtup.t_self = newtup.t_data->t_ctid; + if (cur_page->vpd_blkno > last_moved_in_block) + last_moved_in_block = cur_page->vpd_blkno; /* * Mark old tuple as moved_off by vacuum and store vacuum XID