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 1sHq5T-00B879-Dc for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 19:26:19 +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 1sHq5Q-006FFx-T3 for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 19:26:17 +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 1sHq5P-006FFR-K2 for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 19:26:17 +0000 Received: from mail-qt1-x82c.google.com ([2607:f8b0:4864:20::82c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sHq5M-001AQH-UT for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 19:26:14 +0000 Received: by mail-qt1-x82c.google.com with SMTP id d75a77b69052e-440f035214eso7192921cf.2 for ; Thu, 13 Jun 2024 12:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=berkeley.edu; s=google; t=1718306771; x=1718911571; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=KuOOyBtITc7/BIOHYK+a8KbO71ArhSItsbck+ty+aW4=; b=BhHOTlR01hO1WCLaxa9jcgzJYrSfXhgy7LD4dBDS97fi9i7KPmZVvdJQ6GG/6Ql5Zf eX/uAJ5Yvhi/aQPYwxAEn55ZhRLLp7SOAV34Yax91N3GbNQwUxgiedwGz3X72oZSxgR8 U2MdXCncVE9Pu654c6DOYBHezBtFag1Rv5vpGKvXX9MbjgSvFXVz//m8APGUzIEmSVJK X0ACAHaNBRSEiyXNYzJqFnOl7RSJoJAdbRrSZRzdOloHRlTuvQWxcWUG1wGa+l5e3Ri1 CXdx2dngGehW9PDU6q/UDLiLfyZA5ac+1rnl7tKJNcmuvWfyla0/FYZnHaGRJkg+UuTv jyig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718306771; x=1718911571; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=KuOOyBtITc7/BIOHYK+a8KbO71ArhSItsbck+ty+aW4=; b=mQizzB089/7+BR4pLbtYp2HvCWsGWBFIN7jGzyZCoxtMbwelklhaIRuaCmDf0Onjin pvqwxg48WspSH68ZPnppib6bdYYFGy42jTnqpeOsNC4msZVgIAX1GZdOirXXPHsFaFEV vbTmWx8KKgNBHdEwrmEcCgCzvZqy1ZzF4Z09UBlNM/BwWOTCdq+C3Z1x1VvHn/xYfbcr l++5eRCsaY/9YXRBw8bxK7IdXFxamW8nE+ShUL1QakLdUpkdi3/WTTuqInPNWxdUAbrV 2IbwQzXCRKsKSaQxIDh4AKHG6cgUuduswOP8sZ/s6I/1z4iGaoxu2d0El54cZtfjoXVc JS+w== X-Gm-Message-State: AOJu0Yxq4DVQZD3QJKwmOf5yo687uOq5xgzBb1WETlJK3sGXbJh0ageK B5RvNhwxqZYx+TYpuf991KSKDJMyi0oggA+u1LaA1SRTMRg4F0OSgInRmVUSqwmP4JcB6Z0xmTw bctq0qCQCwKZgIo+8UiyyIOmGHIUHBUDD+R1rNkMnIxPo5wKOmXPT X-Google-Smtp-Source: AGHT+IEEFMQINmuoLmD+7QvoVWmJXU1RSfJd6/8NHLK8omWVmBSezoqwkVczeG5PCffNJCB63xZHCdf/BZe4z/GtmFU= X-Received: by 2002:a05:622a:49:b0:441:1f35:404b with SMTP id d75a77b69052e-4421687d438mr9202731cf.20.1718306771206; Thu, 13 Jun 2024 12:26:11 -0700 (PDT) MIME-Version: 1.0 From: Narek Galstyan Date: Thu, 13 Jun 2024 12:26:00 -0700 Message-ID: Subject: Reserving GUC prefixes from a non-preloaded DB extension is not always enforced To: pgsql-general@lists.postgresql.org Cc: narek@lantern.dev Content-Type: multipart/alternative; boundary="000000000000b6cb52061aca78fd" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b6cb52061aca78fd Content-Type: text/plain; charset="UTF-8" Hi all, 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. SET lantern.haha = 1; -- succeeds, since lantern extension is not loaded SELECT ARRAY[1] <-> ARRAY[1]; -- uses a lantern API, so extension binary is loaded -- The line above does warn about removing the configuration parameter above -- WARNING: invalid configuration parameter name "lantern.haha", removing it -- DETAIL: "lantern" is now a reserved prefix. SET lantern.haha = 1; -- now this throws an error -- ERROR: invalid configuration parameter name "lantern.haha" -- DETAIL: "lantern" is a reserved prefix. I think, ideally, the last error should be thrown in the first SET execution as well. I'd expect GUC variables reserved by an extension to live more permanently in Postgres catalogs (e.g., in pg_settings). So, even when the extension binary is not loaded, Postgres would know which prefixes are reserved and which GUC settings must be allowed (similar to how Postgres knows in pg_extension which extensions are enabled, even when the corresponding extension binary has not been loaded). 1. Would you consider the proposed behavior an improvement? 2. If so, do you have thoughts on how to implement it? Thanks! Narek Galstyan -- --000000000000b6cb52061aca78fd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi all,

I am an extension developer. I = use `MarkGUCPrefixReserved` to reserve GUC prefixes, which my extension use= s 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.

SET lantern.haha = =3D 1; -- succeeds, since lantern=C2=A0extension is not loaded

SELECT ARRAY[1] <-> ARRAY[1]; -- uses a lantern API,= so extension binary is loaded
-- The line above does warn ab= out removing the configuration parameter above
-- WARNING: =C2=A0= invalid configuration parameter name "lantern.haha", removing it<= br>-- DETAIL: =C2=A0"lantern" is now a reserved prefix.
=

=C2=A0SET lantern.haha =3D 1; -- now this throws an err= or
-- ERROR: =C2=A0invalid configuration parameter name "lantern.ha= ha"
-- DETAIL: =C2=A0"lantern" is a reserved prefix.
<= /div>

I think, ideally, the last error should be thrown = in the first SET execution as well.

I'd expect= GUC variables reserved by an extension to live more permanently in Postgre= s catalogs (e.g., in pg_settings).=C2=A0
So, even when the extens= ion binary is not loaded, Postgres would know which prefixes are reserved a= nd which GUC settings must be allowed (similar to how Postgres knows in pg_= extension which extensions are enabled, even when the corresponding extensi= on binary has not been loaded).

1. Would you consider t= he proposed behavior an improvement?
2. If so, do you have thou= ghts on how to implement it?

Th= anks!
Narek Galstyan
--

--000000000000b6cb52061aca78fd--