From 6f3bdadaadc4692050ca20dff53d3890088b9272 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 2 Oct 2026 13:00:31 +0200 Subject: [PATCH] Write pg_attribute_counted_by() in front of the type This is technically the more correct position according to C23, although in practice compilers are relaxed about this. It also opens us up to supporting MSVC's _Field_size_() in the future, which is a similar construct. This requires adding pg_attribute_counted_by to the list of declaration attributes in pgindent, so that pgindent doesn't mess it up. Author: Tristan Partin Discussion: https://www.postgresql.org/message-id/flat/DKBEBF32QLUA.3L2DJRPUYNKHZ%40partin.io --- src/backend/utils/adt/jsonfuncs.c | 2 +- src/tools/pgindent/pgindent | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index 64c85e9ddd1..adbafd0ecd3 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -233,7 +233,7 @@ struct RecordIOData Oid record_type; int32 record_typmod; int ncolumns; - ColumnIOData columns[FLEXIBLE_ARRAY_MEMBER] pg_attribute_counted_by(ncolumns); + pg_attribute_counted_by(ncolumns) ColumnIOData columns[FLEXIBLE_ARRAY_MEMBER]; }; /* per-query cache for populate_record_worker and populate_recordset_worker */ diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 1dcd47e04c9..ee30da799b4 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -238,6 +238,7 @@ sub write_source # Declaration attributes that pg_bsd_indent doesn't know how to handle. my @declaration_attributes = qw( alignas + pg_attribute_counted_by ); # Text of each declaration attribute, stashed by pre_indent() and restored