Skip site navigation (1) Skip section navigation (2)

Re: Small fix for inv_getsize

From: Denis Perchine <dyp(at)perchine(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Small fix for inv_getsize
Date: 2000-11-02 18:29:28
Message-ID: 00110300292802.00541@dyp.perchine.com (view raw or flat)
Thread:
Lists: pgsql-patches
 3 Ноябрь 2000 01:19, Tom Lane написал:
> Denis Perchine <dyp(at)perchine(dot)com> writes:
> > you wrote. Except VARATT_IS_EXTENDED check (is it neccessary, can I store
> > data and be sure that it is not toasted? I do not like this for BLOBs).
>
> Yes, it's necessary *and* appropriate.  LO data won't be moved off,
> because pg_largeobject doesn't have a toast table (unless the user makes
> one), but it can be compressed.
>
> > All other seems the same... Please give me an example of this check...
>
> The loop only has to loop till it finds a valid tuple.

But my code do exactly this...
The only difference between your code and mine (except you search through all 
tuples) is in toast handling... Isn't (tuple.t_data == NULL) a validity check?

My code:
        while ((indexRes = index_getnext(sd, ForwardScanDirection))) {
                tuple.t_self = indexRes->heap_iptr;
                heap_fetch(obj_desc->heap_r, SnapshotNow, &tuple, &buffer);
                pfree(indexRes);
                if (tuple.t_data == NULL)
                        continue;
                found++;
                data = (Form_pg_largeobject) GETSTRUCT(&tuple);
                lastbyte = data->pageno * IBLKSIZE + 
getbytealen(&(data->data));
                ReleaseBuffer(buffer);
                break;
        }

Your code:
        while ((indexRes = index_getnext(sd, ForwardScanDirection)))
        {
                tuple.t_self = indexRes->heap_iptr;
                heap_fetch(obj_desc->heap_r, SnapshotNow, &tuple, &buffer);
                pfree(indexRes);
                if (tuple.t_data == NULL)
                        continue;
                found = true;
                data = (Form_pg_largeobject) GETSTRUCT(&tuple);
                datafield = &(data->data);
                pfreeit = false;
                if (VARATT_IS_EXTENDED(datafield))
                {
                        datafield = (bytea *)
                                heap_tuple_untoast_attr((varattrib *) 
datafield);
                        pfreeit = true;
                }
                thislastbyte = data->pageno * LOBLKSIZE + 
getbytealen(datafield);
                if (thislastbyte > lastbyte)
                        lastbyte = thislastbyte;
                if (pfreeit)
                        pfree(datafield);
                ReleaseBuffer(buffer);
        }

-- 
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp(at)perchine(dot)com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

In response to

Responses

pgsql-patches by date

Next:From: Tom LaneDate: 2000-11-02 19:19:02
Subject: Re: Small fix for inv_getsize
Previous:From: Tom LaneDate: 2000-11-02 18:24:41
Subject: Re: Small fix for inv_getsize

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group