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.94.2) (envelope-from ) id 1uUSWd-003bZM-Fy for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jun 2025 15:59:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uUSWb-005IDS-GO for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jun 2025 15:59:02 +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.94.2) (envelope-from ) id 1uUSWb-005IDG-6a for pgsql-hackers@lists.postgresql.org; Wed, 25 Jun 2025 15:59:01 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uUSWa-003xBa-0c for pgsql-hackers@lists.postgresql.org; Wed, 25 Jun 2025 15:59:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 55PFwsZt1296196; Wed, 25 Jun 2025 11:58:55 -0400 From: Tom Lane To: Daniel Gustafsson cc: Tomas Vondra , Evgeniy Gorbanev , pgsql-hackers@lists.postgresql.org Subject: Re: No error checking when reading from file using zstd in pg_dump In-reply-to: References: <6b9817a8-88ec-4efd-b441-9e2a0439c6b8@basealt.ru> <95255a86-4bc7-4ff4-aa26-4441aafdf0fb@basealt.ru> <522DB522-3962-4F91-A691-2DE790F6CCD6@yesql.se> <517794.1750082166@sss.pgh.pa.us> <3815B6CD-924B-40FA-823A-55E2F8F24602@yesql.se> <520142.1750083607@sss.pgh.pa.us> <644360.1750096605@sss.pgh.pa.us> <666035.1750106940@sss.pgh.pa.us> Comments: In-reply-to Daniel Gustafsson message dated "Wed, 25 Jun 2025 16:20:59 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1296194.1750867134.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 25 Jun 2025 11:58:54 -0400 Message-ID: <1296195.1750867134@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Gustafsson writes: > I spent a little bit of time reading over all the implementations and cr= oss > referencing the API for conformity, and came up with the attached. The = 0001 > patch is the one from upstream, and each subsequent commit is fixing one > function for all the implementations. Before pushing it should all be s= quashed > into a single commit IMHO. Thanks for tackling this! I looked over this patchset briefly, and found a couple of nits: v5-0002, in compress_io.h: + * Returns true on success and throws error for all error conditions. It doesn't return true anymore. Should be more like + * Returns nothing. Exits via pg_fatal for all error conditions. In LZ4Stream_write: you dropped the bit about - errno =3D (errno) ? errno : ENOSPC; but I think that's still necessary: we must assume ENOSPC if fwrite doesn't set errno. Other fwrite callers (write_none, Zstd_write) need this too. v5-0004 has an instance too, in Zstd_close. I did not check to see if other fwrite calls are OK, but it'd be good to verify that they all follow the pattern of presetting errno to 0 and then replacing that with ENOSPC. regards, tom lane