|
27 | 27 | * FALSE if not; in the latter case the contents of dest
|
28 | 28 | * are undefined.
|
29 | 29 | *
|
30 |
| - * void |
| 30 | + * bool |
31 | 31 | * pglz_decompress(const PGLZ_Header *source, char *dest)
|
32 | 32 | *
|
33 | 33 | * source is the compressed input.
|
|
40 | 40 | * The data is written to buff exactly as it was handed
|
41 | 41 | * to pglz_compress(). No terminating zero byte is added.
|
42 | 42 | *
|
| 43 | + * The return value is TRUE if decompression succeeded, |
| 44 | + * FALSE if not; in the latter case the contents of dest |
| 45 | + * are undefined. |
| 46 | + * |
43 | 47 | * The decompression algorithm and internal data format:
|
44 | 48 | *
|
45 | 49 | * PGLZ_Header is defined as
|
|
169 | 173 | *
|
170 | 174 | * Copyright (c) 1999-2014, PostgreSQL Global Development Group
|
171 | 175 | *
|
172 |
| - * src/backend/utils/adt/pg_lzcompress.c |
| 176 | + * src/common/pg_lzcompress.c |
173 | 177 | * ----------
|
174 | 178 | */
|
175 | 179 | #include "postgres.h"
|
176 | 180 |
|
177 | 181 | #include <limits.h>
|
178 | 182 |
|
179 |
| -#include "utils/pg_lzcompress.h" |
| 183 | +#include "common/pg_lzcompress.h" |
180 | 184 |
|
181 | 185 |
|
182 | 186 | /* ----------
|
@@ -492,7 +496,8 @@ pglz_find_match(int16 *hstart, const char *input, const char *end,
|
492 | 496 | /* ----------
|
493 | 497 | * pglz_compress -
|
494 | 498 | *
|
495 |
| - * Compresses source into dest using strategy. |
| 499 | + * Compresses source into dest using strategy. Returns false if a failure |
| 500 | + * occurred, true in case of success. |
496 | 501 | * ----------
|
497 | 502 | */
|
498 | 503 | bool
|
@@ -678,10 +683,11 @@ pglz_compress(const char *source, int32 slen, PGLZ_Header *dest,
|
678 | 683 | /* ----------
|
679 | 684 | * pglz_decompress -
|
680 | 685 | *
|
681 |
| - * Decompresses source into dest. |
| 686 | + * Decompresses source into dest. Returns false if a failure |
| 687 | + * occurred, true in case of success. |
682 | 688 | * ----------
|
683 | 689 | */
|
684 |
| -void |
| 690 | +bool |
685 | 691 | pglz_decompress(const PGLZ_Header *source, char *dest)
|
686 | 692 | {
|
687 | 693 | const unsigned char *sp;
|
@@ -771,9 +777,10 @@ pglz_decompress(const PGLZ_Header *source, char *dest)
|
771 | 777 | * Check we decompressed the right amount.
|
772 | 778 | */
|
773 | 779 | if (dp != destend || sp != srcend)
|
774 |
| - elog(ERROR, "compressed data is corrupt"); |
| 780 | + return false; |
775 | 781 |
|
776 | 782 | /*
|
777 | 783 | * That's it.
|
778 | 784 | */
|
| 785 | + return true; |
779 | 786 | }
|
0 commit comments