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 1wAmql-000KWO-0x for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2026 10:43:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAmqj-005Eti-1g for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2026 10:43:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAmqi-005EtZ-2S for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2026 10:43:02 +0000 Received: from fhigh-b8-smtp.messagingengine.com ([202.12.124.159]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wAmqg-00000000AHE-1pNw for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2026 10:43:01 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id CE02D7A00F4; Thu, 9 Apr 2026 06:42:54 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 09 Apr 2026 06:42:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=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=1775731374; x=1775817774; bh=aaWaVjbj1Yo+3AtgIKzK6JoRkqoGL91/JZYCIr5n9s0=; b= S1qwSG3zXKkN8MRN2nfuZj5fx4fYIoAH9CSmHKxsZfU31O1yAU3ILEe5GeQNOxNd 0x1K9VL/E56Rw67NZhl+AN701jR2JfgkLAtix2A+xJmDExhii2V5rjZRmZnxa9MR pg/1aTzyR3cEiZLUE6X6b9n2Ry4lz30AxfNIV0VL8B0TiWh9j2hB24O2o5YkaX/v hq2/6Hj8cmRsXqAzpXAEr4D0g0piMFtk8zoye2IRfy0ZMw5RWkTDEmmkXMuywyN4 +bRFcwklySmob3fE9HhUVVRvpRYMCGjzAXQCC7YaryJLrwtHll6tzzonQDE1JtGT TmQtiqSzsaMikx+VQEKW3A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=1775731374; x=1775817774; bh=a aWaVjbj1Yo+3AtgIKzK6JoRkqoGL91/JZYCIr5n9s0=; b=XCjE88OiaUYhhV6k2 +GFAdF+/ICI0wmWsjlW+JLCm3NnrUqbtE2LgvoGKMuVDAX4KGszszmrFHbiZBnrj RfuJgDNIN+LHpqOMJapV19T41cYOVOew6a6vMAInV6JMBsctKblyqqfYdRZ+Xpcf ia21pYETR0ESjRq8yVUkGxF2JjhzEDM5HmNZujncMAWsxEAQH+7WSkRLrf40Ffkt QRFQg1hvIh+9UVwS1Hib3fbEjzbweijlvzY+XmN4Qxdsghte0F0k+TkK2Arp/an0 z/Djh8kCfmBl0i7wJc0NNtm0p7BIpUuho84ViEPKc2Lv6nBzuGTU7dkvQGWsPnSO jmPmw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgddviedvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefkffggfgfuvfhfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpefrvghtvghrucfg ihhsvghnthhrrghuthcuoehpvghtvghrsegvihhsvghnthhrrghuthdrohhrgheqnecugg ftrfgrthhtvghrnhepgeeuuedvhfehueeijeetgfdutdfhveevfeeugfdtvdfgteetheej teeluedvvedunecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrsegvihhs vghnthhrrghuthdrohhrghdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphhouh htpdhrtghpthhtohepthhhohhmrghsrdhmuhhnrhhosehgmhgrihhlrdgtohhmpdhrtghp thhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrd horhhg X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 Apr 2026 06:42:53 -0400 (EDT) Message-ID: <7f93a0ad-e7cc-4878-8c0c-68fe85927fe2@eisentraut.org> Date: Thu, 9 Apr 2026 12:42:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [[deprecated("don't call this, call that")]] To: Thomas Munro , PostgreSQL Hackers References: Content-Language: de-DE, 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 09.04.26 05:34, Thomas Munro wrote: > While working on 1e7fe06c, I wished I could make functions generate > compiler warnings: > > pg_attribute_deprecated("use pg_mblen_{cstr,range,with_len,unbounded} instead") > extern int pg_mblen(const char *mbstr); > > That'd avoid accidental reintroduction, and also get extension > maintainers' attention. $SUBJECT is C23/C++14's syntax, but you've > long been able to do that with in __attribute__ or __declspec for the > usual suspects so I looked into which compiler versions introduced > that and came up with the attached. Yes, this makes sense. There have been discussions about a deprecated attribute before (such as [0]), but in those cases it was mostly about nagging people about coding style, which had potentially annoying effects for extension authors that want to cover many major versions. But in this case, we are actively encouraging people to get rid of a function use, so it seems like a very suitable use case. [0]: https://www.postgresql.org/message-id/d80b6adf-4bfd-4172-a9cd-2ad6e23b1a08%40eisentraut.org > The idea would be to back-patch the deprecation warnings, and delete > the functions in, I guess now, v20. Then the deprecation notice > facility would always be there for next time we need it. It might be enough to put the deprecation attribute into PG19. That way, extension authors will see it (unless the extension is not supporting PG19, in which case it seems likely that they also won't bother to make any adjustments to avoid deprecated functions). This piece +#elif defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 5) +#define pg_attribute_deprecated(message) __attribute__((deprecated(message))) could be written as #elif __has_attribute(deprecated) ... __has_attribute works back to PG14. If you do want to backpatch it, I would skip the C23/C++ branch for versions PG18 and older. That way, each branch has an internally consistent handling of attributes. (We have some C23/C++ attributes in PG19, but not before.)