Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKUnk-0003XF-9A for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jan 2023 01:42:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pKUni-0006Pl-9Z for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jan 2023 01:42:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKUnh-0006Pb-Qx for pgsql-hackers@lists.postgresql.org; Wed, 25 Jan 2023 01:42:10 +0000 Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pKUne-0004H1-MG for pgsql-hackers@lists.postgresql.org; Wed, 25 Jan 2023 01:42:08 +0000 Received: by mail-il1-x134.google.com with SMTP id h10so6078773ilq.6 for ; Tue, 24 Jan 2023 17:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=CyZvaTgyudBIZ13AszEnshpvwgf39SXM8rf9chfJVik=; b=rPeRuLOjFhXXRKX/US6mK/KkeN9KSlR7XNiZQZvTIeDKs2isNm180NQmQOxPOk2RQu 3tPYpPZrCTI7QFBgTliNC7wiCqhETIfovsJgQjYY6SNGt89zioIB8pdhOCazlYMrzA3M LVV3tt6Rhx+PzkcsBfw9hourgAsh6MEAFTCbqiAn79iAr58tdhpC9ANFfRNEQCWJ63KK usyfQkCb5iFvytpR8meMhf5vOfkF2jOavsDsIMpJt7Rz097XuErDVorLE5DTX0eUILeW bCdgr7XQSHDQpdy7ctlssQgSesZ4ASMAsrIKZ3LiwbHttdomq6vT8zOOAJqivueUhwI+ zd2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CyZvaTgyudBIZ13AszEnshpvwgf39SXM8rf9chfJVik=; b=fVgpcbvisrBNm4lbA/1ExBcpW389MNx9thdDUdUghwZ6ygBEmy3xYfIYjhb+WUG2B2 UkBpUQ1X+zLgVKh1zi9oerv02mlWJJPwAUNpuKcKZBjHrH+EyQ5312U6jIdpPj5m9yoW WVipBVFMil8PZSbpZW5xZ16qzXK7eRXBHT0XLxmODZ0F5UL9GnK/WPbpPxd6NrjJtjU9 0GxqJ+yWjSErHkaQGg7u/bGCGc7LRZzEBPJUWGLHBLGxqTznsYnGIMHkLnyEanKWwDS6 /Mtt16C+Pe3nic7FpQO1tubxf9qepXPLMKS9KAbVNBQJqg1IJgRr7sLbC+ei4kyZIwv3 c5sA== X-Gm-Message-State: AO0yUKUnvwYgjbjHI8lb54qAfr6Lkxr6HBmodUI4tckk93dAGgdx1OB5 yCgeYYkLzSGwAGLyoiAH8DPw/g== X-Google-Smtp-Source: AK7set8X5+GFXrZ7JQaD215By5q/tSqVYMerCxOG3eRuQsQjMQ7Sh/JaelAwFDqGOyu6ZXS40p8kKg== X-Received: by 2002:a05:6e02:1be1:b0:310:9954:8aff with SMTP id y1-20020a056e021be100b0031099548affmr3052904ilv.9.1674610925980; Tue, 24 Jan 2023 17:42:05 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id s13-20020a056638258d00b00389cb050d1bsm1191951jat.33.2023.01.24.17.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jan 2023 17:42:05 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id EE814800A27; Tue, 24 Jan 2023 19:42:03 -0600 (CST) Date: Tue, 24 Jan 2023 19:42:03 -0600 From: Justin Pryzby To: gkokolatos@pm.me Cc: Tomas Vondra , Michael Paquier , pgsql-hackers@lists.postgresql.org, Rachel Heaton Subject: Re: Add LZ4 compression in pg_dump Message-ID: <20230125014203.GL13860@telsasoft.com> References: <41036470-041b-08a3-469d-fe07de2bc58e@enterprisedb.com> <6ab89d42-0345-b96e-02d4-68e171cdbe03@enterprisedb.com> <7zu6GYFi72jByVk2SEe_nd8r1DHhwA35vSntAE9sAfiMX9Lfk6bwimkwmu7GDgYaEvL27SE4qF1uK4_LHWQM4H-SXOwkMAI-GV8PKGmED_E=@pm.me> <20230123180014.GX13860@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jan 24, 2023 at 03:56:20PM +0000, gkokolatos@pm.me wrote: > On Monday, January 23rd, 2023 at 7:00 PM, Justin Pryzby wrote: > > On Mon, Jan 23, 2023 at 05:31:55PM +0000, gkokolatos@pm.me wrote: > > > > > Please find attached v23 which reintroduces the split. > > > > > > 0001 is reworked to have a reduced footprint than before. Also in an attempt > > > to facilitate the readability, 0002 splits the API's and the uncompressed > > > implementation in separate files. > > > > Thanks for updating the patch. Could you address the review comments I > > sent here ? > > https://www.postgresql.org/message-id/20230108194524.GA27637%40telsasoft.com > > Please find v24 attached. Thanks for updating the patch. In 001, RestoreArchive() does: > -#ifndef HAVE_LIBZ > - if (AH->compression_spec.algorithm == PG_COMPRESSION_GZIP && > - AH->PrintTocDataPtr != NULL) > + supports_compression = false; > + if (AH->compression_spec.algorithm == PG_COMPRESSION_NONE || > + AH->compression_spec.algorithm == PG_COMPRESSION_GZIP) > + supports_compression = true; > + > + if (AH->PrintTocDataPtr != NULL) > { > for (te = AH->toc->next; te != AH->toc; te = te->next) > { > if (te->hadDumper && (te->reqs & REQ_DATA) != 0) > - pg_fatal("cannot restore from compressed archive (compression not supported in this installation)"); > + { > +#ifndef HAVE_LIBZ > + if (AH->compression_spec.algorithm == PG_COMPRESSION_GZIP) > + supports_compression = false; > +#endif > + if (supports_compression == false) > + pg_fatal("cannot restore from compressed archive (compression not supported in this installation)"); > + } > } > } > -#endif This first checks if the algorithm is implemented, and then checks if the algorithm is supported by the current build - that confused me for a bit. It seems unnecessary to check for unimplemented algorithms before looping. That also requires referencing both GZIP and LZ4 in two places. I think it could be written to avoid the need to change for added compression algorithms: + if (te->hadDumper && (te->reqs & REQ_DATA) != 0) + { + /* Check if the compression algorithm is supported */ + pg_compress_specification spec; + parse_compress_specification(AH->compression_spec.algorithm, NULL, &spec); + if (spec->parse_error != NULL) + pg_fatal(spec->parse_error); + } Or maybe add a new function to compression.c to indicate whether a given algorithm is supported. That would also indicate *which* compression library isn't supported. Other than that, I think 001 is ready. 002/003 use these names, which I think are too similar - initially I didn't even realize there were two separate functions (each with a second stub function to handle the case of unsupported compression): +extern void InitCompressorGzip(CompressorState *cs, const pg_compress_specification compression_spec); +extern void InitCompressGzip(CompressFileHandle *CFH, const pg_compress_specification compression_spec); +extern void InitCompressorLZ4(CompressorState *cs, const pg_compress_specification compression_spec); +extern void InitCompressLZ4(CompressFileHandle *CFH, const pg_compress_specification compression_spec); typo: s/not build with/not built with/ Should AllocateCompressor() set cs->compression_spec, rather than doing it in each compressor ? Thanks for considering. -- Justin