|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.10 1996/11/28 04:37:38 vadim Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.11 1996/11/29 10:27:59 vadim Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -462,6 +462,7 @@ _vc_scanheap (VRelList curvrl, Relation onerel,
|
462 | 462 | {
|
463 | 463 | intnblocks,blkno;
|
464 | 464 | ItemIditemid;
|
| 465 | +ItemPointeritemptr; |
465 | 466 | HeapTuplehtup;
|
466 | 467 | Bufferbuf;
|
467 | 468 | Pagepage,tempPage=NULL;
|
@@ -611,6 +612,33 @@ DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.",
|
611 | 612 | tupgone);
|
612 | 613 | }
|
613 | 614 |
|
| 615 | +/* |
| 616 | + * It's possibly! But from where it comes ? |
| 617 | + * And should we fix it ? - vadim 11/28/96 |
| 618 | + */ |
| 619 | +itemptr=&(htup->t_ctid); |
| 620 | +if ( !ItemPointerIsValid (itemptr)|| |
| 621 | +BlockIdGetBlockNumber(&(itemptr->ip_blkid))!=blkno ) |
| 622 | + { |
| 623 | +elog (NOTICE,"ITEM POINTER IS INVALID: %u/%u FOR %u/%u. TUPGONE %d.", |
| 624 | +BlockIdGetBlockNumber(&(itemptr->ip_blkid)), |
| 625 | +itemptr->ip_posid,blkno,offnum,tupgone); |
| 626 | + } |
| 627 | + |
| 628 | +/* |
| 629 | + * Other checks... |
| 630 | + */ |
| 631 | +if (htup->t_len!=itemid->lp_len ) |
| 632 | + { |
| 633 | +elog (NOTICE,"PAGEHEADER' LEN %u IS NOT THE SAME AS HTUP' %u FOR %u/%u.TUPGONE %d.", |
| 634 | +itemid->lp_len,htup->t_len,blkno,offnum,tupgone); |
| 635 | + } |
| 636 | +if ( !OidIsValid(htup->t_oid) ) |
| 637 | + { |
| 638 | +elog (NOTICE,"OID IS INVALID FOR %u/%u.TUPGONE %d.", |
| 639 | +blkno,offnum,tupgone); |
| 640 | + } |
| 641 | + |
614 | 642 | if (tupgone) {
|
615 | 643 | ItemIdlpp;
|
616 | 644 |
|
@@ -676,6 +704,10 @@ DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.",
|
676 | 704 | /* save stats in the rel list for use later */
|
677 | 705 | curvrl->vrl_ntups=ntups;
|
678 | 706 | curvrl->vrl_npages=nblocks;
|
| 707 | +if (ntups==0 ) |
| 708 | +min_tlen=max_tlen=0; |
| 709 | +curvrl->vrl_min_tlen=min_tlen; |
| 710 | +curvrl->vrl_max_tlen=max_tlen; |
679 | 711 |
|
680 | 712 | Vvpl->vpl_nemend=nemend;
|
681 | 713 | Fvpl->vpl_nemend=nemend;
|
@@ -746,6 +778,7 @@ _vc_rpfheap (VRelList curvrl, Relation onerel,
|
746 | 778 | InsertIndexResultiresult;
|
747 | 779 | VPageListDataNvpl;
|
748 | 780 | VPageDescrToVpd=NULL,Fvplast,Vvplast,vpc,*vpp;
|
| 781 | +intToVpI=0; |
749 | 782 | IndDesc*Idesc,*idcur;
|
750 | 783 | intFblklast,Vblklast,i;
|
751 | 784 | Sizetlen;
|
@@ -872,16 +905,40 @@ _vc_rpfheap (VRelList curvrl, Relation onerel,
|
872 | 905 | !_vc_enough_space (ToVpd,tlen) )
|
873 | 906 | {
|
874 | 907 | if (ToBuf!=InvalidBuffer )
|
| 908 | +{ |
875 | 909 | WriteBuffer(ToBuf);
|
876 |
| -ToBuf=InvalidBuffer; |
| 910 | +ToBuf=InvalidBuffer; |
| 911 | +/* |
| 912 | + * If no one tuple can't be added to this page - |
| 913 | + * remove page from Fvpl. - vadim 11/27/96 |
| 914 | + */ |
| 915 | +if ( !_vc_enough_space (ToVpd,curvrl->vrl_min_tlen) ) |
| 916 | + { |
| 917 | +if (ToVpd!=Fvplast ) |
| 918 | + { |
| 919 | +Assert (Fnpages>ToVpI+1 ); |
| 920 | +memmove (Fvpl->vpl_pgdesc+ToVpI, |
| 921 | +Fvpl->vpl_pgdesc+ToVpI+1, |
| 922 | +sizeof (VPageDescr*)* (Fnpages-ToVpI-1)); |
| 923 | + } |
| 924 | +Assert (Fnpages >=1 ); |
| 925 | +Fnpages--; |
| 926 | +if (Fnpages==0 ) |
| 927 | +break; |
| 928 | +/* get prev reapped page from Fvpl */ |
| 929 | +Fvplast=Fvpl->vpl_pgdesc[Fnpages-1]; |
| 930 | +Fblklast=Fvplast->vpd_blkno; |
| 931 | + } |
| 932 | + } |
877 | 933 | for (i=0;i<Fnpages;i++)
|
878 | 934 | {
|
879 | 935 | if (_vc_enough_space (Fvpl->vpl_pgdesc[i],tlen) )
|
880 | 936 | break;
|
881 | 937 | }
|
882 | 938 | if (i==Fnpages )
|
883 | 939 | break;/* can't move item anywhere */
|
884 |
| -ToVpd=Fvpl->vpl_pgdesc[i]; |
| 940 | +ToVpI=i; |
| 941 | +ToVpd=Fvpl->vpl_pgdesc[ToVpI]; |
885 | 942 | ToBuf=ReadBuffer(onerel,ToVpd->vpd_blkno);
|
886 | 943 | ToPage=BufferGetPage(ToBuf);
|
887 | 944 | /* if this page was not used before - clean it */
|
|