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.94.2) (envelope-from ) id 1tLRKi-00Eo3s-0q for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Dec 2024 18:21:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tLRKf-000s92-5T for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Dec 2024 18:21:10 +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.94.2) (envelope-from ) id 1tLRKe-000s8t-Qf for pgsql-hackers@lists.postgresql.org; Wed, 11 Dec 2024 18:21:10 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tLRKa-002Jda-Rz for pgsql-hackers@postgresql.org; Wed, 11 Dec 2024 18:21:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 4BBIL3rd506789; Wed, 11 Dec 2024 13:21:03 -0500 From: Tom Lane To: Andrei Lepikhov cc: PostgreSQL-development Subject: Re: Add Postgres module info In-reply-to: References: Comments: In-reply-to Andrei Lepikhov message dated "Wed, 11 Dec 2024 15:35:43 +0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <506787.1733941263.1@sss.pgh.pa.us> Date: Wed, 11 Dec 2024 13:21:03 -0500 Message-ID: <506788.1733941263@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andrei Lepikhov writes: > I would like to propose the module_info structure, which aims to let > extension maintainers sew some data into the binary file. Being included > in the module code, this information remains unchanged and is available > for reading by a backend. I don't have much of an opinion one way or the other about the usefulness of these additional info fields. But I would like to object to the way you've gone about it, namely to copy-and-paste the magic-block mechanism. That doesn't scale: the next time somebody else wants some more fields, will we have three such structs? The approach we foresaw using was that we could simply add more fields to Pg_magic_struct (obviously, only in a major version). That's happened at least once already - abi_extra was not there to begin with. There are a couple of ways that we could deal with the API seen by module authors: 1. The PG_MODULE_MAGIC macro keeps the same API and leaves the additional field(s) empty. Authors who want to fill the extra field(s) use a new macro, say PG_MODULE_MAGIC_V2. 2. PG_MODULE_MAGIC gains some arguments, forcing everybody to change their code. While this would be annoying, it'd be within our compatibility rules for a major version update. I wouldn't do it though unless there were a compelling reason why everybody should fill these fields. 3. Maybe we could do something with making PG_MODULE_MAGIC variadic, but I've not thought hard about what that could look like. In any case it'd only be a cosmetic improvement over the above ways. 4. The extra fields are filled indirectly by macros that extension authors can optionally provide (a variant on the FMGR_ABI_EXTRA mechanism). This would be code-order-sensitive so I'm not sure it's really a great idea. 5. Something I didn't think of? With any of these except #4, authors who want their source code to support multiple PG major versions would be forced into using #if tests on CATALOG_VERSION_NO to decide what to write. That's a bit annoying but hardly unusual. regards, tom lane