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 1pXne0-0006V1-MI for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2023 18:27:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pXndy-0000Vd-CL for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Mar 2023 18:27:06 +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 1pXndy-0000VQ-28 for pgsql-hackers@lists.postgresql.org; Thu, 02 Mar 2023 18:27:06 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pXndu-0000yJ-K0 for pgsql-hackers@lists.postgresql.org; Thu, 02 Mar 2023 18:27:05 +0000 Received: by mail-ed1-x534.google.com with SMTP id x3so595876edb.10 for ; Thu, 02 Mar 2023 10:27:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6wJP0H17Z4H2Ortp3pFaXS5B/56xgObRSU7YX86bVW4=; b=TivIQUToj6hIWxib5hdU/X231YFvVBv27D55S7tWwATcX6Q3rfax2dNdn0BBghsu12 et8jKw3lJd2ZwVvLslDhV27Uln/mvHUJ+8ku5Jr1ADnsXHusHGHTLhtzggzD84dkd32g QQXUr7ZC2bqVsoZ3o1qzt5vYLyBdK9SmwLMoj5DxEPzf17lmQmqLW0jJJ2DpaGGkzOUr SZ3RZveWWyusKenWbi3ilT1YORBehtLRAatRxBs4KD5zZxhP3sgYjG6A16i7CF0AKttP NJyknOJPrompRB+bKbU202ODcZoIKoGWbu/TrIZgxIvDDvPL6YvpR5X2cSSouvn2h2O2 wzvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6wJP0H17Z4H2Ortp3pFaXS5B/56xgObRSU7YX86bVW4=; b=Hw29oddliNRDiFRQ8K8oFMmkTW3GxHWTGGy7DxOteKAWBVfb4dTo8olLK8605jhKrM waP3t8+x1eN8jTe3rxTCOBjflyyq9QnxbR06xNvVj6HeqChSjgsDg9DzCcHIx9qz3LaM BPYLfI62mlk8V6b9nudbK9DJhlMLO3U9ouNXoaaNlZbpBasroFgwuE/lYqTDSibkrstS bJmwerRq4qCeaeMHJR+87Rw9fGnTJnWa8RM04IOPiTSYUWfc+uYI6eKSa9CEq1WsczUD aHqvK73OTvFXOhkYZxhAVW7nmUwjsIoM801V/8bgxQ3uWzeMLyW9VS0eBxKotUesf9G5 AQuA== X-Gm-Message-State: AO0yUKVJ4UfvVoKIJiqGinGZNhVUVBlwgvnySjwDZa+hqHpN5Z+Wm/e4 xmV4JdoUatxfs1xXcaZl9WP7M1ab/frg7x/Nfh0QnUKgB48/0kvfBScyR8vBKRfoj1ZXt0LrZgK /YM1wS6QKhh/0EUPR0qJ7/gAXZ7yBMRUH5XwT0rmWEnySWi47q6uF2iqTEdxKr7j+NcVX8x8RnJ leToNl9fx5gNWpoD6B7I8Qeel2BD0eSnn9nIv0YgfzxeagSoGXSNhs X-Google-Smtp-Source: AK7set8piR8K8kaNSk/UEc2HSys+EjK4P5sVdc61QiM3gQXsMCyhly9HRJtTPgJv39k3Rl8uKElDMw== X-Received: by 2002:a17:906:ece2:b0:8af:2f5e:93e3 with SMTP id qt2-20020a170906ece200b008af2f5e93e3mr2954912ejb.29.1677781621421; Thu, 02 Mar 2023 10:27:01 -0800 (PST) Received: from [10.137.0.17] (static-84-42-175-93.bb.vodafone.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id hz15-20020a1709072cef00b008b2aba5fb22sm7301762ejc.206.2023.03.02.10.27.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Mar 2023 10:27:01 -0800 (PST) Message-ID: Date: Thu, 2 Mar 2023 19:27:00 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: Add LZ4 compression in pg_dump To: Justin Pryzby Cc: gkokolatos@pm.me, Michael Paquier , shiy.fnst@fujitsu.com, pgsql-hackers@lists.postgresql.org, Rachel Heaton References: <535565cd-b69f-c064-a845-15c0fc44db4a@enterprisedb.com> <22cb80ed-ec87-54c7-fd5b-cdcf79766bb1@enterprisedb.com> <8421f53d-c9f7-c02e-3278-9f9522a8e8f3@enterprisedb.com> <20230224015115.GS1653@telsasoft.com> <20230225050214.GH1653@telsasoft.com> <20230225140553.GI1653@telsasoft.com> <20230302171824.GE4268@telsasoft.com> Content-Language: en-US From: Tomas Vondra In-Reply-To: <20230302171824.GE4268@telsasoft.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/2/23 18:18, Justin Pryzby wrote: > On Wed, Mar 01, 2023 at 05:20:05PM +0100, Tomas Vondra wrote: >> On 2/25/23 15:05, Justin Pryzby wrote: >>> On Fri, Feb 24, 2023 at 11:02:14PM -0600, Justin Pryzby wrote: >>>> I have some fixes (attached) and questions while polishing the patch for >>>> zstd compression. The fixes are small and could be integrated with the >>>> patch for zstd, but could be applied independently. >>> >>> One more - WriteDataToArchiveGzip() says: >>> >>> + if (cs->compression_spec.level == 0) >>> + pg_fatal("requested to compress the archive yet no level was specified"); >>> >>> That was added at e9960732a. >>> >>> But if you specify gzip:0, the compression level is already enforced by >>> validate_compress_specification(), before hitting gzip.c: >>> >>> | pg_dump: error: invalid compression specification: compression algorithm "gzip" expects a compression level between 1 and 9 (default at -1) >>> >>> 5e73a6048 intended that to work as before, and you *can* specify -Z0: >>> >>> The change is backward-compatible, hence specifying only an integer >>> leads to no compression for a level of 0 and gzip compression when the >>> level is greater than 0. >>> >>> $ time ./src/bin/pg_dump/pg_dump -h /tmp regression -t int8_tbl -Fp --compress 0 |file - >>> /dev/stdin: ASCII text >> >> FWIW I agree we should make this backwards-compatible - accept "0" and >> treat it as no compression. >> >> Georgios, can you prepare a patch doing that? > > I think maybe Tomas misunderstood. What I was trying to say is that -Z > 0 *is* accepted to mean no compression. This part wasn't quoted, but I > said: > Ah, I see. Well, I also tried but with "-Z gzip:0" (and not -Z 0), and that does fail: error: invalid compression specification: compression algorithm "gzip" expects a compression level between 1 and 9 (default at -1) It's a bit weird these two cases behave differently, when both translate to the same default compression method (gzip). >> Right now, I think that pg_fatal in gzip.c is dead code - that was first >> added in the patch version sent on 21 Dec 2022. > > If you run the diff command that I've been talking about, you'll see > that InitCompressorZlib was almost unchanged - e9960732 is essentially a > refactoring. I don't think it's desirable to add a pg_fatal() in a > function that's otherwise nearly-unchanged. The fact that it's > nearly-unchanged is a good thing: it simplifies reading of what changed. > If someone wants to add a pg_fatal() in that code path, it'd be better > done in its own commit, with a separate message explaining the change. > > If you insist on changing anything here, you might add an assertion (as > you said earlier) along with a comment like > /* -Z 0 uses the "None" compressor rather than zlib with no compression */ > Yeah, a comment would be helpful. Also, after thinking about it a bit more maybe having the unreachable pg_fatal() is not a good thing, as it will just confuse people (I'd certainly assume having such check means there's a way in which case it might trigger.). Maybe an assert would be better? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company