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 1lGbEM-0003eX-Ov for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Mar 2021 05:36: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 1lGbEJ-0007zG-VU for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Mar 2021 05:36:27 +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 1lGbEJ-0007yX-2c for pgsql-hackers@lists.postgresql.org; Mon, 01 Mar 2021 05:36:27 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lGbEB-0007fO-NW for pgsql-hackers@lists.postgresql.org; Mon, 01 Mar 2021 05:36:25 +0000 Received: by mail-il1-x133.google.com with SMTP id k2so13620867ili.4 for ; Sun, 28 Feb 2021 21:36:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=yUPtmaFUxJbtOzb2KtBYbNG01SBqymPHoIMvrnceHOU=; b=bBPfPUr1NWmRDGGDpQfCB7oaGzOsgw9V7usjndVWbN96t/malCwNtWeZn0oCNRN44k 30ewynHgr4fMX/aS3ipVX1UFMWEL3rdPZE77ZJC4j9YIcU+xKPM5bCCXvWyKQZHkky0q 8lEtrkx2f/F0sQTu4g1GpnN7wm2+GQnIo5bEBOmKVvGOcw+vhHiZvUB14nAmXeI7o2A3 tOcbxsXOGnAec4UUXaoc4QJlHqFny1hn2qXIhfPRuJtEEDFSWTuOBLvQTnzNmvzmmk74 208Ah1YSvPFmU8fmaqZiVrnq5pOuE3aQRD6LexnjEJM0tztdFc34iW6NXoqHvziwKGLz B3Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=yUPtmaFUxJbtOzb2KtBYbNG01SBqymPHoIMvrnceHOU=; b=BH808jDR+rogWFl+lX3S0Jk4KZ/hudWpDtktFumaElbSF6QHbKk+99xZ2/COWJN4NB nfsWZt+2AIzC1ccqPQmzg7EJmCgX2nrt0q7V8efGOkMwE2I101faR0wPyq3vwHQtlpk8 k586Gh1Yz5Bz8UtQ687z5XGcZ2zONPTGSxJBjKaE80XW5EdMZ8+msQ2f4mP2XIpfeyoj 8b+q77Omgoofbt+s7xi4GmuuqwiTNo8eWH7hY8FIK/u3MIoL4D4+G19vfUEfJ0GZoIEE ooy5z/nYiN5PxEMQPfWwO3RHI/Ri/R5ia5cFFOzZCWGGsAZM2wcIpulkP9YMjZ6ln9Bi oiLA== X-Gm-Message-State: AOAM53105UAfwlglWEBWu9m6W+8p1721Jhz0YRliMZpnOh27qHyyAZ+p t78RwZ27glG8zbdc4/iN8bGMYw== X-Google-Smtp-Source: ABdhPJxtMLUeb631MgubnjlVhgkt50UxhLXv7+GJ1Y2K9CboHJv06PdLAFEsxVGhLILfAZ9BD6qXQA== X-Received: by 2002:a92:4a10:: with SMTP id m16mr3412186ilf.240.1614576978841; Sun, 28 Feb 2021 21:36:18 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id m5sm5479279ilq.65.2021.02.28.21.36.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Feb 2021 21:36:18 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 5A8D5801079; Sun, 28 Feb 2021 23:36:17 -0600 (CST) Date: Sun, 28 Feb 2021 23:36:17 -0600 From: Justin Pryzby To: Dilip Kumar Cc: Robert Haas , Tomas Vondra , Alexander Korotkov , David Steele , Ildus Kurbangaliev , Dmitry Dolgov <9erthalion6@gmail.com>, pgsql-hackers@lists.postgresql.org Subject: Re: [HACKERS] Custom compression methods Message-ID: <20210301053617.GA3701@telsasoft.com> References: <20210218211314.GC14772@telsasoft.com> <20210228041821.GB20769@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: Precedence: bulk On Mon, Mar 01, 2021 at 10:32:23AM +0530, Dilip Kumar wrote: > On Sun, Feb 28, 2021 at 9:48 AM Justin Pryzby wrote: > > > > On my PC, this new change is causing a test failure: > > > > SELECT SUBSTR(f1, 2000, 50) FROM cmdata1; > > - substr > > ----------------------------------------------------- > > - 01234567890123456789012345678901234567890123456789 > > -(1 row) > > - > > +ERROR: compressed lz4 data is corrupt > > The older version of lz4 had this problem that while decompressing > partial if we don't give the buffer size up to full data length it was > failing[1] but it is solved in version 1.9. Thanks. It seems like that explains it. I think if that's a problem with recent versions, then you'll have to conditionally disable slicing. https://packages.debian.org/liblz4-dev Slicing isn't generally usable if it sometimes makes people's data inaccessible and gives errors about corruption. I guess you could make it a compile time test on these constants (I don't know the necessary version, though) #define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */ #define LZ4_VERSION_MINOR 7 /* for new (non-breaking) interface capabilities */ #define LZ4_VERSION_RELEASE 1 /* for tweaks, bug-fixes, or development */ #define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE) If the version is too low, either make it #error, or disable slicing. The OS usual library version infrastructure will make sure the runtime version is at least the MAJOR+MINOR of the compile time version. -- Justin