From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add pg_attribute_counted_by()
Date: Mon, 28 Sep 2026 08:25:17 +0000
Message-ID: <E1xB6fl-00000001Zq8-1ChI@gemulon.postgresql.org> (raw)
Add pg_attribute_counted_by()
The counted_by attribute allows specifying that a flexible array
member of a struct is "counted by" another member of the same struct.
The attribute makes arrays a little more self-documenting, but it is
also a hint to the compiler such that it can improve detection of
object size information and provide better results in compile-time
diagnostics and run-time features, such as the array bounds sanitizer.
Both GCC and clang warn when the attribute is used in C++, where it is
ignored, so define it away there.
In its current form, it is best used for flexible array members only.
Pointer array support may come later on.
This commit only contains a single use of the attribute for testing.
More will be added afterwards.
Author: Tristan Partin <tristan@partin.io>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Reviewed-by: Japin Li <japinli@hotmail.com>
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/a936ebd9f9f64b0efb853195d8dcdb8a0453537d
Modified Files
--------------
src/backend/utils/adt/jsonfuncs.c | 2 +-
src/include/c.h | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: peter@eisentraut.org
Subject: Re: pgsql: Add pg_attribute_counted_by()
In-Reply-To: <E1xB6fl-00000001Zq8-1ChI@gemulon.postgresql.org>
References: <E1xB6fl-00000001Zq8-1ChI@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox