From: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
---|---|
To: | Paul Ramsey <pramsey(at)cleverelephant(dot)ca> |
Cc: | Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Regina Obe <r(at)pcorp(dot)us> |
Subject: | Re: Compressed TOAST Slicing |
Date: | 2019-03-13 16:32:40 |
Message-ID: | AB33DB45-67B5-43C8-87A9-C4E3DF8EB447@yandex-team.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> 13 марта 2019 г., в 21:05, Paul Ramsey <pramsey(at)cleverelephant(dot)ca> написал(а):
>
> Here is a new (final?) patch ...
>
> <compressed-datum-slicing-20190313a.patch>
This check
@@ -744,6 +748,8 @@ pglz_decompress(const char *source, int32 slen, char *dest,
{
*dp = dp[-off];
dp++;
+ if (dp >= destend) /* check for buffer overrun */
+ break; /* do not clobber memory */
}
is still done for every byte. You can precompute maximum allowed length before that cycle. Here's diff
diff --git a/src/common/pg_lzcompress.c b/src/common/pg_lzcompress.c
index 6b48892a8f..05b2b3d5d1 100644
--- a/src/common/pg_lzcompress.c
+++ b/src/common/pg_lzcompress.c
@@ -744,12 +744,11 @@ pglz_decompress_checked(const char *source, int32 slen, char *dest,
* memcpy() here, because the copied areas could overlap
* extremely!
*/
+ len = Min(len, destend - dp);
while (len--)
{
*dp = dp[-off];
dp++;
- if (dp >= destend) /* check for buffer overrun */
- break; /* do not clobber memory */
}
}
else
Best regards, Andrey Borodin.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2019-03-13 16:38:33 | Re: GIN indexes on an = ANY(array) clause |
Previous Message | Robert Haas | 2019-03-13 16:20:30 | Re: using index or check in ALTER TABLE SET NOT NULL |