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 1t2A73-002GL5-Um for pgsql-general@arkaria.postgresql.org; Sat, 19 Oct 2024 14:07:25 +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 1t2A70-003JaT-TY for pgsql-general@arkaria.postgresql.org; Sat, 19 Oct 2024 14:07:23 +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 1t2A70-003JaL-ID for pgsql-general@lists.postgresql.org; Sat, 19 Oct 2024 14:07:22 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t2A6y-001hve-Bx for pgsql-general@lists.postgresql.org; Sat, 19 Oct 2024 14:07:21 +0000 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5c97c7852e8so3677511a12.1 for ; Sat, 19 Oct 2024 07:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729346838; x=1729951638; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=dWsS3HQbkaMmVcyjmTrdqvWy5xrL0eHNn1gE8CZY7zQ=; b=WD8iVCNe5DqUtraduymzSF6+GnsCw8ZADPlDUkTLIvjH+n8Y34rkrweHpmVb0nO5XG Sglt/sUOaTuQWyLEXDRAXohgglwKvnQ39TWSq4o6k8dijpa6KU3qoDEUJkSCwAuI85h6 Ji2S7ohf/ZCX3KjxNn6LJJq3HNsnbRJPTGPYI+ShtgEIftE7iRZ0+XnQSU/e9v2IG8SZ DREYxYfvObCTSQVeSqzRt/8mIhKcVM+eaaEJlxYOT3cZQuywHqakYjlhfUhZXA2ohTDg F/y+0bntSNPGn6sBGJT3CcrfJchZCwmd16JjwItRlxyKys0HchXYMfMQkZnr03lC8hje DOKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729346838; x=1729951638; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=dWsS3HQbkaMmVcyjmTrdqvWy5xrL0eHNn1gE8CZY7zQ=; b=wMyefDXsx87Cbb5ndNJfksl2BbYfAQSIeIlFbKLoddEbBO5CPNyRgF/dgCJLWBfWCM zafAZL276dnIIKhocH8vVEWnT7yIkHQ23JISbZIAECqdxJ/56HhWFegM1lYreiutidY/ 6doP1/gndAJTWZJ5BrAam+Brqem57dmLsD60l3fJvVNK4RqcIv3pOij9XMaLR/5TcJVk onNqq81FWaTitZYgdHrXq2WmDOF/mrDlPgWQEjzCeHZqmY87QROBtIIrtS+5pGn62kKn Nss31lg9ydmJFXorTkX3Qfsdgm5mH9gs5qPVVxxuIYAwP2WvRPHQc3Lc/TvSXA1dCEmj gDRA== X-Gm-Message-State: AOJu0YzhZv+17zDRUNQS/7na8pgXFoMVLBGwu6tgy5T5+75tNPU7wHk0 4Scwf5XgYt9J/Q4ele17mNZV7HkOm33TUB2oMAkn2/53nFOC1kEWcrI20WligfW5CepdL3+dJL1 bqUub8vkP2oZAj/PxuPdiS1mNKw9WOdSw X-Google-Smtp-Source: AGHT+IEsX2mOcgJPw+2lDtynkuA3OpcpO/z6R8inomYhTbAkjLFpdF6W5ejTQvdKhzMIKUStHdJ91ymyYDbto/Tud+k= X-Received: by 2002:a05:6402:4316:b0:5c8:8381:c1bf with SMTP id 4fb4d7f45d1cf-5ca0ac44799mr3647623a12.3.1729346837500; Sat, 19 Oct 2024 07:07:17 -0700 (PDT) MIME-Version: 1.0 From: Marcelo Zabani Date: Sat, 19 Oct 2024 11:07:06 -0300 Message-ID: Subject: RESET, NULL and empty-string valued settings and transaction isolation To: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000f163000624d4efd0" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f163000624d4efd0 Content-Type: text/plain; charset="UTF-8" Hi, according to the docs, RESET sets the value of a setting to "The default value is defined as the value that the parameter would have had, if no SET had ever been issued for it in the current session" Which confuses me given that the value starts being NULL in the session and then turns into an empty string: $ psql => select current_setting('my.test', true) is null; -- true => set my.test = 'abc'; => reset my.test; => select current_setting('my.test', true) is null; -- false => select current_setting('my.test', true)=''; -- true A similar effect happens with transactions and SET LOCAL: => begin; =*> set local my.test='abc'; =*> rollback; -- commit works too => select current_setting('my.test', true) = ''; -- true Is this expected? I thought even if I misunderstand the docs, the effect isn't very nice because SQL like current_setting('my.some_boolean_setting')::boolean will fail after a transaction with SET LOCAL sets it, a side-effect that can be particularly confusing and basically requires usage of nullif(.., '') or other explicit checks around every current_setting call-site in practice. Thanks in advance, Marcelo. --000000000000f163000624d4efd0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, according to the docs, RESET sets the value of a = setting to
"The default value is defined as the value that t= he parameter would have had, if no SET= had ever been issued for it in the current session"

Which confuses me given that the value starts being NULL in the ses= sion and then turns into an empty string:
$ psql
= =3D> select current_setting('my.test', true) is null; -- true=3D> set my.test =3D 'abc';
=3D> reset my.test;
=3D>= ; select current_setting('my.test', true) is null; -- false
=3D&= gt; select current_setting('my.test', true)=3D''; -- true

A similar effect happens with transactions and SET = LOCAL:
=3D> begin;
=3D*> set local my.test=3D'abc= 9;;
=3D*> rollback; -- commit works too
=3D> select current_set= ting('my.test', true) =3D ''; -- true

Is this expected? I thought even if I misunderstand the docs, the e= ffect isn't very nice because SQL like current_setting('my.some_boo= lean_setting')::boolean will fail after a transaction with SET LOCAL se= ts it, a side-effect that can be particularly confusing and basically requi= res usage of nullif(.., '') or other explicit checks around every c= urrent_setting call-site in practice.

Thanks in ad= vance,
Marcelo.
--000000000000f163000624d4efd0--