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 1sHqIM-00B9Bw-Tv for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 19:39:38 +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 1sHqIK-006UwU-50 for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 19:39:37 +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.94.2) (envelope-from ) id 1sHqIJ-006UwM-Pp for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 19:39:36 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHqII-001AW7-4L for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 19:39:35 +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 45DJdUrP2074490; Thu, 13 Jun 2024 15:39:30 -0400 From: Tom Lane To: Narek Galstyan cc: pgsql-general@lists.postgresql.org, narek@lantern.dev Subject: Re: Reserving GUC prefixes from a non-preloaded DB extension is not always enforced In-reply-to: References: Comments: In-reply-to Narek Galstyan message dated "Thu, 13 Jun 2024 12:26:00 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2074488.1718307570.1@sss.pgh.pa.us> Date: Thu, 13 Jun 2024 15:39:30 -0400 Message-ID: <2074489.1718307570@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Narek Galstyan writes: > I am an extension developer. I use `MarkGUCPrefixReserved` to reserve GUC > prefixes, which my extension uses to help avoid accidentally misspelled > config-file entries. > However, since the reservation happens in `_PG_init()` and `_PG_init()` is > not called until the first use of an API exposed by my extension, > misspelled config-file entries that get executed before the extension is > loaded will not throw an error. No, but a warning will be reported when the extension does get loaded. This seems in line to me with the general behavior of extension-defined GUCs: we cannot know anything about whether a value stored in the config file is sane until we have loaded the extension that defines the GUC's data type, allowed range, etc. > I'd expect GUC variables reserved by an extension to live more permanently > in Postgres catalogs (e.g., in pg_settings). How would they get there? What happens when the extension goes away? How would such an approach emulate C-code-enforced restrictions, that is checks made by a GUC check_hook? What happens if different databases in an installation have inconsistent catalog entries for a GUC? (You could eliminate such inconsistency by storing the data in a shared catalog, perhaps, but that brings some other concerns.) I don't really see the value for work expended here. regards, tom lane