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 1pbQWP-0000ZM-Ks for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Mar 2023 18:34:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pbQWN-0004Zh-AF for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Mar 2023 18:34:15 +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 1pbQWM-0004ZW-O0 for pgsql-hackers@lists.postgresql.org; Sun, 12 Mar 2023 18:34:14 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pbQWF-0003C5-Dc for pgsql-hackers@lists.postgresql.org; Sun, 12 Mar 2023 18:34:13 +0000 Received: by mail-wr1-x42d.google.com with SMTP id r29so1337015wra.13 for ; Sun, 12 Mar 2023 11:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1678646045; 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=1AOCQbCg1OtTqTICp88ZzxeOGirT3akpYUpuGc1qLSQ=; b=NbcT68hnkxkgpD/JqSvCG0n70LW9CY5livfTKBSfpERjidfEwi8vEso3BYb8Fcj1MF u7E4ovyKy6pCkN7we4/y1mZbeWthWVJsarM5hMWO+ddyP53uXcl8aAGGmV2FCCLhht05 w27/HOHqpXC6eHKXt6vPNMfE349KIXLGEQHR2zNAb9CvamMYtx/q7xSNNvhDcsqaTqt0 TdLSIysfOF9txQQ7ZSV3eYdmb63v75JNdEHArR7hdNbr4+fJYsBOyAFRCwsZzgQRoH1B 1QcZ4kGW4hUYZuyb7UjT0CTQQ0mBRoziIWSw4pygHRxlv5Z3PEEe3Gqsr3fQoLQZq8fn 9wmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678646045; 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=1AOCQbCg1OtTqTICp88ZzxeOGirT3akpYUpuGc1qLSQ=; b=tGggxZ5wOAU7Zmkvm5wp9aAvYGRi0brRYZXHjpd7gkooqG3uG+qOYvlXuViGjOyE2t mBdGYXBdtXFK6uF1VHNv68vhXHbFHzHwxgX67DXNfDLZ3Z5MCqRlSSY+G48MFMInD+ls xlHJVqnxeqUec5iuF8nKjr2c3M8CwGWFy3Ye/8X6VV7XlByqvJfkbk11YrYm91/W0VIg hWsMf99Oh49zF9GVLC2NdDCI6j8Q4hIZmrq8+IXlE4XwgTzw8+Ktc75LK3vZgdvUvMjp vaVAvqmSu+XhRLwq7st8sHGaHzitftKKa9ZumJQtPF8UDPbDuevIg3a19f/WbnXHfSZf GLZw== X-Gm-Message-State: AO0yUKWWGOguVH9hfeQnbkNX8joNhXYNN2lTRqA6oMA8xM+EzGIGfPlV qVxZPqJEoFX2aeGDv3IC9IIKE4NamEp/clocv7VCMZxFPT1ushjxj/ItEYM0reC/Kx/NFnbe/pd hAImJdiufsenwmoRFrNvtJ/AcOyNuF+qZCgt5hud6QjeS5NFYHcEC9QnMmFQTUF2v2/OOU2sYYb crjScUC5rfdgtPnW7Xw+IxCtSDC4QBiYo+yWldIK7N9tnV4Yh8+vMk X-Google-Smtp-Source: AK7set8jYBPgGFv+ZPgBZDnEvG3qmrqXAkXqcMI4YPirxby7nkJiYMEEg9KdcBY3VtgWClmEMe5MfQ== X-Received: by 2002:adf:e989:0:b0:2c5:5938:e6d6 with SMTP id h9-20020adfe989000000b002c55938e6d6mr5678753wrm.35.1678646045052; Sun, 12 Mar 2023 11:34:05 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-228-162.bb.vodafone.cz. [86.49.228.162]) by smtp.gmail.com with ESMTPSA id a2-20020a5d53c2000000b002c55ec7f661sm5720082wrw.5.2023.03.12.11.34.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Mar 2023 11:34:04 -0700 (PDT) Message-ID: <8d4c70d8-3212-45fe-ef8e-6b6bb511ace4@enterprisedb.com> Date: Sun, 12 Mar 2023 19:34:02 +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: Peter Eisentraut , Alexander Lakhin , gkokolatos@pm.me Cc: "shiy.fnst@fujitsu.com" , Michael Paquier , Justin Pryzby , "pgsql-hackers@lists.postgresql.org" , Rachel Heaton References: <7zu6GYFi72jByVk2SEe_nd8r1DHhwA35vSntAE9sAfiMX9Lfk6bwimkwmu7GDgYaEvL27SE4qF1uK4_LHWQM4H-SXOwkMAI-GV8PKGmED_E=@pm.me> <6YZqN2HEE4yJxxxXWiMl4QWwKzLon0SdKETTGVkT9zjWnXMftGZjLKHHjGFuwC_5I6xL2s8nMXdLQGA4vEFveYXSHbfD9K9pDQvEJF2y99o=@pm.me> <535565cd-b69f-c064-a845-15c0fc44db4a@enterprisedb.com> <22cb80ed-ec87-54c7-fd5b-cdcf79766bb1@enterprisedb.com> <8421f53d-c9f7-c02e-3278-9f9522a8e8f3@enterprisedb.com> <33496f7c-3449-1426-d568-63f6bca2ac1f@gmail.com> <4336c6e7-df8b-1e96-5408-b16dbc6ca6e0@enterprisedb.com> Content-Language: en-US From: Tomas Vondra In-Reply-To: <4336c6e7-df8b-1e96-5408-b16dbc6ca6e0@enterprisedb.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/12/23 11:07, Peter Eisentraut wrote: > On 11.03.23 07:00, Alexander Lakhin wrote: >> Hello, >> 23.02.2023 23:24, Tomas Vondra wrote: >>> On 2/23/23 16:26, Tomas Vondra wrote: >>>> Thanks for v30 with the updated commit messages. I've pushed 0001 after >>>> fixing a comment typo and removing (I think) an unnecessary change >>>> in an >>>> error message. >>>> >>>> I'll give the buildfarm a bit of time before pushing 0002 and 0003. >>>> >>> I've now pushed 0002 and 0003, after minor tweaks (a couple typos etc.), >>> and marked the CF entry as committed. Thanks for the patch! >>> >>> I wonder how difficult would it be to add the zstd compression, so that >>> we don't have the annoying "unsupported" cases. >> >> With the patch 0003 committed, a single warning -Wtype-limits appeared >> in the >> master branch: >> $ CPPFLAGS="-Og -Wtype-limits" ./configure --with-lz4 -q && make -s -j8 >> compress_lz4.c: In function ‘LZ4File_gets’: >> compress_lz4.c:492:19: warning: comparison of unsigned expression in >> ‘< 0’ is always false [-Wtype-limits] >>    492 |         if (dsize < 0) >>        | >> (I wonder, is it accidental that there no other places that triggers >> the warning, or some buildfarm animals had this check enabled before?) > > I think there is an underlying problem in this code that it dances back > and forth between size_t and int in an unprincipled way. > > In the code that triggers the warning, dsize is size_t.  dsize is the > return from LZ4File_read_internal(), which is declared to return int. > The variable that LZ4File_read_internal() returns in the success case is > size_t, but in case of an error it returns -1.  (So the code that is > warning is meaning to catch this error case, but it won't ever work.) > Further below LZ4File_read_internal() calls LZ4File_read_overflow(), > which is declared to return int, but in some cases it returns > fs->overflowlen, which is size_t. > I agree. I just got home so I looked at this only very briefly, but I think it's clearly wrong to assign the LZ4File_read_internal() result to a size_t variable (and it seems to me LZ4File_gets does the same mistake with LZ4File_read_internal() result). I'll get this fixed early next week, I'm too tired to do that now without likely causing further issues. > This should be cleaned up. > > AFAICT, the upstream API in lz4.h uses int for size values, but > lz4frame.h uses size_t, so I don't know what the correct approach is. Yeah, that's a good point. I think Justin is right we should be using the LZ4F stuff, so ultimately we'll probably switch to size_t. But IMO it's definitely better to correct the current code first, and only then switch to LZ4F (from one correct state to another). regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company