Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlgxw-0003aG-Iu for pgsql-general@arkaria.postgresql.org; Wed, 17 Jun 2020 22:55:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jlgxu-0005ZR-LA for pgsql-general@arkaria.postgresql.org; Wed, 17 Jun 2020 22:55:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlgxu-0005ZI-DM for pgsql-general@lists.postgresql.org; Wed, 17 Jun 2020 22:55:30 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlgxr-0007QW-Ox for pgsql-general@lists.postgresql.org; Wed, 17 Jun 2020 22:55:30 +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 05HMtPKI1513795; Wed, 17 Jun 2020 18:55:25 -0400 From: Tom Lane To: Michel Pelletier cc: pgsql-general Subject: Re: Hiding a GUC from SQL In-reply-to: References: Comments: In-reply-to Michel Pelletier message dated "Wed, 17 Jun 2020 13:23:19 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1513793.1592434525.1@sss.pgh.pa.us> Date: Wed, 17 Jun 2020 18:55:25 -0400 Message-ID: <1513794.1592434525@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Michel Pelletier writes: > In my extension pgsodium I'm defining a custom variable at startup to store > a key: > https://github.com/michelp/pgsodium/blob/master/src/pgsodium.c#L1107 > I'm using the flags GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE > | GUC_DISALLOW_IN_FILE, and a custom "no show" show hook that obscures the > value. This idea was inspired from the pgcryptokey module from Bruce > Momjian. I guess I'm wondering why you're making it a GUC at all, if you don't want any of the GUC facilities to apply. As far as I can think at the moment, putting in a no-op show hook is sufficient to prevent the value from being seen at the SQL level. However, it's far from clear that doing that isn't going to have negative side-effects; it'll possibly also break other things like GUC save/restore (eg rolling back when a transaction fails). It seems like if you want to be this paranoid, you'd be better off not exposing the variable to the GUC machinery in the first place. You could use a custom set-function (like setseed) to replace the one bit of functionality you do want. regards, tom lane