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 1jM4hM-0000Nz-Mm for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Apr 2020 07:00:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jM4hL-0002IS-HF for pgsql-bugs@arkaria.postgresql.org; Wed, 08 Apr 2020 07:00:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jM4hK-0002IL-WA for pgsql-bugs@lists.postgresql.org; Wed, 08 Apr 2020 07:00:31 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jM4hI-0004Me-3k for pgsql-bugs@lists.postgresql.org; Wed, 08 Apr 2020 07:00:29 +0000 Received: by mail-pl1-x643.google.com with SMTP id h11so2184096plk.7 for ; Wed, 08 Apr 2020 00:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=O+4L11oWG3IMt2+zOc0ilRF/TB3Wa1ERNSf0wu6J7rk=; b=tjupkzECpAJMCVT/73uYpywr+Nb7iBliFZlXUPM41FbLwEArl7t5yovyaJzVQw+Mpt JFLK9VyA0jCuwgzuycfA0ClL0P4GOOcRw3PpalYHhEREd08bL4NBAf9/1T0x5R+F7YXq dHUNlq0J2Rh/QBuS+Ri121fB45fcRjSaj8IFvN7z65OX0gfPsStt2wGsUhXCGJjcaihP N4yG8oXEsTOL8CR6KGNdPfKlfH5W1PLBB1XqYCzHVRPp7EQPXlxUvgGSDnNMQt5UnPQ1 2u1g5v3DWDe8J2PPNFnHOXvjoQaABrwLH5DCmAz8FJuqpYisSIBNM/OfEn8XtzLYYaxU PzBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=O+4L11oWG3IMt2+zOc0ilRF/TB3Wa1ERNSf0wu6J7rk=; b=j37WACEZH3fVAwPubQ3ao384Ywe3Rs172zo+m5YBlPV2SZ3hf1GiMMzYzuiBqobAi3 kLIYjnPo6fhIA9GRtL50Fq9JbemLq2lOGUAsVPMfCAawVy1pIDk5RDZvf2oHeN3zW0dX gxF3/v3w14Zzyswt0ZSzVwMPt2SWofgjTmC/ywZSc+gx+zuX/f59vM02KyXhY6WFP/Pb Zp1SLRrxCPbFpXfXBlIkoGaK4I4zCH0aidFm4puK3HyT3S8XHo9gICljlgpLzoxKYGRi fGjk15gTo0+e38DFozEkI2qS8eyGayNywwJN/LR1LfgXTJNMIBh3TlXQai+JX2szQCQ2 wv8g== X-Gm-Message-State: AGi0Pua+rRpv98TQCZCvC8uL80zHjpIaG7gy+0BypYajWAry6Augo5NT plt1OfE76DTag4JryFYnXEsTKEwk/9AqaRxu X-Google-Smtp-Source: APiQypKYUD7rf3H9Qw20hLf+/IrupAKC2yzKkOOW0AsM/wEiobrtdapm5poy/Xk6qst74Wn8hLKc1g== X-Received: by 2002:a17:902:b7cb:: with SMTP id v11mr6199197plz.307.1586329226986; Wed, 08 Apr 2020 00:00:26 -0700 (PDT) Received: from [127.0.0.1] ([47.88.5.130]) by smtp.gmail.com with ESMTPSA id l15sm14881443pgk.59.2020.04.08.00.00.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Apr 2020 00:00:26 -0700 (PDT) From: wenjing Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_3221A9E9-0639-4D53-97F4-506E67EC1AEE" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [bug] Wrong bool value parameter Date: Wed, 8 Apr 2020 15:00:20 +0800 In-Reply-To: Cc: Euler Taveira , pgsql-bugs@lists.postgresql.org, tushar , Prabhat Sahu To: Masahiko Sawada References: X-Mailer: Apple Mail (2.3608.80.23.2.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_3221A9E9-0639-4D53-97F4-506E67EC1AEE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 2020=E5=B9=B44=E6=9C=887=E6=97=A5 =E4=B8=8B=E5=8D=8810:35=EF=BC=8CMasahi= ko Sawada =E5=86=99=E9=81=93=EF=BC=9A >=20 > On Tue, 7 Apr 2020 at 20:58, Euler Taveira > wrote: >>=20 >> On Tue, 7 Apr 2020 at 06:30, =E6=9B=BE=E6=96=87=E6=97=8C = wrote: >>>=20 >>> Do we allow such a bool parameter value? This seems puzzling to me. >>>=20 >>>=20 >>> postgres=3D# create table t1(c1 int) with(autovacuum_enabled =3D'tr');= >>> CREATE TABLE >>> postgres=3D# create table t2(c1 int) with(autovacuum_enabled =3D'fa');= >>> CREATE TABLE >>> postgres=3D# \d+ t1 >>> Table "public.t1" >>> Column | Type | Collation | Nullable | Default | Storage | Stats = target | Description >>> = --------+---------+-----------+----------+---------+---------+------------= --+------------- >>> c1 | integer | | | | plain | = | >>> Access method: heap >>> Options: autovacuum_enabled=3Dtr >>>=20 >> [don't post to multiple mailing lists] >>=20 >> I'm not sure it is a bug. It certainly can be an improvement. Code as = is does not cause issues although I concur with you that it is at least = a strange syntax. It is like this at least since 2009 (commit = ba748f7a11e). I'm not sure parse_bool* is the right place to fix it = because it could break code. IMHO the problem is that = parse_one_reloption() is using the value provided by user; it should = test those (abbreviation) conditions and store "true" (for example) as = bool value. >>=20 >=20 > The document[1] states: >=20 > Boolean: Values can be written as on, off, true, false, yes, no, 1, 0 > (all case-insensitive) or any unambiguous prefix of one of these. >=20 > Given that PostgreSQL treats such values as boolean values it seems to > me that it's a normal behavior. >=20 > [1] https://www.postgresql.org/docs/devel/config-setting.html Why do table parameters of a bool type have different rules than data = types of a Boolean type? postgres=3D# create table test_bool_type(a bool); CREATE TABLE postgres=3D# insert into test_bool_type values(true); INSERT 0 1 postgres=3D# insert into test_bool_type values(false); INSERT 0 1 postgres=3D# insert into test_bool_type values('false'); INSERT 0 1 postgres=3D# insert into test_bool_type values('t'); INSERT 0 1 postgres=3D# insert into test_bool_type values('f'); INSERT 0 1 postgres=3D# insert into test_bool_type values('tr'); ERROR: invalid input syntax for type boolean: "tr" LINE 1: insert into test_bool_type values('tr'); ^ postgres=3D# insert into test_bool_type values('fa'); ERROR: invalid input syntax for type boolean: "fa" LINE 1: insert into test_bool_type values('fa'); ^ postgres=3D# insert into test_bool_type values('fals'); ERROR: invalid input syntax for type boolean: "fals" LINE 1: insert into test_bool_type values('fals'); =20 >=20 > Regards, >=20 > --=20 > Masahiko Sawada http://www.2ndQuadrant.com/ > PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --Apple-Mail=_3221A9E9-0639-4D53-97F4-506E67EC1AEE Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

2020=E5=B9=B44=E6=9C=887=E6=97=A5 =E4=B8=8B=E5=8D=8810:35=EF=BC= =8CMasahiko Sawada <masahiko.sawada@2ndquadrant.com> =E5=86=99=E9=81=93=EF=BC= =9A

On Tue, 7 Apr 2020 at 20:58, Euler Taveira
<euler.taveira@2ndquadrant.com> wrote:

On Tue, 7 = Apr 2020 at 06:30, =E6=9B=BE=E6=96=87=E6=97=8C <wjzeng2012@gmail.com> wrote:

Do we allow such a bool = parameter value? This seems puzzling to me.


postgres=3D# create table t1(c1 int) = with(autovacuum_enabled =3D'tr');
CREATE TABLE
postgres=3D# create table t2(c1 int) with(autovacuum_enabled = =3D'fa');
CREATE TABLE
postgres=3D# \d+ = t1
=             &n= bsp;           &nbs= p;          Table = "public.t1"
Column |  Type   | Collation | = Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+-= -------------+-------------
c1     | = integer |           | =          | =         | plain   | =             &n= bsp;|
Access method: heap
Options: = autovacuum_enabled=3Dtr

[don't = post to multiple mailing lists]

I'm not = sure it is a bug. It certainly can be an improvement. Code as is does = not cause issues although I concur with you that it is at least a = strange syntax. It is like this at least since 2009 (commit = ba748f7a11e). I'm not sure parse_bool* is the right place to fix it = because it could break code. IMHO the problem is that = parse_one_reloption() is using the value provided by user; it should = test those (abbreviation) conditions and store "true" (for example) as = bool value.


The = document[1] states:

Boolean: Values can be = written as on, off, true, false, yes, no, 1, 0
(all = case-insensitive) or any unambiguous prefix of one of these.

Given that PostgreSQL treats such values as = boolean values it seems to
me that it's a normal = behavior.

[1] https://www.postgresql.org/docs/devel/config-setting.html

Why = do table parameters of a bool type have different rules than data types = of a Boolean type?


postgres=3D# create table test_bool_type(a = bool);
CREATE TABLE
postgres=3D# insert into test_bool_type = values(true);
INSERT 0 1
postgres=3D# insert into test_bool_type = values(false);
INSERT 0 1
postgres=3D# insert into test_bool_type = values('false');
INSERT = 0 1
postgres=3D# insert into test_bool_type = values('t');
INSERT 0 1
postgres=3D# insert into test_bool_type = values('f');
INSERT 0 1

postgres=3D# insert into test_bool_type = values('tr');
ERROR:  invalid input syntax for = type boolean: "tr"
LINE 1: insert into test_bool_type = values('tr');
          =                     =             ^
postgres=3D# insert into test_bool_type = values('fa');
ERROR:  invalid input syntax for = type boolean: "fa"
LINE 1: insert into test_bool_type = values('fa');
          =                     =             ^
postgres=3D# insert into test_bool_type = values('fals');
ERROR:  invalid input syntax for = type boolean: "fals"
LINE 1: = insert into test_bool_type values('fals');

                =      



Regards,

--
Masahiko Sawada =            http://www.2ndQuadrant.com/
PostgreSQL = Development, 24x7 Support, Remote DBA, Training & Services

= --Apple-Mail=_3221A9E9-0639-4D53-97F4-506E67EC1AEE--