Incorrect argument passed to buffer_readv_encode_error()

Started by Antonin Houska9 days ago3 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

This thread has been committed, so CI has stopped here. Anything below is the last result it produced.

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t254192
psql -h localhost -U postgres

Built from patchset v1 (message #1), October 15, 2026 at 06:43 AM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t254192_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t254192_1 && git checkout t254192_1

Patchset v1 (message #1) is on t254192_1

Jump to latest
#1Antonin Houska
ah@cybertec.at

Although there's no compiler warning, and probably no correctness issue, I
think the intended coding was as I propose in the diff attached.

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

Attachments:

t254192_1
buffer_readv_encode_error_argument_fix.difftext/x-diffDownload+1-1
#2Steven Niu
niushiji@gmail.com
In reply to: Antonin Houska (#1)
Re: Incorrect argument passed to buffer_readv_encode_error()

Agree with this change:

buffer_readv_encode_error(&result_one, is_temp,
*zeroed_buffer,
*ignored_checksum,
- *buffer_invalid,
+ *buffer_invalid ? 1 : 0,
*zeroed_buffer ? 1 : 0,
*failed_checksum ? 1 : 0,
buf_off, buf_off, buf_off);

The function prototype of buffer_readv_encode_error() is,

static inline void
buffer_readv_encode_error(PgAioResult *result,
bool is_temp,
bool zeroed_any,
bool ignored_any,
uint8 error_count,
uint8 zeroed_count,
uint8 checkfail_count,
uint8 first_error_off,
uint8 first_zeroed_off,
uint8 first_ignored_off)

Apparently the error_count argument should behave same as zeroed_count and checkfail_count.

Regards,
Steven
________________________________________
From: Antonin Houska <ah@cybertec.at>
Sent: Wednesday, October 14, 2026 14:31
To: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Cc: andres@anarazel.de <andres@anarazel.de>
Subject: Incorrect argument passed to buffer_readv_encode_error()

Although there's no compiler warning, and probably no correctness issue, I
think the intended coding was as I propose in the diff attached.

--
Antonin Houska
Web: https://www.cybertec-postgresql.com

#3Michael Paquier
michael@paquier.xyz
In reply to: Antonin Houska (#1)
Re: Incorrect argument passed to buffer_readv_encode_error()

On Wed, Oct 14, 2026 at 08:31:22AM +0200, Antonin Houska wrote:

Although there's no compiler warning, and probably no correctness issue, I
think the intended coding was as I propose in the diff attached.

Indeed. That's harmless still inconsistent as this *buffer_invalid
points to error_count in buffer_readv_encode_error, which is assumed
to be a uint8 counter.

I am wondering if this should be backpatched down to v18, actually, at
least to keep the branches consistently in check, or just as a matter
of style.
--
Michael