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 1pKk4U-0007kG-Rb for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jan 2023 18:00:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pKk4T-0003y0-FY for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Jan 2023 18:00:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pKk4T-0003xr-0g for pgsql-hackers@lists.postgresql.org; Wed, 25 Jan 2023 18:00:29 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pKk4O-0005wH-NY for pgsql-hackers@lists.postgresql.org; Wed, 25 Jan 2023 18:00:26 +0000 Received: by mail-il1-x12e.google.com with SMTP id b15so6931827ils.11 for ; Wed, 25 Jan 2023 10:00:24 -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=jatvmOn34QYRPaD9HMWrD9jXR1a65/cfR1IIqEtJnt8=; b=dsFzKZwcaMlZ3kriLL1GjlNACc6vkuPoW80U1ZnrHgEDXOpKWgFkqWvq6krCafmvSz XZocnONDT7S3u7iknnhMfNdO27eQOYeykZO8E35TfkeMjuTqWW7ep2uOzfit0V/o9pat gml16NmSvXloRKDbkTDnI30B8dQAgmDdoe4y8gyyTJFKzmeGDqKPIoc/d3wSgPJATD6q BoKyQ4YAuxvNUpotnL3ihhFAkFQih7W3Ob16Sz2x4Mo6Fxvu8ZIJSBtAW1r3sPNkCQS2 MTW1DPzi3ptW7dG5wBnYtMw0DyQCJ9fD3crZcSGBYZ+j+dHtqveAu/6b4oPZ4HSTJmSg Ux8g== 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=jatvmOn34QYRPaD9HMWrD9jXR1a65/cfR1IIqEtJnt8=; b=WyM7EQClqPk9I0ZIcuHyf7ntsRfS0xklVzPzgUj8F+ZcoXLg+PcnNykkeLnsKuz4Av 9xKGk4Ke0b12QrOHXwAo8VDO5sCqOgodoesqr+1NxN6/6XFsEFYFYw8wr6QrDxyUXfNp ZcblYtBOqtfRGfppX0jP0PTz2Gofjf0wat+buQ3X5SnkDmaIwI4HIKJjqmurC0722Ix0 ZZgYB1hUy4vSzGucofPAIPAG8wKZComOuREuCrRi3BSnTRil962fkHnzRafwJgTwen43 s0qn/eq3dFg9m6izABTolnEM4Q05hTMJJhO9FNnTayyG09jRZA2hXKfwzjzog7c4rnK6 MOFQ== X-Gm-Message-State: AO0yUKVAO0mMJk5DSZuGhOakfPkcK/KBLv8twA26koMUZyfax6rC8cLp Toce2Ak7ZrFZKIGZYHnriFwSdw== X-Google-Smtp-Source: AK7set/O0GjX3pIgHCONbL1g6AW/kvwSB9V1Y5SbU+sfIYkFZ4uwQtAL1w0sftvk4wwDf5tdRrRyUw== X-Received: by 2002:a05:6e02:1a6d:b0:310:a8aa:8a50 with SMTP id w13-20020a056e021a6d00b00310a8aa8a50mr1733476ilv.26.1674669622600; Wed, 25 Jan 2023 10:00:22 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id t11-20020a056e02010b00b0031097a03904sm1358636ilm.32.2023.01.25.10.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 10:00:21 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id AF964800CA9; Wed, 25 Jan 2023 12:00:20 -0600 (CST) Date: Wed, 25 Jan 2023 12:00:20 -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: <20230125180020.GF22427@telsasoft.com> References: <6ab89d42-0345-b96e-02d4-68e171cdbe03@enterprisedb.com> <7zu6GYFi72jByVk2SEe_nd8r1DHhwA35vSntAE9sAfiMX9Lfk6bwimkwmu7GDgYaEvL27SE4qF1uK4_LHWQM4H-SXOwkMAI-GV8PKGmED_E=@pm.me> <20230123180014.GX13860@telsasoft.com> <20230125014203.GL13860@telsasoft.com> <-myGeDiZ-ePDRyi18026Iu2HTTfmwfjWaJn4OWJ2F3oglZUfJTOQ7FARPW7gYxE4vK3b0HpwYoiHR45nfOWReRvvJZfCBfJzPP5iJyn4muk=@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <-myGeDiZ-ePDRyi18026Iu2HTTfmwfjWaJn4OWJ2F3oglZUfJTOQ7FARPW7gYxE4vK3b0HpwYoiHR45nfOWReRvvJZfCBfJzPP5iJyn4muk=@pm.me> 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 Wed, Jan 25, 2023 at 03:37:12PM +0000, gkokolatos@pm.me wrote: > Of course, one can throw the error before entering the loop, yet I think > that it does not help the readability of the code. IMHO it is easier to > follow if the error is thrown once during that check. > If anything, I can suggest to throw an error much earlier, i.e. in ReadHead(), > and remove altogether this check. On the other hand, I like the belts > and suspenders approach because there are no more checks after this point. While looking at this, I realized that commit 5e73a6048 introduced a regression: @@ -3740,19 +3762,24 @@ ReadHead(ArchiveHandle *AH) - if (AH->compression != 0) - pg_log_warning("archive is compressed, but this installation does not support compression -- no data will be available"); + if (AH->compression_spec.algorithm == PG_COMPRESSION_GZIP) + pg_fatal("archive is compressed, but this installation does not support compression"); Before, it was possible to restore non-data chunks of a dump file, even if the current build didn't support its compression. But that's now impossible - and it makes the code we're discussing in RestoreArchive() unreachable. I don't think we can currently test for that, since it requires creating a dump using a build --with compression and then trying to restore using a build --without compression. The coverage report disagrees with me, though... https://coverage.postgresql.org/src/bin/pg_dump/pg_backup_archiver.c.gcov.html#3901 > > I think it could be written to avoid the need to change for added > > compression algorithms: ... > > I am not certain how that would work in the example with ZSTD above. > If I am not wrong, parse_compress_specification() will not throw an error > if the codebase supports ZSTD, yet this specific pg_dump binary will not > support it because ZSTD is not implemented. parse_compress_specification() > is not aware of that and should not be aware of it, should it? You're right. I think the 001 patch should try to remove hardcoded references to LIBZ/GZIP, such that the later patches don't need to update those same places for LZ4. For example in ReadHead() and RestoreArchive(), and maybe other places dealing with file extensions. Maybe that could be done by adding a function specific to pg_dump indicating whether or not an algorithm is implemented and supported. -- Justin