Re: Small fix for inv_getsize

Поиск
Список
Период
Сортировка
От Denis Perchine
Тема Re: Small fix for inv_getsize
Дата
Msg-id 00110300292802.00541@dyp.perchine.com
обсуждение исходный текст
Ответ на Re: Small fix for inv_getsize  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Small fix for inv_getsize  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-patches
 3 Ноябрь 2000 01:19, Tom Lane написал:
> Denis Perchine <dyp@perchine.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@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

В списке pgsql-patches по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Small fix for inv_getsize
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Small fix for inv_getsize