| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | zengman <zengman(at)halodbtech(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: POC: make mxidoff 64 bits |
| Date: | 2026-01-04 18:06:06 |
| Message-ID: | 73b48ddd-3114-450e-939b-63a39b0210c6@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 30/12/2025 03:49, zengman wrote:
> Hi,
>
> I'm currently looking into the `SlruReadSwitchPageSlow` function and have a question regarding the expression `&state->buf.data + bytes_read` —
> I suspect the ampersand (&) here might be misused. Would you be able to help me verify this?
>
> ```
> while (bytes_read < BLCKSZ)
> {
> ssize_t rc;
>
> rc = pg_pread(state->fd,
> &state->buf.data + bytes_read,
> BLCKSZ - bytes_read,
> offset);
> if (rc < 0)
> {
> if (errno == EINTR)
> continue;
> pg_fatal("could not read file \"%s\": %m", state->fn);
> }
> if (rc == 0)
> {
> /* unexpected EOF */
> pg_log(PG_WARNING, "unexpected EOF reading file \"%s\" at offset %u, reading as zeros",
> state->fn, (unsigned int) offset);
> memset(&state->buf.data + bytes_read, 0, BLCKSZ - bytes_read);
> break;
> }
> bytes_read += rc;
> offset += rc;
> }
> ```
>
> ```
> rc = pg_pread(state->fd,
> &state->buf.data + bytes_read,
> BLCKSZ - bytes_read,
> offset);
> memset(&state->buf.data + bytes_read, 0, BLCKSZ - bytes_read);
> ```
Yes, you're right. Good catch! Committed the fix, thanks.
- Heikki
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jim Jones | 2026-01-04 19:05:01 | Re: WIP - xmlvalidate implementation from TODO list |
| Previous Message | Jacob Jackson | 2026-01-04 17:34:19 | Proposal: Add a UNIQUE NOT ENFORCED constraint |