Re: Compressed TOAST Slicing

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Paul Ramsey <pramsey(at)cleverelephant(dot)ca>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Regina Obe <r(at)pcorp(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Compressed TOAST Slicing
Date: 2019-03-12 16:10:08
Message-ID: 8473F4DC-D250-4C9E-B29D-311F75C2D9CC@yandex-team.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> 12 марта 2019 г., в 19:40, Paul Ramsey <pramsey(at)cleverelephant(dot)ca> написал(а):
>
>> On Mar 11, 2019, at 10:42 PM, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>>
>> int32
>> pglz_decompress(const char *source, int32 slen, char *dest,
>> - int32 rawsize)
>> + int32 rawsize, bool is_slice)
>
> The sanity check is just that both buffers are completely read they reach their respective ends. With a partial buffer on one side, that check just will definitionally not happen when slicing (it’s not possible to know a priori what location in the compressed buffer corresponds to a location in the uncompressed one). I can ensure the old API still holds for pglz_decompress() and add a new pglz_decompress_slice() that takes the parameter, is that sufficient?

I think that providing two separate entry points for this functionality is better option.
The word "slice" is widely used for [start:end] slicing, not sure it's good word. But I'm not good in English.

Either way we could replace

if (dp != destend || sp != srcend)
return -1;

with

if (dp != destend && sp != srcend)
return -1;

and that's it. || defends from data corruption and some kind of programming mistakes, but actually that's not the purpose of data compression.

Best regards, Andrey Borodin.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-03-12 16:13:48 Re: Compressed TOAST Slicing
Previous Message Alvaro Herrera 2019-03-12 16:04:55 Re: Update does not move row across foreign partitions in v11