Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vml1I-00Fvhy-2T for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Feb 2026 03:54:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vml1G-00BQ95-1w for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Feb 2026 03:54:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vml1G-00BQ8x-11 for pgsql-hackers@lists.postgresql.org; Mon, 02 Feb 2026 03:54:35 +0000 Received: from fout-b2-smtp.messagingengine.com ([202.12.124.145]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vml1F-000000007ys-1JuG for pgsql-hackers@lists.postgresql.org; Mon, 02 Feb 2026 03:54:34 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 910321D0005F; Sun, 1 Feb 2026 22:54:31 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Sun, 01 Feb 2026 22:54:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:subject:subject:to:to; s=fm3; t=1770004471; x=1770090871; bh=uTQWg39Y8V7eyR01pxuS6IeMFS5qKgHl DYfc1qzheYQ=; b=saunAWYzs66kqY/SOeiatgEilBO+0Xoe74ashFYL3lOIpdoU EIC2HsTvCxCzuDT+PgX4x873X8NxefCihEly/f5vANHFOnxgZmO33Xm72laRSgZt pxKslxXavERcK8zLjfhBTN3h7mBawZwH48PRDuqV9s2JM1NS/s9KDkgWbtgMboxq ohl3Z7mJX7YLbU5VTuOYifbJSDUwZUP5SHrpQ9o/AU1r7IaMz3PstwDHTKkLxVpJ kgOZsJzuJVbjXjNi3U8xqHIxp3OPwZ1hjKqOx/lIq3rgxRRKyFZY3NKN0tjnl9a1 KnaJVMO8sH7HfRWfqpDYHzUZOUX3i8w6AWqKtg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1770004471; x= 1770090871; bh=uTQWg39Y8V7eyR01pxuS6IeMFS5qKgHlDYfc1qzheYQ=; b=L 3IU9ICTAeYF9uQn567Ra/fdflyGAxTBc0UdMQJ+/2k/DsXPaRDaqhwk3u01iawhI I2XQtEiWKInpJnZZKAdzlqAMxn0uRDIezpo3flWXTUMzr2UtNOjP8OX4NcarQasm hToxv1kBRa2oS0wNUftxzaZH8YAESiQpURXA+IHFb1BBIRdRZJSv/Sb2hWReKoqV DkWJsTUx/yKhp3pdfKe0iekzXKVQrkFrbE0f4e/IjQT8C6zVOJy9rPnGmiNV1baf dDlAc+RXfHpEy8vZehWAIrEmBbP8Ft8YnlKD0UwT0My5XyI969hr1871ykTvNhy8 t5BGwGdWcnulsSwmLmIKQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddujeeiieduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnegfrh hlucfvnfffucdlfeehmdenucfjughrpeffhffvvefukfggtggusehgtderredttddvnecu hfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqhhuih gvrhdrgiihiieqnecuggftrfgrthhtvghrnhepgfethfduhffhtdeiheefffefleduleei keekvdegffehgeetjedutdeffeeuudetnecuffhomhgrihhnpehpohhsthhgrhgvshhqlh drohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehmihgthhgrvghlsehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopedvpdhmoh guvgepshhmthhpohhuthdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhs thhsrdhpohhsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehrohgsvghrthhmhhgrrg hssehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 1 Feb 2026 22:54:30 -0500 (EST) Date: Mon, 2 Feb 2026 12:54:26 +0900 From: Michael Paquier To: Postgres hackers Cc: Robert Haas Subject: Incorrect errno used in OpenWalSummaryFile() Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="9SZJvrcclY8Y4Q36" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --9SZJvrcclY8Y4Q36 Content-Type: multipart/mixed; boundary="3+Le/7UDIuAabD8I" Content-Disposition: inline --3+Le/7UDIuAabD8I Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, While looking at walsummary.c for a different thread, I have bumped into this code: OpenWalSummaryFile(WalSummaryFile *ws, bool missing_ok) [...] file = PathNameOpenFile(path, O_RDONLY); if (file < 0 && (errno != EEXIST || !missing_ok)) ereport(ERROR, (errcode_for_file_access(), errmsg("could not open file \"%s\": %m", path))); And it seems to me that this EEXIST should be an ENOENT? The top of the function also documents that we want to handle an error when a summary file does not exist. The comment makes sense to me, not the code. It's also worth noting that this function has two callers, both use missing_ok = false, meaning that the errno check does not really matter today. If someone plays with this code on HEAD or the back-branches and decides to introduce a missing_ok=true call, it could matter, so I'd rather not change this function signature. This issue has been mentioned here as well, I've just bumped into it independently a few hours ago: https://www.postgresql.org/message-id/tencent_1CA40FCC21C1C770712BC089@qq.com Regards, -- Michael --3+Le/7UDIuAabD8I Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=wal-summary-errno.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/backup/walsummary.c b/src/backend/backup/walsummar= y.c index 4ee510092f99..4cd1824fbc6b 100644 --- a/src/backend/backup/walsummary.c +++ b/src/backend/backup/walsummary.c @@ -214,7 +214,7 @@ OpenWalSummaryFile(WalSummaryFile *ws, bool missing_ok) LSN_FORMAT_ARGS(ws->end_lsn)); =20 file =3D PathNameOpenFile(path, O_RDONLY); - if (file < 0 && (errno !=3D EEXIST || !missing_ok)) + if (file < 0 && (errno !=3D ENOENT || !missing_ok)) ereport(ERROR, (errcode_for_file_access(), errmsg("could not open file \"%s\": %m", path))); --3+Le/7UDIuAabD8I-- --9SZJvrcclY8Y4Q36 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmmAH/IACgkQnvQgOdby QH15OQ/8Cgh0nfLCB6iOFbC0Ip4r9Lmxsh32pKeg/VtpYwkfLEzfJCwSRZSiBB2i vfWD8QF+qiJDFlCvp0UG7ElGiSaj/NT3JkWLmNXg1tB80hmvaWnwKUAvd0qkL9iD zURUS0MdV6swZKMH2S01ndDmK69C+7PiZAW96g3TJnejfGkhOCKrmkL3o2se0kHN N68KQETEGo9408poVrgk5ztPj4ON7pW2j0Ovg2pOfcQq5FQm/qDMWFcTnUtvaPDA eK+F/O84DQJfzkuZqaPHAt/SXgMrp0lDURV46vyG/6SV1MSEAu1Ip6wqoVHJ2vmW jlaYtwxbFdXtNcKhUs/TntVMj0MGfT22dVIy3hZ/yMCZnmdKUvzKmdFPRQg1XRf+ s0mdqYVuMfHJkTPkMs7XCWGFy5rbABkn/RWNHVnQ2u5Is9MJoy0vuOrzaC8E5ylx 4nuIRcH7nvrnUTWYJSSYiAKofwmd+N5jBe5YGHoXo/UDqu5PlQwH45ZGiuZWgmWy Cf+RQLOUY9LZsDk9ZjJCAFzmKJ3XEG4kHNnStHCkHjHAt/k8OST+anhJAqyJdo50 SiwxWrZtmqkkftgQQFmT4/99EK3vMh2Z3/hIusvh9GOewbCVueqNx2/mNK0Co5Bb 3j27AX5WuvuLGiNPUL8wwEoLcgCj9PnFt9dHySJbpCX+tN87Q8k= =tbu2 -----END PGP SIGNATURE----- --9SZJvrcclY8Y4Q36--