Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vaMwF-007XFb-0y for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 23:46:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vaMwE-00187W-0M for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Dec 2025 23:46:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vaMwD-00187O-2I for pgsql-hackers@lists.postgresql.org; Mon, 29 Dec 2025 23:46:10 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vaMwC-003Fil-21 for pgsql-hackers@lists.postgresql.org; Mon, 29 Dec 2025 23:46:09 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 9A15F1D00084; Mon, 29 Dec 2025 18:46:06 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Mon, 29 Dec 2025 18:46:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1767051966; x=1767138366; bh=SYz7KEoKbZ 7rqg6WCaAn2qF6znSZjNcyZYj4KBaNTRc=; b=kMwOlHFhBua3fG1CTMwZFsAQOA eb5rc9/uGrFndj9cZSyZeZkBrVDKPK7jjoNtDdnzErXBTcBBSO3Mkt6egHAPkpsm jEYqRFsK6dPFSpdr2tld9GknnAxtBqYlFfF/Y2Ia7umLkLoIxldU30aKAFXmYQgi Kti9vSwO8rSsakU36Yowl0Z1EH3IC+pMrgp+4sVRLvYiyF1omVfIKcTe7hp5kKrt 2pk/Mv6xi1tQT07Wbi0fFQT9pob1+CKmJe73iOF8PkNfTfCdERvwMDBEpheImfUV GF7BG59+h4JNmnzh+9VhM42O0IRhNzYbITv8C04s2vT6hKlphpHA9Xvn6VhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1767051966; x=1767138366; bh=SYz7KEoKbZ7rqg6WCaAn2qF6znSZjNcyZYj 4KBaNTRc=; b=OlG3IVAD0J9XYFO1+S3pX17kmmgU/HB3of6nldhTctuSLWiFT9U JFvqJMwNVXsJ1snPDob4IJXa4x4zYwxbeSbh8S9QL7UrFK//vWCTuLA5uWDz/z+P /6ZfjqsNMEZQqUjFj+K4DRPWqCeX9tfstIoTNNX8s4BvL2hVlMooLpMUNI0DVtT2 deb4hjtG/+ZtVsxnhdCjOGK7Tmv5ke1PK+QCg7dmbwONpBelkwaKtmdrR1OKwq03 ll4vDu/Vu17t9pucNJB4GCKnRZX9z9glDJM7H6OVeNh4l0xg2DeV0bZUD2amAXSN ujLFS0pfJo/M2L1SrZxU+9gKCb723V2Kr4A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdejkeehtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtjeen ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeevteejgfejveegudekheeiueeiueei veeuiedugeehveeugffgudeuleegleeiteenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeegpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeguhhgrrh hinhhshhgrhhelheesghhmrghilhdrtghomhdprhgtphhtthhopehrohgsseigiihilhhl rgdrnhgvthdprhgtphhtthhopehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdprh gtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhq lhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Dec 2025 18:46:04 -0500 (EST) Date: Tue, 30 Dec 2025 08:45:47 +0900 From: Michael Paquier To: Dharin Shah Cc: Robert Treat , Peter Eisentraut , pgsql-hackers@lists.postgresql.org Subject: Re: Fwd: [PATCH] Add zstd compression for TOAST using extended header format Message-ID: References: <4c70b0f6-5aba-464c-b145-464a620c1222@eisentraut.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="QOmSrVUgh/TzW+xL" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --QOmSrVUgh/TzW+xL Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 29, 2025 at 02:45:27PM +0100, Dharin Shah wrote: > The goal is to centralize =E2=80=9Chow do we interpret an external datum?= =E2=80=9D so that > detoast code paths don=E2=80=99t have to reason directly about va_extinfo= encoding > vs payload layout details. This is intended as groundwork for a follow-up > patch adding a new vartag-based method (e.g., zstd) without scattering > special cases in detoast paths. +static bool +decode_external_toast_pointer(const struct varlena *attr, + DecodedExternalToast *decoded) [...] +typedef enum ToastDecompressMethod +{ + TOAST_DECOMP_NONE =3D 0, + TOAST_DECOMP_PGLZ =3D 1, + TOAST_DECOMP_LZ4 =3D 2 +} ToastDecompressMethod; + +typedef struct DecodedExternalToast +{ + Oid toastrelid; + Oid valueid; + uint32 rawsize; /* Decompressed size; for future methods without tcinfo= */ + uint32 extsize; /* On-disk payload size */ + ToastDecompressMethod method; + uint8 flags; +} DecodedExternalToast; Yeah, honestly this is a layer I have been thinking about as well as one option, but contrary to you I have been focusing on putting that into varatt.h, with the exception of the value being an Oid8. I think that you have an interesting point in focusing your implementation to be stored in the detoast part, though. I'd need to spend a bit more time to see the result this would lead at with the larger 8-byte issue in mind, but this is something that would come at no real cost as it has no function pointer redirection compared to what I was first envisioning on the other thread. That's especially true if it makes the CompressionId business easier to mold around when adding a new vartag. > Why HAS_TCINFO? > - Previously, =E2=80=9Cis compressed?=E2=80=9D was used as a proxy for wh= ether the external > payload begins with tcinfo. This patch makes that explicit: HAS_TCINFO > captures payload layout, which is distinct from whether the value is > compressed. This separation is needed for future methods that may store > external compressed payloads without tcinfo. It is possible to model the on-memory data as we want. This suggestion would be OK with some flags. -- Michael --QOmSrVUgh/TzW+xL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmlTEqsACgkQnvQgOdby QH1GHQ//eNxwep1/7ED1nHcUQV2bo9+0kRxZiwZ3uOST5+5U3jlZjs44SEefYo/w tO6GXe95nBbVp+lCwFnFvB8XMpdaS62pA9Oe8/wYhLhGSbvl/wPe1+Ry4Sp59iH1 mO2sh8AdVcdCHmOPkGcECt7s7GafS3p1nzn5qj+OrG9r9XKusxEygcwejr/K62rn ncrkrs1ViXqklZDDy7b/c10XQnsq7kPN2iJ0mH1XttDJ3Jb3xnYoqCAV8gLkgSpt xvSFRTawxV3BqIlAJeemcL3oezyKYW8RxBL0G/PYX8uL6tfhzLc37Tkq4LtYK6pe fTTNGJZdd5suNBBwhs8Kj9b7l5FUkdaf/OiSTA1PA5l+USevjf0aCOCd6Y/9EZza ukzTqhpTXcIgRZ5is7SrxAW1mr6jU1YhYBKgpldQfrgoooJV/Ruhctv6mjzDQ+pJ DlB24L8yo9uJSwxTg/5Z+go+EpCOR44Qag3TKGAYlMqnQDV6L2gw248/ShIIbl4z 327iM8dTH/H3/FV1lO5d6zhQt3P+grxQcSWsa3rwN8Bz4HYqNDXG/Nbar5NtiZph irqXk9So8I7g49J/HwFszPvin93mXDjILZLkoHpnTwaVn66xkUJ+/eoHyt1jXosV nFUnTqe0Kfw3zIjFDF+TNK3jYdHyOWVzU2DGiwMe0VkiOyVjaAM= =UIeH -----END PGP SIGNATURE----- --QOmSrVUgh/TzW+xL--