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 1pXOlF-0003q9-6K for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Mar 2023 15:52:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pXOlE-0001HX-0w for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Mar 2023 15:52:56 +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 1pXOlD-0001H1-JV for pgsql-hackers@lists.postgresql.org; Wed, 01 Mar 2023 15:52:55 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pXOlA-0006RL-W5 for pgsql-hackers@lists.postgresql.org; Wed, 01 Mar 2023 15:52:54 +0000 Received: by mail-wr1-x42e.google.com with SMTP id t15so13727557wrz.7 for ; Wed, 01 Mar 2023 07:52:52 -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:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ljdp0rrEXrXjD5C5rv2F+1LVqf8iNoT/46pQ4VapRZ8=; b=OgkCphzNhMtJkBPZbnCmRwK7naTn0sp398e++l/I91V+JUjdtJWm9LGaybBJm6NzUX t3fT51LTT+BTEFqK2/0842B1hqSRFoQ2N9MBm0pg0/70Xv6zwvxsdtRtJRlNY4/7kzy0 eLHqK3ZX5stdwkwz0UGsY4x5n4zELXdxyZNQviG59Vif3eEn9cT7DV/5nu0R2biJmg9a IxrnqCtx2sJlGxsN0B8lLMfwDAxOLMJAEZXkHXELt9UtLHVvnkDaRRKwZeZjoNS2BL7H H9pGpsNarMhYcCaM+VkA6AZDyrMHWUwKBF39tq7nSPHat5+y3u9xQMQGWPosXYhJFLdp FhOg== 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:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ljdp0rrEXrXjD5C5rv2F+1LVqf8iNoT/46pQ4VapRZ8=; b=cPcsVh2GFD2jQanx7pPBzgkI+KoaiW7uKuZyrQxoyxT5N/VKH8ocdGAhGhbRIQmeXQ FnyHwYNmzKKAPu1PioOx9w1ovn6hUytYMZfp/3jcxhQBLS0VLzXV3LoS8di+L6x40FCC OR7wwYhjwLp5WAh9q+4onTmAwvSKtDIq8MwpbiDUeV2xElT4OVDO+KQX85tnDHMoIaRS v9fvLXcFE5VtSWvL8npG+dCBoPGtazejT2pgK30K2/3wWHJC0oTZstgLvDPBdINOPPno n24My1Sm0ryf77InLdaEaqEZ9dAunPSvZAOufQSxPZTPRFIh7PP4I3zbTCucdBHaDRTW iPqA== X-Gm-Message-State: AO0yUKU/TYxel1+F0N6SgkwknfmC27M+ljRrp++8gNj6RPzSI8WMmYRf A0WRS5uvkTfB49G6c3OWDpNhZzGLgZ5tvduFWrPPbvX0w9fprcr+JOVzEngSRDW2Bvj2D5YllB3 OTWh/YdISFGCQ/bMnsGozqq6N+7yUdVkkaxjY6H4Lxm4RCAvnXtD940UWJ07emMXgs812wnnPAT m81zUmFcLHcbfB/h1KUIr/W2mW2GfiJnRdKkiPNpxoLa4Vs5lCCt41 X-Google-Smtp-Source: AK7set89W2y3ffVl2smp8nstwGU9oSNN8ZUzDZzH9VA264v7kTFiX8UKzeyPYrPOTlk2dw6SyBXSxw== X-Received: by 2002:adf:f489:0:b0:2c5:58f5:3c40 with SMTP id l9-20020adff489000000b002c558f53c40mr5405544wro.47.1677685970480; Wed, 01 Mar 2023 07:52:50 -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 i5-20020a5d5585000000b002c569acab1esm13031036wrv.73.2023.03.01.07.52.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Mar 2023 07:52:50 -0800 (PST) Message-ID: Date: Wed, 1 Mar 2023 16:52:49 +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 Content-Language: en-US To: gkokolatos@pm.me, Justin Pryzby Cc: shiy.fnst@fujitsu.com, Michael Paquier , pgsql-hackers@lists.postgresql.org, Rachel Heaton References: <20230126062846.GO22427@telsasoft.com> <535565cd-b69f-c064-a845-15c0fc44db4a@enterprisedb.com> <22cb80ed-ec87-54c7-fd5b-cdcf79766bb1@enterprisedb.com> <8421f53d-c9f7-c02e-3278-9f9522a8e8f3@enterprisedb.com> <20230228235834.GC30529@telsasoft.com> From: Tomas Vondra In-Reply-To: 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/1/23 14:39, gkokolatos@pm.me wrote: > > > > > > ------- Original Message ------- > On Wednesday, March 1st, 2023 at 12:58 AM, Justin Pryzby wrote: > > > >> I found that e9960732a broke writing of empty gzip-compressed data, >> specifically LOs. pg_dump succeeds, but then the restore fails: >> >> postgres=# SELECT lo_create(1234); >> lo_create | 1234 >> >> $ time ./src/bin/pg_dump/pg_dump -h /tmp -d postgres -Fc |./src/bin/pg_dump/pg_restore -f /dev/null -v >> pg_restore: implied data-only restore >> pg_restore: executing BLOB 1234 >> pg_restore: processing BLOBS >> pg_restore: restoring large object with OID 1234 >> pg_restore: error: could not uncompress data: (null) >> > > Thank you for looking. This was an untested case. > Yeah :-( >> The inline patch below fixes it, but you won't be able to apply it >> directly, as it's on top of other patches which rename the functions >> back to "Zlib" and rearranges the functions to their original order, to >> allow running: >> >> git diff --diff-algorithm=minimal -w e9960732a~:./src/bin/pg_dump/compress_io.c ./src/bin/pg_dump/compress_gzip.c >> > > Please find a patch attached that can be applied directly. > >> The current function order avoids 3 lines of declarations, but it's >> obviously pretty useful to be able to run that diff command. I already >> argued for not calling the functions "Gzip" on the grounds that the name >> was inaccurate. > > I have no idea why we are back on the naming issue. I stand by the name > because in my humble opinion helps the code reader. There is a certain > uniformity when the compression_spec.algorithm and the compressor > functions match as the following code sample shows. > > if (compression_spec.algorithm == PG_COMPRESSION_NONE) > InitCompressorNone(cs, compression_spec); > else if (compression_spec.algorithm == PG_COMPRESSION_GZIP) > InitCompressorGzip(cs, compression_spec); > else if (compression_spec.algorithm == PG_COMPRESSION_LZ4) > InitCompressorLZ4(cs, compression_spec); > > When the reader wants to see what happens when the PG_COMPRESSION_XXX > is set, has to simply search for the XXX part. I think that this is > justification enough for the use of the names. > I don't recall the previous discussion about the naming, but I'm not sure why would it be inaccurate. We call it 'gzip' pretty much everywhere, and I agree with Georgios there's it helps to make this consistent with the PG_COMPRESSION_ stuff. The one thing that concerned me while reviewing it earlier was that it might make the backpatcheing harder. But that's mostly irrelevant due to all the other changes I think. >> >> I'd want to create an empty large object in src/test/sql/largeobject.sql >> to exercise this tested during pgupgrade. But unfortunately that >> doesn't use -Fc, so this isn't hit. Empty input is an important enough >> test case to justify a tap test, if there's no better way. > > Please find in the attached a test case that exercises this codepath. > Thanks. That seems correct to me, but I find it somewhat confusing, because we now have DeflateCompressorInit vs. InitCompressorGzip DeflateCompressorEnd vs. EndCompressorGzip DeflateCompressorData - The name doesn't really say what it does (would be better to have a verb in there, I think). I wonder if we can make this somehow clearer? Also, InitCompressorGzip says this: /* * If the caller has defined a write function, prepare the necessary * state. Avoid initializing during the first write call, because End * may be called without ever writing any data. */ if (cs->writeF) DeflateCompressorInit(cs); Does it actually make sense to not have writeF defined in some cases? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company