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 1pFWIH-0002II-Ez for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Jan 2023 08:17:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pFWIG-0005A5-C6 for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Jan 2023 08:17:08 +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 1pFV0U-0006GP-9O for pgsql-bugs@lists.postgresql.org; Wed, 11 Jan 2023 06:54:42 +0000 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pFV0R-0000xb-M4 for pgsql-bugs@lists.postgresql.org; Wed, 11 Jan 2023 06:54:41 +0000 Received: by mail-ed1-x52d.google.com with SMTP id z11so21012113ede.1 for ; Tue, 10 Jan 2023 22:54:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=subzero-cloud.20210112.gappssmtp.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0tRQZrVTBx+7OyCIe6XS7lkN5aCbLYZCz9duKqXJx20=; b=0akiaVt7JK0cacwcY6QkhXzb8bDcBgI6BlfDPnch1OX5AcUQ1qIK7tzlkpnczpm6Zb PxT7SlOk4bqNHpcTUPv83FZlySr2vKUb4XvI1UkGUMYsHsX8uNzDW52NKUnVGTkCIX3+ hdsskRbVLsv10V7j9Tqp9PcWaDMgr83VDfx2AChQ1umRy7THZxEKevYOnY0CyL6L+M37 +70OBSra54kz002AQHtiufS3++LshGyZBlaHXVE4c4x0SWTf9enQrkXaJXCVfQh0WA/T 4A3fZcAxN0n+jRFiMLJTPi9hwgv/axzBt5AC4yoInLxM2wi0TrVpioTqQEVqENhcKbfr FHhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0tRQZrVTBx+7OyCIe6XS7lkN5aCbLYZCz9duKqXJx20=; b=RvS+f+9ZUL45lUf8tLZn068drpuLCfJlGR3JsEDAZeuQ/Z6705wmxVqrPcqdWquu7J sgX6ZcjhQHit1+rAiFtkpfj+q8wqwWjGtnFPYM2WDPeSP3PN7on211WiUsQawxCZtusd YNCP2XvH+vwNHIIkMvKaWV6r/cfAIIQnsr1ScF7YqOwLok105TKQKaSpp/Bzhbj59kJH ZaMES2jkPFc49BIOLKADr+CKtPGGgg4EBwOOuOfYWZt9WZXmzTgQk2HjeCR934Y7YNhR L4bETWN1QnXtbg7nbJPbGl8iBHdQWuhwzrszzYbI69g81YfiNU746MlVzF9jNnwWexmw RcPg== X-Gm-Message-State: AFqh2koNWmGL4ilPrvj7gN53rI47K6sPXJFdVJ5xHYn9nM2K/7eb7dtm cuc9oF+nxEOHq3iBAI0Vt3kZhsjA7P5PWr4p X-Google-Smtp-Source: AMrXdXtUIN+7jtTLYyEOcuKkZbmtXJ8FE+k7ej/w7Da+pp/HWBURc7Fx3pWAMczr8PQj4FOu/UcnBA== X-Received: by 2002:a05:6402:1294:b0:499:8849:5faf with SMTP id w20-20020a056402129400b0049988495fafmr10490907edv.26.1673420077322; Tue, 10 Jan 2023 22:54:37 -0800 (PST) Received: from smtpclient.apple ([86.127.142.246]) by smtp.gmail.com with ESMTPSA id q24-20020a056402249800b0046ac460da13sm5760514eda.53.2023.01.10.22.54.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Jan 2023 22:54:36 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.200.110.1.12\)) Subject: Re: set_config with is_local parameter true escapes transaction boundaries From: Ruslan Talpa In-Reply-To: <392925.1673397546@sss.pgh.pa.us> Date: Wed, 11 Jan 2023 08:54:25 +0200 Cc: pgsql-bugs@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <17634C6E-1208-4254-A82F-9B9AEEC2DCA9@subzero.cloud> References: <997A11B3-BC14-44FB-A505-BE7C49BE5330@subzero.cloud> <392925.1673397546@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3731.200.110.1.12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk It=E2=80=99s true that null is not a valid value for GUC however the = infrastructure does make a distinction between =E2=80=9Cthe setting has = no value, as in empty string=E2=80=9D and =E2=80=9Cthere is no such = setting, null=E2=80=9D and since the documentation for set_config only = says =E2=80=9CIf is_local is true, the new value will only apply during = the current transaction.=E2=80=9D the expectation is that after the = transaction things should return to the previous state (i.e = current_setting should return null) Maybe this is only a documentation issue, for example have a note in = 9.27.1 or 20.16 along the lines =E2=80=9CNote: Once a GUC value has been = set, even with is_local set to true, subsequent calls to current_setting = will return an empty string=E2=80=9D In any case, I am only reporting (what I view as) an inconsistency i = came across that is not mentioned anywhere and thought I=E2=80=99d bring = it up so that PG developers are aware can make a decision either way. Thank you for your work (and reply to the email) PS: A few more words about the context where this came up, feel free to = skip this. Per 20.16 it=E2=80=99s clear that this infrastructure was designed for = PG extensions to use, however currently it=E2=80=99s being (ab)used by = popular tools like PostgREST/Postgraphile/Hasura as a =E2=80=9Ctransaction= context=E2=80=9D, i.e. store within a transaction things like =E2=80=9Cwh= o is executing the current query=E2=80=9D or =E2=80=9Cfrom what ip=E2=80=9D= so that code from the database context (triggers/views/stored = procedures) can act based on that information. Looking at it from this = use case point of view, one would want to make a distinction between = =E2=80=9Cthat context value is not set=E2=80=9D and =E2=80=9Cthat = context value is an empty string=E2=80=9D or at least be aware this = issue exists. > On 11 Jan 2023, at 02:39, Tom Lane wrote: >=20 > Ruslan Talpa writes: >> When executing set_config with the parameter =E2=80=98is_local=E2=80=99= set to true within a transaction, it is expected that the config value = is not available after the transaction however once the config is set in = any transaction, current_setting will return an empty string instead of = null >=20 > The GUC infrastructure doesn't recognize null as a value, so you > are making a distinction that the system doesn't. >=20 > regards, tom lane