Support of partial decompression for datums - Mailing list pgsql-hackers

From Ildus Kurbangaliev
Subject Support of partial decompression for datums
Date
Msg-id 20151204154718.48024130@lp
Whole thread Raw
Responses Re: Support of partial decompression for datums
Re: Support of partial decompression for datums
List pgsql-hackers
Attached patch adds support of partial decompression for datums.
It will be useful in many cases when extracting part of data is
enough for big varlena structures.

It is especially useful for expanded datums, because it provides
storage for partial results.

I have another patch, which removes the 1 Mb limit on tsvector using
this feature.

Usage:

    Assert(VARATT_IS_COMPRESSED(attr));
    evh->data = (struct varlena *)
        palloc(TOAST_COMPRESS_RAWSIZE(attr) + VARHDRSZ);
    SET_VARSIZE(evh->data, TOAST_COMPRESS_RAWSIZE(attr) + VARHDRSZ);

    /* Extract size of tsvector */
    res = toast_decompress_datum_partial(attr, evh->data,
        evh->dcState, sizeof(int32));
    if (res == -1)
        elog(ERROR, "compressed tsvector is corrupted");

    evh->count = TS_COUNT((TSVector) evh->data);

    /* Extract entries of tsvector */
    res = toast_decompress_datum_partial(attr, evh->data,
        evh->dcState, sizeof(int32) + sizeof(WordEntry) * evh->count);
    if (res == -1)
        elog(ERROR, "compressed tsvector is corrupted");


--
Ildus Kurbangaliev
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company

Attachment

pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: atomic reads & writes (with no barriers)
Next
From: Michael Paquier
Date:
Subject: Re: Error with index on unlogged table