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 1mNdS8-0006kE-NM for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Sep 2021 15:56:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mNdS6-0003Ko-Mr for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Sep 2021 15:56:02 +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 1mNdS6-0003Kg-FF for pgsql-hackers@lists.postgresql.org; Tue, 07 Sep 2021 15:56:02 +0000 Received: from feynman.df7cb.de ([195.49.152.168]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mNdS2-0005sY-Ia for pgsql-hackers@postgresql.org; Tue, 07 Sep 2021 15:56:01 +0000 Received: from msg.df7cb.de (unknown [IPv6:2a02:908:1477:c900:2bd8:b2ae:909b:9395]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by feynman.df7cb.de (Postfix) with ESMTPSA id 4H3qcV6xbmz3DyC for ; Tue, 7 Sep 2021 17:55:54 +0200 (CEST) Date: Tue, 7 Sep 2021 17:55:54 +0200 From: Christoph Berg To: PostgreSQL Hackers Subject: VARDATA_COMPRESSED_GET_COMPRESS_METHOD comment? Message-ID: Mail-Followup-To: Christoph Berg , PostgreSQL Hackers MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk In postgres.h, there are these macros for working with compressed toast: vvvvvvvv /* Decompressed size and compression method of an external compressed Datum */ #define VARDATA_COMPRESSED_GET_EXTSIZE(PTR) \ (((varattrib_4b *) (PTR))->va_compressed.va_tcinfo & VARLENA_EXTSIZE_MASK) #define VARDATA_COMPRESSED_GET_COMPRESS_METHOD(PTR) \ (((varattrib_4b *) (PTR))->va_compressed.va_tcinfo >> VARLENA_EXTSIZE_BITS) /* Same, when working directly with a struct varatt_external */ #define VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer) \ ((toast_pointer).va_extinfo & VARLENA_EXTSIZE_MASK) #define VARATT_EXTERNAL_GET_COMPRESS_METHOD(toast_pointer) \ ((toast_pointer).va_extinfo >> VARLENA_EXTSIZE_BITS) On the first line, is the comment "external" correct? It took me quite a while to realize that the first two macros are the methods to be used on an *inline* compressed Datum, when the second set is used for varlenas in toast tables. Context: Me figuring out https://github.com/credativ/toastinfo/blob/master/toastinfo.c#L119-L128 Christoph