Distinguish EOF from a read error when loading the relcache init file

From: Evgeniy Gorbanyov <esgor(at)altlinux(dot)org>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Distinguish EOF from a read error when loading the relcache init file
Date: 2026-11-11 09:04:03
Message-ID: b192ab5c-19e9-42c2-af2a-3f9535e342cf@altlinux.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

load_relcache_init_file() treats a zero-length fread() of the next
relation descriptor length as the end of pg_internal.init, which has
no record count.  fread() also returns zero when a read error
transfers no data.  In that case the file is accepted whenever the
nailed rel and index counts already match, so a partial cache can be
installed instead of bootstrapping it from the built-in descriptors.

Check ferror() before treating a zero-length read as the end of the
file.

The patch is attached.

Regards,
Evgeniy Gorbanyov

Attachment Content-Type Size
0001-Distinguish-EOF-from-a-read-error-when-loading-the-r.patch text/x-patch 1.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-11-11 09:06:19 Re: Crashes on a partition whose concurrent detach never finished
Previous Message Aleksander Alekseev 2026-11-11 09:01:13 Re: {heap,minimal}_expand_tuple() are unused