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 1lGDXM-0002C7-7b for pgsql-hackers@arkaria.postgresql.org; Sun, 28 Feb 2021 04:18:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lGDXK-0003JU-SV for pgsql-hackers@arkaria.postgresql.org; Sun, 28 Feb 2021 04:18:30 +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 1lGDXK-0003JN-Gg for pgsql-hackers@lists.postgresql.org; Sun, 28 Feb 2021 04:18:30 +0000 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lGDXD-0004kG-OU for pgsql-hackers@lists.postgresql.org; Sun, 28 Feb 2021 04:18:29 +0000 Received: by mail-il1-x132.google.com with SMTP id f10so11192693ilq.5 for ; Sat, 27 Feb 2021 20:18:23 -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=o4SNFV/Qh0adsTVI3ELMiFWgve8dJGz2AKkdFEzQVeY=; b=FTItg447FQ5vV0iSGRRoXhEn9KiW+nHnyo6svudrdTVZeX4mHI45jbArJg4FyHJzw0 aKUK2B6+cS7AO96z1xkLj4fX69cjyigWU/cLwzviFVt5KcPdrF+UlYp3Fw6sHe9nfiLz eYSpCcu8FWvcEUKsl/J4dnsV7tYV9TQNzLRRsTMZrZM70ydN88ynTWPaJcFCivGuHvNY ymUEIUCAwxh20ASL35Mvx9H0/hhg2+wVIKAgBbmb4X2ZFxu5/N8jeCYPRb1g1XduoKkn eXtS7lwRepwlaIcVpJrccn/54T0yN7fq1A9hk9+px1vvgy6BwhAp58YPGAMoBZVr9gwG dMPA== 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=o4SNFV/Qh0adsTVI3ELMiFWgve8dJGz2AKkdFEzQVeY=; b=VvKi4DlGM7Jn40ah8ANHhPJ7JdMnFd6p6HqpQgaw1wk4d1lwQp4GcXfCq+eC+cS5AS KaB29w5GrQOzDDNIpjt9dTzyGDiiR/RvoJUVreASjDGLo2QXnLzRr2caDmRLrkMm46iY AlLwW084cG4ImtUT6KtLsvbagChTgmoaVyoj8QurraOYilR/AJCBYLSoVSFfcU9K427Z UDQiLWjCJvsduS4lU3I3SrJr6A/VQnscEIYvFhuw8CFN5x2kF4HQPUCl5GQHx0HqMG8e SCqqHLz5y4jV4MKSzjaGKlTyr8Tpds/Q9hiK1jw5IejPVqNYkkzZpPcF/e7myFajlj1i v5+Q== X-Gm-Message-State: AOAM5315FLDEnwiMXQeriF4in/46z+EuiI7SVZYqcBnG/vrKvAKD3huR 8gm9dKLPh8J46q/VUz7FD9+Ymg== X-Google-Smtp-Source: ABdhPJyhEi/Ye0yW2f7UM0SJQW44viWokUpi1JZX2iRUBn+Xq6eLLLnnEUPiPS+XDuS2DR1IngcnwA== X-Received: by 2002:a92:8bcf:: with SMTP id i198mr8621274ild.152.1614485903089; Sat, 27 Feb 2021 20:18:23 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id k14sm6246071iob.34.2021.02.27.20.18.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Feb 2021 20:18:22 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 5326580108A; Sat, 27 Feb 2021 22:18:21 -0600 (CST) Date: Sat, 27 Feb 2021 22:18:21 -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: <20210228041821.GB20769@telsasoft.com> References: <20210214184940.GL1793@telsasoft.com> <20210214202831.GM1793@telsasoft.com> <20210218211314.GC14772@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 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 @@ -119,15 +119,15 @@ lz4_cmdecompress_slice(const struct varlena *value, int32 slicelength) int32 rawsize; struct varlena *result; - /* allocate memory for holding the uncompressed data */ - result = (struct varlena *) palloc(VARRAWSIZE_4B_C(value) + VARHDRSZ); + /* allocate memory for the uncompressed data */ + result = (struct varlena *) palloc(slicelength + VARHDRSZ); - /* decompress partial data using lz4 routine */ + /* decompress the data */ rawsize = LZ4_decompress_safe_partial((char *) value + VARHDRSZ_COMPRESS, VARDATA(result), VARSIZE(value) - VARHDRSZ_COMPRESS, slicelength, - VARRAWSIZE_4B_C(value)); + slicelength); Also, in the tests, you have this at both the top and bottom of the file: src/test/regress/sql/compression.sql:\set HIDE_COMPRESSAM false src/test/regress/sql/compression.sql:\set HIDE_COMPRESSAM false Whereas the patch I sent had at the end: +\set HIDE_COMPRESSAM on ("on" is the default when run under pg_regress)