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 1x2Ibd-005h3L-1G for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Sep 2026 01:20:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x2Ibc-003WcD-1F for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Sep 2026 01:20:36 +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 1x2Ibb-003WBs-0b for pgsql-hackers@lists.postgresql.org; Fri, 04 Sep 2026 01:20:36 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x2IbY-00000003tmf-0XpI for pgsql-hackers@lists.postgresql.org; Fri, 04 Sep 2026 01:20:34 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 9421B7A01A9; Thu, 3 Sep 2026 21:20:30 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Thu, 03 Sep 2026 21:20:30 -0400 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=fm1; t=1788484830; x=1788571230; bh=UarZ/jOH8A OTrkJpYp7tn2spSJvUi9Q2oAoU5CleQX8=; b=Qv9N7yLnhnm3f9+nI3RF14tGyp 8A2zpDmV2p3vXC4tE+IsKTscEsrpyEDR316KEY69hvLQpmpWay5qIUqBDHTO3Hb6 2OYJTlCEWTm4QmTNLVtUwMAlUH1RAQ3TOpkQBLhio0UtSDNjGuom6nNu45xQkKF9 jJgnVBtuI/KyJmDsC1i3DVCCQhZL0QQ6wwE80weBEb+oBAxUpL/oTaAwxBn0W8Jk r+2lEvhuBWqEXxFyfDN/99kdzfzm2NkVo3UsZtHEx0U9dTxrhURdc9k3Vg+F4TM5 gCBF836Zr67VphjfUWWbiTutqzMrZ2vMZshqPkrgOW7uvO4dMJzp+oJ+LyFA== 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=fm1; t= 1788484830; x=1788571230; bh=UarZ/jOH8AOTrkJpYp7tn2spSJvUi9Q2oAo U5CleQX8=; b=aq9MqnavM9Uh5YtPn2ADhUMnnFFXx/lMwvRu5ZnVdJrw1xhCT6P PQHjXwYLs6zPejRGmhd1zgsYlGvF6D7gZsGKPwbuIALAb6U9aHDzaAlzqBidooEK QmO/rw3pACiv8WdjM4toy8kbQpSMrQDkaczfb77+X5jNsGAH8+k+I0LkqP8XQA6Y BA1wZ4Nla00Hdmmi+DmXgCJKSoLAJXTLXiPp2X0ZcEU6o8OgzVoXSaT7d2DHx/uS 5jlPfZWMALxgeX+zI+mzhXPBPLO49qfRABF8v+h1OVmBHFVwas6/NS2gCRqN2AzZ 3hJjlHG7oMHVLLGC7JDlBFmO1soog7eLt9w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGFTF+CIyzsT9fCqYEj/mrJKgW3bZ6aO+LhnvZ5B7LtPU4f12Uu1miSn1PHuSi6qR YPnw9q+7/8ALe9ZOxGo1OJuXf4yovvviFFYFR216on9ZIaeaURYCZgPgtNoJfI+n5GPxJT EBTIS5UAB5W31gj15HTUrmVlLoy1ua8S226oe2aBC3f4Sd75OhLKEAt4ZX8KWDkgTwsRtx XLl4PwXC4fE5CG+p34GqtJ6eXedWmRKmyBui2dBOBfk7IblR3BvYYD1xCyEOeVsD/GjFTT /s1r+7uWhTyw0QBsC/m/CYbjeu4CtSvvtWq9ZZoQBeIyMKOgCgh9iKTvQ1TfSm3+Zxikok 6IlSRM/8NCn6D+dsDrZ98GUFDUPygzHV9emMdiJI86j/PNSEtN/bityPZler7NhiyS9fgE dF1MIeTc9S8edkgMYSuuldhxjEam7f1o50KwFWhtR7K4i2JkO0kc85Gb+U+1/4ZCJDcfBs rMG4oXuwL8pK6gV9DgU7G4G4lr1k5nSO1h/hHfEu/4lvRxhi3lYzoZFA2oJWYwfqwVyNO5 P1OT4mRgzSftnXxdoT5+dOrrXwikNQmZIsRmP6hHIVrkHLZnnORHdPWrnrXSMZxa4ScPIO B5oGOctyCXE+4G3LQ03Z9aYHqJNWfF3jAp3NENyeo/1oxgjIz8RJ9n5bFZGQ X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 3 Sep 2026 21:20:23 -0400 (EDT) Date: Fri, 4 Sep 2026 10:20:18 +0900 From: Michael Paquier To: Chao Li Cc: Postgres hackers , Tom Lane , Andres Freund Subject: Re: Rename of varatt_external to varatt_external_oid Message-ID: References: <1B63EFC9-93D5-4197-8D12-181D8F55ACA5@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JhDV7fXbwmwHOuxh" Content-Disposition: inline In-Reply-To: <1B63EFC9-93D5-4197-8D12-181D8F55ACA5@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --JhDV7fXbwmwHOuxh Content-Type: multipart/mixed; boundary="Mvrusdn1hTsRFd8y" Content-Disposition: inline --Mvrusdn1hTsRFd8y Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 04, 2026 at 08:43:37AM +0800, Chao Li wrote: > I tried to review this patch, but =E2=80=9Cgit am=E2=80=9D failed on the = current > HEAD (2b3d11aaed8). Would you please rebase? Oops. Sorry for the incorrect rebase blurp caused by 2b3d11aaed89. The attached should work better. -- Michael --Mvrusdn1hTsRFd8y Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v2-0001-Rename-varatt_external-to-varatt_external_oid.patch Content-Transfer-Encoding: quoted-printable =46rom f77b51e169c472d6f3c2f1eca54f50b043faa6e1 Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier Date: Fri, 4 Sep 2026 08:29:08 +0900 Subject: [PATCH v2] Rename varatt_external to varatt_external_oid This impacts a few more definitions, related to this structure, as of: - VARTAG_ONDISK -> VARTAG_ONDISK_OID - TOAST_POINTER_SIZE -> TOAST_OID_POINTER_SIZE - TOAST_MAX_CHUNK_SIZE -> TOAST_OID_MAX_CHUNK_SIZE - Macros in varatt.h for varatt_external_oid. This rename is in preparation of a follow-up patch to add support for 8-byte TOAST values, where we need to make the distinction between the OID and OID8 variants. Author: Michael Paquier Reviewed-by: Yugo Nagata Reviewed-by: Bharath Rupireddy Discussion: https://postgr.es/m/CALj2ACVnO6jjs5aRx3dSOBy9LV7=3DiakPBR1eOvoe= B8rL8Q47zg@mail.gmail.com --- src/include/access/detoast.h | 4 +-- src/include/access/heaptoast.h | 6 ++-- src/include/varatt.h | 36 ++++++++++--------- src/backend/access/common/detoast.c | 30 ++++++++-------- src/backend/access/common/toast_compression.c | 6 ++-- src/backend/access/common/toast_internals.c | 16 ++++----- src/backend/access/heap/heaptoast.c | 2 +- src/backend/access/table/toast_helper.c | 4 +-- src/backend/access/transam/xlog.c | 8 ++--- .../replication/logical/reorderbuffer.c | 6 ++-- src/backend/utils/adt/varlena.c | 2 +- src/bin/pg_resetwal/pg_resetwal.c | 2 +- doc/src/sgml/storage.sgml | 2 +- contrib/amcheck/verify_heapam.c | 14 ++++---- src/tools/pgindent/typedefs.list | 2 +- 15 files changed, 72 insertions(+), 68 deletions(-) diff --git a/src/include/access/detoast.h b/src/include/access/detoast.h index fbd98181a3a1..2b1428b1e81c 100644 --- a/src/include/access/detoast.h +++ b/src/include/access/detoast.h @@ -14,7 +14,7 @@ =20 /* * Macro to fetch the possibly-unaligned contents of an EXTERNAL datum - * into a local "varatt_external" toast pointer. This should be + * into a local "varatt_external_oid" toast pointer. This should be * just a memcpy, but some versions of gcc seem to produce broken code * that assumes the datum contents are aligned. Introducing an explicit * intermediate "varattrib_1b_e *" variable seems to fix it. @@ -28,7 +28,7 @@ do { \ } while (0) =20 /* Size of an EXTERNAL datum that contains a standard TOAST pointer */ -#define TOAST_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(varatt_external)) +#define TOAST_OID_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(varatt_external= _oid)) =20 /* Size of an EXTERNAL datum that contains an indirection pointer */ #define INDIRECT_POINTER_SIZE (VARHDRSZ_EXTERNAL + sizeof(varatt_indirect)) diff --git a/src/include/access/heaptoast.h b/src/include/access/heaptoast.h index 631cb1836b96..b2346fd75bd4 100644 --- a/src/include/access/heaptoast.h +++ b/src/include/access/heaptoast.h @@ -69,19 +69,19 @@ =20 /* * When we store an oversize datum externally, we divide it into chunks - * containing at most TOAST_MAX_CHUNK_SIZE data bytes. This number *must* + * containing at most TOAST_OID_MAX_CHUNK_SIZE data bytes. This number *m= ust* * be small enough that the completed toast-table tuple (including the * ID and sequence fields and all overhead) will fit on a page. * The coding here sets the size on the theory that we want to fit * EXTERN_TUPLES_PER_PAGE tuples of maximum size onto a page. * - * NB: Changing TOAST_MAX_CHUNK_SIZE requires an initdb. + * NB: Changing TOAST_OID_MAX_CHUNK_SIZE requires an initdb. */ #define EXTERN_TUPLES_PER_PAGE 4 /* tweak only this */ =20 #define EXTERN_TUPLE_MAX_SIZE MaximumBytesPerTuple(EXTERN_TUPLES_PER_PAGE) =20 -#define TOAST_MAX_CHUNK_SIZE \ +#define TOAST_OID_MAX_CHUNK_SIZE \ (EXTERN_TUPLE_MAX_SIZE - \ MAXALIGN(SizeofHeapTupleHeader) - \ sizeof(Oid) - \ diff --git a/src/include/varatt.h b/src/include/varatt.h index 000bdf33b923..33979bbaaad1 100644 --- a/src/include/varatt.h +++ b/src/include/varatt.h @@ -16,7 +16,7 @@ #define VARATT_H =20 /* - * varatt_external is a traditional "TOAST pointer", that is, the + * varatt_external_oid is a traditional "TOAST pointer", that is, the * information needed to fetch a Datum stored out-of-line in a TOAST table. * The data is compressed if and only if the external size stored in * va_extinfo is less than va_rawsize - VARHDRSZ. @@ -29,14 +29,14 @@ * you can look at these fields! (The reason we use memcmp is to avoid * having to do that just to detect equality of two TOAST pointers...) */ -typedef struct varatt_external +typedef struct varatt_external_oid { int32 va_rawsize; /* Original data size (includes header) */ uint32 va_extinfo; /* External saved size (without header) and * compression method */ Oid va_valueid; /* Unique ID of value within TOAST table */ Oid va_toastrelid; /* RelID of TOAST table containing it */ -} varatt_external; +} varatt_external_oid; =20 /* * These macros define the "saved size" portion of va_extinfo. Its remain= ing @@ -51,7 +51,7 @@ typedef struct varatt_external * The creator of such a Datum is entirely responsible that the referenced * storage survives for as long as referencing pointer Datums can exist. * - * Note that just as for varatt_external, this struct is stored + * Note that just as for varatt_external_oid, this struct is stored * unaligned within any containing tuple. */ typedef struct varatt_indirect @@ -66,7 +66,7 @@ typedef struct varatt_indirect * storage. APIs for this, in particular the definition of struct * ExpandedObjectHeader, are in src/include/utils/expandeddatum.h. * - * Note that just as for varatt_external, this struct is stored + * Note that just as for varatt_external_oid, this struct is stored * unaligned within any containing tuple. */ typedef struct ExpandedObjectHeader ExpandedObjectHeader; @@ -78,15 +78,16 @@ typedef struct varatt_expanded =20 /* * Type tag for the various sorts of "TOAST pointer" datums. The peculiar - * value for VARTAG_ONDISK comes from a requirement for on-disk compatibil= ity - * with a previous notion that the tag field was the pointer datum's lengt= h. + * value for VARTAG_ONDISK_OID comes from a requirement for on-disk + * compatibility with a previous notion that the tag field was the pointer + * datum's length. */ typedef enum vartag_external { VARTAG_INDIRECT =3D 1, VARTAG_EXPANDED_RO =3D 2, VARTAG_EXPANDED_RW =3D 3, - VARTAG_ONDISK =3D 18 + VARTAG_ONDISK_OID =3D 18 } vartag_external; =20 /* Is a TOAST pointer either type of expanded-object pointer? */ @@ -105,8 +106,8 @@ VARTAG_SIZE(vartag_external tag) return sizeof(varatt_indirect); else if (VARTAG_IS_EXPANDED(tag)) return sizeof(varatt_expanded); - else if (tag =3D=3D VARTAG_ONDISK) - return sizeof(varatt_external); + else if (tag =3D=3D VARTAG_ONDISK_OID) + return sizeof(varatt_external_oid); else { Assert(false); @@ -360,7 +361,7 @@ VARATT_IS_EXTERNAL(const void *PTR) static inline bool VARATT_IS_EXTERNAL_ONDISK(const void *PTR) { - return VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) =3D=3D VARTAG_ONDI= SK; + return VARATT_IS_EXTERNAL(PTR) && VARTAG_EXTERNAL(PTR) =3D=3D VARTAG_ONDI= SK_OID; } =20 /* Is varlena datum an indirect pointer? */ @@ -502,15 +503,18 @@ VARDATA_COMPRESSED_GET_COMPRESS_METHOD(const void *PT= R) return ((const varattrib_4b *) PTR)->va_compressed.va_tcinfo >> VARLENA_E= XTSIZE_BITS; } =20 -/* Same for external Datums; but note argument is a varatt_external */ +/* + * Same for external Datums; but note argument is a struct + * varatt_external_oid. + */ static inline Size -VARATT_EXTERNAL_GET_EXTSIZE(varatt_external toast_pointer) +VARATT_EXTERNAL_OID_GET_EXTSIZE(varatt_external_oid toast_pointer) { return toast_pointer.va_extinfo & VARLENA_EXTSIZE_MASK; } =20 static inline uint32 -VARATT_EXTERNAL_GET_COMPRESS_METHOD(varatt_external toast_pointer) +VARATT_EXTERNAL_OID_GET_COMPRESS_METHOD(varatt_external_oid toast_pointer) { return toast_pointer.va_extinfo >> VARLENA_EXTSIZE_BITS; } @@ -533,9 +537,9 @@ VARATT_EXTERNAL_GET_COMPRESS_METHOD(varatt_external toa= st_pointer) * actually saves space, so we expect either equality or less-than. */ static inline bool -VARATT_EXTERNAL_IS_COMPRESSED(varatt_external toast_pointer) +VARATT_EXTERNAL_OID_IS_COMPRESSED(varatt_external_oid toast_pointer) { - return VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer) < + return VARATT_EXTERNAL_OID_GET_EXTSIZE(toast_pointer) < (Size) (toast_pointer.va_rawsize - VARHDRSZ); } =20 diff --git a/src/backend/access/common/detoast.c b/src/backend/access/commo= n/detoast.c index a6c1f3a734b2..a50aea7b6b12 100644 --- a/src/backend/access/common/detoast.c +++ b/src/backend/access/common/detoast.c @@ -225,12 +225,12 @@ detoast_attr_slice(varlena *attr, =20 if (VARATT_IS_EXTERNAL_ONDISK(attr)) { - varatt_external toast_pointer; + varatt_external_oid toast_pointer; =20 VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); =20 /* fast path for non-compressed external datums */ - if (!VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) + if (!VARATT_EXTERNAL_OID_IS_COMPRESSED(toast_pointer)) return toast_fetch_datum_slice(attr, sliceoffset, slicelength); =20 /* @@ -240,7 +240,7 @@ detoast_attr_slice(varlena *attr, */ if (slicelimit >=3D 0) { - int32 max_size =3D VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer); + int32 max_size =3D VARATT_EXTERNAL_OID_GET_EXTSIZE(toast_pointer); =20 /* * Determine maximum amount of compressed data needed for a prefix @@ -251,7 +251,7 @@ detoast_attr_slice(varlena *attr, * determine how much compressed data we need to be sure of being * able to decompress the required slice. */ - if (VARATT_EXTERNAL_GET_COMPRESS_METHOD(toast_pointer) =3D=3D + if (VARATT_EXTERNAL_OID_GET_COMPRESS_METHOD(toast_pointer) =3D=3D TOAST_PGLZ_COMPRESSION_ID) max_size =3D pglz_maximum_compressed_size(slicelimit, max_size); =20 @@ -344,7 +344,7 @@ toast_fetch_datum(varlena *attr) { Relation toastrel; varlena *result; - varatt_external toast_pointer; + varatt_external_oid toast_pointer; int32 attrsize; =20 if (!VARATT_IS_EXTERNAL_ONDISK(attr)) @@ -353,11 +353,11 @@ toast_fetch_datum(varlena *attr) /* Must copy to access aligned fields */ VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); =20 - attrsize =3D VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer); + attrsize =3D VARATT_EXTERNAL_OID_GET_EXTSIZE(toast_pointer); =20 result =3D (varlena *) palloc(attrsize + VARHDRSZ); =20 - if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) + if (VARATT_EXTERNAL_OID_IS_COMPRESSED(toast_pointer)) SET_VARSIZE_COMPRESSED(result, attrsize + VARHDRSZ); else SET_VARSIZE(result, attrsize + VARHDRSZ); @@ -398,7 +398,7 @@ toast_fetch_datum_slice(varlena *attr, int32 sliceoffse= t, { Relation toastrel; varlena *result; - varatt_external toast_pointer; + varatt_external_oid toast_pointer; int32 attrsize; =20 if (!VARATT_IS_EXTERNAL_ONDISK(attr)) @@ -412,9 +412,9 @@ toast_fetch_datum_slice(varlena *attr, int32 sliceoffse= t, * prefix -- this isn't lo_* we can't return a compressed datum which is * meaningful to toast later. */ - Assert(!VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer) || 0 =3D=3D sliceoff= set); + Assert(!VARATT_EXTERNAL_OID_IS_COMPRESSED(toast_pointer) || 0 =3D=3D slic= eoffset); =20 - attrsize =3D VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer); + attrsize =3D VARATT_EXTERNAL_OID_GET_EXTSIZE(toast_pointer); =20 if (sliceoffset >=3D attrsize) { @@ -427,7 +427,7 @@ toast_fetch_datum_slice(varlena *attr, int32 sliceoffse= t, * space required by va_tcinfo, which is stored at the beginning as an * int32 value. */ - if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer) && slicelength > 0) + if (VARATT_EXTERNAL_OID_IS_COMPRESSED(toast_pointer) && slicelength > 0) slicelength =3D slicelength + sizeof(int32); =20 /* @@ -440,7 +440,7 @@ toast_fetch_datum_slice(varlena *attr, int32 sliceoffse= t, =20 result =3D (varlena *) palloc(slicelength + VARHDRSZ); =20 - if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) + if (VARATT_EXTERNAL_OID_IS_COMPRESSED(toast_pointer)) SET_VARSIZE_COMPRESSED(result, slicelength + VARHDRSZ); else SET_VARSIZE(result, slicelength + VARHDRSZ); @@ -550,7 +550,7 @@ toast_raw_datum_size(Datum value) if (VARATT_IS_EXTERNAL_ONDISK(attr)) { /* va_rawsize is the size of the original datum -- including header */ - varatt_external toast_pointer; + varatt_external_oid toast_pointer; =20 VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); result =3D toast_pointer.va_rawsize; @@ -610,10 +610,10 @@ toast_datum_size(Datum value) * compressed or not. We do not count the size of the toast pointer * ... should we? */ - varatt_external toast_pointer; + varatt_external_oid toast_pointer; =20 VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); - result =3D VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer); + result =3D VARATT_EXTERNAL_OID_GET_EXTSIZE(toast_pointer); } else if (VARATT_IS_EXTERNAL_INDIRECT(attr)) { diff --git a/src/backend/access/common/toast_compression.c b/src/backend/ac= cess/common/toast_compression.c index 5a5d579494a2..3b1bd6519261 100644 --- a/src/backend/access/common/toast_compression.c +++ b/src/backend/access/common/toast_compression.c @@ -262,12 +262,12 @@ toast_get_compression_id(varlena *attr) */ if (VARATT_IS_EXTERNAL_ONDISK(attr)) { - varatt_external toast_pointer; + varatt_external_oid toast_pointer; =20 VARATT_EXTERNAL_GET_POINTER(toast_pointer, attr); =20 - if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) - cmid =3D VARATT_EXTERNAL_GET_COMPRESS_METHOD(toast_pointer); + if (VARATT_EXTERNAL_OID_IS_COMPRESSED(toast_pointer)) + cmid =3D VARATT_EXTERNAL_OID_GET_COMPRESS_METHOD(toast_pointer); } else if (VARATT_IS_COMPRESSED(attr)) cmid =3D VARDATA_COMPRESSED_GET_COMPRESS_METHOD(attr); diff --git a/src/backend/access/common/toast_internals.c b/src/backend/acce= ss/common/toast_internals.c index 77d42e7ed65a..0f234661bfa9 100644 --- a/src/backend/access/common/toast_internals.c +++ b/src/backend/access/common/toast_internals.c @@ -124,7 +124,7 @@ toast_save_datum(Relation rel, Datum value, TupleDesc toasttupDesc; CommandId mycid =3D GetCurrentCommandId(true); varlena *result; - varatt_external toast_pointer; + varatt_external_oid toast_pointer; int32 chunk_seq =3D 0; char *data_p; int32 data_todo; @@ -176,7 +176,7 @@ toast_save_datum(Relation rel, Datum value, VARATT_EXTERNAL_SET_SIZE_AND_COMPRESS_METHOD(toast_pointer, data_todo, VARDATA_COMPRESSED_GET_COMPRESS_METHOD(dval)); /* Assert that the numbers look like it's compressed */ - Assert(VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)); + Assert(VARATT_EXTERNAL_OID_IS_COMPRESSED(toast_pointer)); } else { @@ -225,7 +225,7 @@ toast_save_datum(Relation rel, Datum value, toast_pointer.va_valueid =3D InvalidOid; if (oldexternal !=3D NULL) { - varatt_external old_toast_pointer; + varatt_external_oid old_toast_pointer; =20 Assert(VARATT_IS_EXTERNAL_ONDISK(oldexternal)); /* Must copy to access aligned fields */ @@ -289,7 +289,7 @@ toast_save_datum(Relation rel, Datum value, { alignas(int32) varlena hdr; /* this is to make the union big enough for a chunk: */ - char data[TOAST_MAX_CHUNK_SIZE + VARHDRSZ]; + char data[TOAST_OID_MAX_CHUNK_SIZE + VARHDRSZ]; } chunk_data; int32 chunk_size; =20 @@ -298,7 +298,7 @@ toast_save_datum(Relation rel, Datum value, /* * Calculate the size of this chunk */ - chunk_size =3D Min(TOAST_MAX_CHUNK_SIZE, data_todo); + chunk_size =3D Min(TOAST_OID_MAX_CHUNK_SIZE, data_todo); =20 /* * Build a tuple and store it @@ -359,8 +359,8 @@ toast_save_datum(Relation rel, Datum value, /* * Create the TOAST pointer value that we'll return */ - result =3D (varlena *) palloc(TOAST_POINTER_SIZE); - SET_VARTAG_EXTERNAL(result, VARTAG_ONDISK); + result =3D (varlena *) palloc(TOAST_OID_POINTER_SIZE); + SET_VARTAG_EXTERNAL(result, VARTAG_ONDISK_OID); memcpy(VARDATA_EXTERNAL(result), &toast_pointer, sizeof(toast_pointer)); =20 return PointerGetDatum(result); @@ -376,7 +376,7 @@ void toast_delete_datum(Relation rel, Datum value, bool is_speculative) { varlena *attr =3D (varlena *) DatumGetPointer(value); - varatt_external toast_pointer; + varatt_external_oid toast_pointer; Relation toastrel; Relation *toastidxs; ScanKeyData toastkey; diff --git a/src/backend/access/heap/heaptoast.c b/src/backend/access/heap/= heaptoast.c index bc4cdd8a3d8b..3b7c658a90e6 100644 --- a/src/backend/access/heap/heaptoast.c +++ b/src/backend/access/heap/heaptoast.c @@ -647,7 +647,7 @@ heap_fetch_toast_slice(Relation toastrel, Oid valueid, = int32 attrsize, &toastidxs, &num_indexes); =20 - max_chunk_size =3D TOAST_MAX_CHUNK_SIZE; + max_chunk_size =3D TOAST_OID_MAX_CHUNK_SIZE; =20 totalchunks =3D ((attrsize - 1) / max_chunk_size) + 1; startchunk =3D sliceoffset / max_chunk_size; diff --git a/src/backend/access/table/toast_helper.c b/src/backend/access/t= able/toast_helper.c index 2f2022d99510..6f2d691cc681 100644 --- a/src/backend/access/table/toast_helper.c +++ b/src/backend/access/table/toast_helper.c @@ -171,7 +171,7 @@ toast_tuple_init(ToastTupleContext *ttc) * The column must have attstorage EXTERNAL or EXTENDED if check_main is * false, and must have attstorage MAIN if check_main is true. * - * The column must have a minimum size of MAXALIGN(TOAST_POINTER_SIZE); + * The column must have a minimum size of MAXALIGN(TOAST_OID_POINTER_SIZE); * if not, no benefit is to be expected by compressing it. * * The return value is the index of the biggest suitable column, or @@ -184,7 +184,7 @@ toast_tuple_find_biggest_attribute(ToastTupleContext *t= tc, TupleDesc tupleDesc =3D ttc->ttc_rel->rd_att; int numAttrs =3D tupleDesc->natts; int biggest_attno =3D -1; - int32 biggest_size =3D MAXALIGN(TOAST_POINTER_SIZE); + int32 biggest_size =3D MAXALIGN(TOAST_OID_POINTER_SIZE); int32 skip_colflags =3D TOASTCOL_IGNORE; int i; =20 diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam= /xlog.c index 2e3f177100b0..3203f2fd4ee2 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -4324,7 +4324,7 @@ WriteControlFile(void) ControlFile->nameDataLen =3D NAMEDATALEN; ControlFile->indexMaxKeys =3D INDEX_MAX_KEYS; =20 - ControlFile->toast_max_chunk_size =3D TOAST_MAX_CHUNK_SIZE; + ControlFile->toast_max_chunk_size =3D TOAST_OID_MAX_CHUNK_SIZE; ControlFile->loblksize =3D LOBLKSIZE; =20 ControlFile->float8ByVal =3D true; /* vestigial */ @@ -4577,15 +4577,15 @@ ReadControlFile(void) "INDEX_MAX_KEYS", ControlFile->indexMaxKeys, "INDEX_MAX_KEYS", INDEX_MAX_KEYS), errhint("It looks like you need to recompile or initdb."))); - if (ControlFile->toast_max_chunk_size !=3D TOAST_MAX_CHUNK_SIZE) + if (ControlFile->toast_max_chunk_size !=3D TOAST_OID_MAX_CHUNK_SIZE) ereport(FATAL, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("database files are incompatible with server"), /* translator: %s is a variable name and %d is its value */ errdetail("The database cluster was initialized with %s %d," " but the server was compiled with %s %d.", - "TOAST_MAX_CHUNK_SIZE", ControlFile->toast_max_chunk_size, - "TOAST_MAX_CHUNK_SIZE", (int) TOAST_MAX_CHUNK_SIZE), + "TOAST_OID_MAX_CHUNK_SIZE", ControlFile->toast_max_chunk_size, + "TOAST_OID_MAX_CHUNK_SIZE", (int) TOAST_OID_MAX_CHUNK_SIZE), errhint("It looks like you need to recompile or initdb."))); if (ControlFile->loblksize !=3D LOBLKSIZE) ereport(FATAL, diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/= replication/logical/reorderbuffer.c index 900864afc6db..457d544eec93 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -5168,7 +5168,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb, ReorderB= ufferTXN *txn, varlena *varlena_pointer; =20 /* va_rawsize is the size of the original datum -- including header */ - varatt_external toast_pointer; + varatt_external_oid toast_pointer; varatt_indirect redirect_pointer; varlena *new_datum =3D NULL; varlena *reconstructed; @@ -5236,10 +5236,10 @@ ReorderBufferToastReplace(ReorderBuffer *rb, Reorde= rBufferTXN *txn, VARSIZE(chunk) - VARHDRSZ); data_done +=3D VARSIZE(chunk) - VARHDRSZ; } - Assert(data_done =3D=3D VARATT_EXTERNAL_GET_EXTSIZE(toast_pointer)); + Assert(data_done =3D=3D VARATT_EXTERNAL_OID_GET_EXTSIZE(toast_pointer)); =20 /* make sure its marked as compressed or not */ - if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) + if (VARATT_EXTERNAL_OID_IS_COMPRESSED(toast_pointer)) SET_VARSIZE_COMPRESSED(reconstructed, data_done + VARHDRSZ); else SET_VARSIZE(reconstructed, data_done + VARHDRSZ); diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlen= a.c index c5fd78f891ea..e5632d930682 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -4261,7 +4261,7 @@ pg_column_toast_chunk_id(PG_FUNCTION_ARGS) { int typlen; varlena *attr; - varatt_external toast_pointer; + varatt_external_oid toast_pointer; =20 /* On first call, get the input type's typlen, and save at *fn_extra */ if (fcinfo->flinfo->fn_extra =3D=3D NULL) diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_res= etwal.c index 1542a56ca4b1..79f3085d7696 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -737,7 +737,7 @@ GuessControlValues(void) ControlFile.xlog_seg_size =3D DEFAULT_XLOG_SEG_SIZE; ControlFile.nameDataLen =3D NAMEDATALEN; ControlFile.indexMaxKeys =3D INDEX_MAX_KEYS; - ControlFile.toast_max_chunk_size =3D TOAST_MAX_CHUNK_SIZE; + ControlFile.toast_max_chunk_size =3D TOAST_OID_MAX_CHUNK_SIZE; ControlFile.loblksize =3D LOBLKSIZE; ControlFile.float8ByVal =3D true; /* vestigial */ =20 diff --git a/doc/src/sgml/storage.sgml b/doc/src/sgml/storage.sgml index 19924b98d71d..90aae3defcbc 100644 --- a/doc/src/sgml/storage.sgml +++ b/doc/src/sgml/storage.sgml @@ -417,7 +417,7 @@ described in more detail below. =20 Out-of-line values are divided (after compression if used) into chunks of = at -most TOAST_MAX_CHUNK_SIZE bytes (by default this value is= chosen +most TOAST_OID_MAX_CHUNK_SIZE bytes (by default this valu= e is chosen so that four chunk rows will fit on a page, making it about 2000 bytes). Each chunk is stored as a separate row in the TOAST tab= le belonging to the owning table. Every diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapa= m.c index 6757baee2404..bbaaec89f8ae 100644 --- a/contrib/amcheck/verify_heapam.c +++ b/contrib/amcheck/verify_heapam.c @@ -75,7 +75,7 @@ typedef enum SkipPages */ typedef struct ToastedAttribute { - varatt_external toast_pointer; + varatt_external_oid toast_pointer; BlockNumber blkno; /* block in main table */ OffsetNumber offnum; /* offset in main table */ AttrNumber attnum; /* attribute in main table */ @@ -1565,7 +1565,7 @@ check_toast_tuple(HeapTuple toasttup, HeapCheckContex= t *ctx, int32 expected_size; int32 max_chunk_size; =20 - max_chunk_size =3D TOAST_MAX_CHUNK_SIZE; + max_chunk_size =3D TOAST_OID_MAX_CHUNK_SIZE; last_chunk_seq =3D (extsize - 1) / max_chunk_size; =20 /* Sanity-check the sequence number. */ @@ -1670,7 +1670,7 @@ check_tuple_attribute(HeapCheckContext *ctx) char *tp; /* pointer to the tuple data */ uint16 infomask; CompactAttribute *thisatt; - varatt_external toast_pointer; + varatt_external_oid toast_pointer; =20 infomask =3D ctx->tuphdr->t_infomask; thisatt =3D TupleDescCompactAttr(RelationGetDescr(ctx->rel), ctx->attnum); @@ -1729,7 +1729,7 @@ check_tuple_attribute(HeapCheckContext *ctx) { uint8 va_tag =3D VARTAG_EXTERNAL(tp + ctx->offset); =20 - if (va_tag !=3D VARTAG_ONDISK) + if (va_tag !=3D VARTAG_ONDISK_OID) { report_corruption(ctx, psprintf("toasted attribute has unexpected TOAST tag %u", @@ -1786,7 +1786,7 @@ check_tuple_attribute(HeapCheckContext *ctx) toast_pointer.va_rawsize, VARLENA_SIZE_LIMIT)); =20 - if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) + if (VARATT_EXTERNAL_OID_IS_COMPRESSED(toast_pointer)) { ToastCompressionId cmid; bool valid =3D false; @@ -1872,9 +1872,9 @@ check_toasted_attribute(HeapCheckContext *ctx, Toaste= dAttribute *ta) uint32 extsize; int32 expected_chunk_seq =3D 0; int32 last_chunk_seq; - int32 max_chunk_size =3D TOAST_MAX_CHUNK_SIZE; + int32 max_chunk_size =3D TOAST_OID_MAX_CHUNK_SIZE; =20 - extsize =3D VARATT_EXTERNAL_GET_EXTSIZE(ta->toast_pointer); + extsize =3D VARATT_EXTERNAL_OID_GET_EXTSIZE(ta->toast_pointer); last_chunk_seq =3D (extsize - 1) / max_chunk_size; =20 /* diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs= =2Elist index c546b3d6375d..04aa7bd202ce 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -4436,7 +4436,7 @@ va_list vacuumingOptions validate_string_relopt varatt_expanded -varatt_external +varatt_external_oid varatt_indirect varattrib_1b varattrib_1b_e --=20 2.55.0 --Mvrusdn1hTsRFd8y-- --JhDV7fXbwmwHOuxh Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmqaHNIACgkQnvQgOdby QH0T0A/+M3vBEC3nmf8kp0zO46RF5aBYi+VdaiiR6en1EYf3YW/pzqR/WJIj7Fy9 uNHCMDB6WrH8/TlWma/XsqsRpE6TSPRc4WHc1bCn5TG2GkpKBnJ07SWBbVtAjTlt fEdQEq5R6Leh/Gav6W646xoCPBYBRX0mRW1rSofgbwzPYM8Ati0C8RRAuIt5zpj6 ArgXsF6sJ4eZJpv9AvQMHYVT3FbYDtdKfKhEaOLLaqKvUPY4BeccX/Pg8l8vzPrv vQedIuoW/Y0NQZqQM7WKSXEHd0DBBQ8YHpb+yxs/nFFq86Q9B5us4ps6iEie3OLz nX0ydTqujT8PrI0IPwS87INdew6+pBW+O1Pjm3HqKgWyx/rHfOfYa3225EtRSLeT 8tVA7rgOUnMhREYZaW5q/a0xWXyJzaqyLOnwWz+YhwGsFOn7IYTu5Ey2JeoJ7XLh 4d6etQmSajnWfbf5jBPkKCKXXLUwwyo7/JaXDvYduWcXulz/V/6QQodSXV7HCMNg YgLo/qd5RbQQskadXaJRT8Hh2iynrx34PxGKyyMbo/fMaPPC8sb2J6HhWK8p1ew1 a/J3bQTeRz8FYoWaInG5MR2RbKryasCEV9/XHgA3tADJS3mXYknGpihrAwBeBIVv UwHo85CzyUMiP56jpPwbWxjpbX3juFvstykBKxiLjgr+2utYFFk= =S+Ti -----END PGP SIGNATURE----- --JhDV7fXbwmwHOuxh--