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 1whkm1-000Ovl-1p for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 09:10:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whkly-00C6eT-36 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 09:10:23 +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 1whkly-00C6eL-2D for pgsql-hackers@lists.postgresql.org; Thu, 09 Jul 2026 09:10:23 +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.98.2) (envelope-from ) id 1whklw-00000000IEt-3u4c for pgsql-hackers@lists.postgresql.org; Thu, 09 Jul 2026 09:10:22 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 6F1211D000C7; Thu, 9 Jul 2026 05:10:20 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Thu, 09 Jul 2026 05:10:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding: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=1783588220; x=1783674620; bh=MQ7cfjC5kAPJyfV2byGDGdKWT2fEBPz+ fkK1jLlo9a0=; b=L4MLu+xR4kQYERQ4AAAgPqAFQfs9fmtls5nACesSOL7uDxLh wnLE237GGUhTazRAzeV5kUqvbZgGd+nEULkwosIAcaFm44kEZBRl06IdlAeQzEvd IEBnBKHBEE2YjdiB17zQbZ6G6ROd+qM4wc8/tIk5fp6pKbrXGrJdT2YxmKX+vsO9 Z9K611+IWoYtH7DEkfpJUr67oznn7oWwQC86sRtT7noLdLIurj4ZCUa1KCdRNpca KaNqxaKm8A/2f4EEqAOhbcdGr86rsQ3A6cq0Ka0qnSMmTIJRn559AwyC8o2YuNJH 8l3aW7L0oz/Dg8M/oARZ+NUdna1ZErYWcnV7kw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=1783588220; x= 1783674620; bh=MQ7cfjC5kAPJyfV2byGDGdKWT2fEBPz+fkK1jLlo9a0=; b=O i9W2ybtqt9XN9LNUyGklcd9xnU3opRBgdS0yLV5XVxdtwajfqaQKVrnhM1s0jo0V d3OyOYZRlxDJINodNG60XAs0dbqLn3SmA2mQBMEOEYYppm/javlzlDi5O+X2QG6e x7psu8jgWIbKW6TXmT9XrkIf3tr5scfp2TgTRCjHIYAwOklZnGqROiSmMyp/z6oi BImiE27L7egAS8bF+miKpuEgrOFQUvkHrm2iExM/EQVtEmNOGSgXY0qKmkgGE7fM s0gop6qperyh3jymJ6lDaxxHmltCiO5ydBuY/bI3h2zAdno8q/rcDh64MBuA3sGr rf5EtmzPut9wFmeDGoX0w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGAEOocFKQIzlvcEaBW0QQjJ2pomQJBC/LeAPhtWs/m6bTNzgS5HovW9xpbSKJkPB TCrfLIQ2QRhHG8cKgd+N9zaEch0e8v3Zp/znpeRQ3+QjDIPm0DH4U4WHA75J4TS94RFbmE DTxx7RjoLAxF1GP5fq7oKTWsWTCMNUlKFR81mZ+b2WOA4p/A9RunfUn+2B/pOpckQD+Jyq 7RkaDES3PLgkIDAMhra36bNVgU2l5J6nQNnlSBgPiRlUWrvyfXZYBMvTgFdxy3HSQ5o9sy SSnCjHKxop1Vy2NGkXkZGJJua0urYgG5SgMm6gJicVnTM2hynEl4+dA2o1xr9Tr4BFmDkI FjJdJvFZuedgSN2u+fANpLg57ji4IFu0gv7O4bY2H+IMns09hImzp0OO3djKF4j0AAyynC BFE0ia2HmnzeJ4kcEpYBYAWjEQ0JtrqZYdKqPpPutPDNWNDKQo6dr+spIkFEX5MDOk7wGY XMz81Bp8KF5TKMs4qZ1czwQrCgUT8HDDeJvJnznODuB9MpPpP/MgoQmlNn+qErwyqsBGKz 134zqK6/T3KBIAoPPwJKcix2179kRGjmT8lbOV4Juh7s+K0LOKTvvUHYp45vjueOvg3WO3 VhNGEHIb5LFEGfnTTSBp2fXFQd7Ok/KQXao5fgmf+VQOd7A/RlIoRtIOu4ZQ X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 Jul 2026 05:10:19 -0400 (EDT) Message-ID: Date: Thu, 9 Jul 2026 11:10:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [Proposal] Adding callback support for custom statistics kinds To: Michael Paquier , Sami Imseih Cc: PostgreSQL Hackers References: Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 25.11.25 03:03, Michael Paquier wrote: > One part of the proposed patch that felt independent to me was the > renaming and publishing of the two write/read routines for the stats > files, so I have extracted that in your first patch to reduce the > blast, and applied that as it can also be useful on its own. I came across this now. I'm concerned that these write/read routines for stats files are a bit weirdly defined. They were originally internal to pgstat.c where they were specifically tailored to the control flow in that file. For example, pgstat_write_chunk() contains an internal comment "We check for errors with ferror() when done writing the stats.", which is fine as a description of what happens in that file, but it's pretty poor as an API documentation. On the other hand, pgstat_read_chunk() does do some error checking, but completely undocumented and weirdly inconsistent with the write counterpart. Again, this might be fine for an internal helper but not for an external API. I also don't think these functions are well-named. They don't do anything about "pgstat", they are just convenience wrappers around fread() and fwrite() with some sizeof integration (which is also kind of fragile, because there is no type checking about what you are passing). I have not found any documentation about this new feature for pluggable statistics, so it's not clear whether these functions are meant to be part of the official API for that, or they just happened to be available for implementing that test module. I suggest that unless we can come up with a well-defined, robust, and well-documented API for these, they should be moved back to be internal to pgstat.c, and test_custom_var_stats.c can define its own helper functions. Maybe in the future, when we have more of these, some good API will emerge.