Re: [PATCH] Fix minor issues in astreamer_zstd.c

From: zengman <zengman(at)halodbtech(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: [PATCH] Fix minor issues in astreamer_zstd.c
Date: 2026-01-11 04:24:22
Message-ID: tencent_762065B21B16BCB74765B5CC@qq.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> After re-reading the LZ4 and GZIP code, I agree — the parameter is indeed wrong.
> It looks like decompressor_finalize has the same issue in both implementations.
> Would you mind taking a look?
>
> diff --git a/src/fe_utils/astreamer_gzip.c b/src/fe_utils/astreamer_gzip.c
> index e8d62f754ca..4ccec1a5a7f 100644
> --- a/src/fe_utils/astreamer_gzip.c
> +++ b/src/fe_utils/astreamer_gzip.c
> @@ -349,7 +349,7 @@ astreamer_gzip_decompressor_finalize(astreamer *streamer)
> */
> astreamer_content(mystreamer->base.bbs_next, NULL,
> mystreamer->base.bbs_buffer.data,
> - mystreamer->base.bbs_buffer.maxlen,
> + mystreamer->bytes_written,
> ASTREAMER_UNKNOWN);
>
> astreamer_finalize(mystreamer->base.bbs_next);
> diff --git a/src/fe_utils/astreamer_lz4.c b/src/fe_utils/astreamer_lz4.c
> index bcee7e088de..570e5305874 100644
> --- a/src/fe_utils/astreamer_lz4.c
> +++ b/src/fe_utils/astreamer_lz4.c
> @@ -401,7 +401,7 @@ astreamer_lz4_decompressor_finalize(astreamer *streamer)
> */
> astreamer_content(mystreamer->base.bbs_next, NULL,
> mystreamer->base.bbs_buffer.data,
> - mystreamer->base.bbs_buffer.maxlen,
> + mystreamer->bytes_written,
> ASTREAMER_UNKNOWN);
>
> astreamer_finalize(mystreamer->base.bbs_next);

Hi,

Thank you for your review. I've moved it to 0003, and the test passed without any issues.
However, I'm wondering why no one else reported this. Perhaps this part isn't actually worth changing.
I think we can invite Mr. Robert Haas to help me confirm this, so I've chosen to CC him.

--
Regards,
Man Zeng
www.openhalo.org

Attachment Content-Type Size
0001-Fix-comment-error-in-astreamer_zstd.c-header.patch application/octet-stream 1.0 KB
0002-Fix-data-corruption-in-astreamer_zstd_decompressor_f.patch application/octet-stream 1.2 KB
0003-Fix-output-buffer-handling-in-astreamer_gzip-and-ast.patch application/octet-stream 2.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2026-01-11 04:55:01 Re: [19] CREATE SUBSCRIPTION ... SERVER
Previous Message Thomas Munro 2026-01-11 04:14:51 Re: LLVM JITLink attempt II (WIP)