pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: wenjing <wjzeng2012@gmail.com>
To: Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Cc: Euler Taveira <euler.taveira@2ndquadrant.com>
Cc: pgsql-bugs@lists.postgresql.org, tushar <tushar.ahuja@enterprisedb.com>
Cc: Prabhat Sahu <prabhat.sahu@enterprisedb.com>
Subject: Re: [bug] Wrong bool value parameter
Date: Wed, 8 Apr 2020 15:00:20 +0800
Message-ID: <C930FB4B-E89A-4608-B30C-2434EBF1FBC3@gmail.com> (raw)
In-Reply-To: <CA+fd4k7zmTWzmZP6xPey=KZ2EtBOY+T6mnrLewjL4XV=n0s+og@mail.gmail.com>
References: <C6E8C2E7-1906-4F6E-BCC8-7D9FC2FC5CFE@gmail.com>
	<CAH503wA1_burFuRPQkBfMdHXQoc_13R6wmQ06LkjfKN1SHQpSQ@mail.gmail.com>
	<CA+fd4k7zmTWzmZP6xPey=KZ2EtBOY+T6mnrLewjL4XV=n0s+og@mail.gmail.com>



> 2020年4月7日 下午10:35,Masahiko Sawada <masahiko.sawada@2ndquadrant.com> 写道:
> 
> On Tue, 7 Apr 2020 at 20:58, Euler Taveira
> <euler.taveira@2ndquadrant.com> wrote:
>> 
>> On Tue, 7 Apr 2020 at 06:30, 曾文旌 <wjzeng2012@gmail.com> wrote:
>>> 
>>> Do we allow such a bool parameter value? This seems puzzling to me.
>>> 
>>> 
>>> postgres=# create table t1(c1 int) with(autovacuum_enabled ='tr');
>>> CREATE TABLE
>>> postgres=# create table t2(c1 int) with(autovacuum_enabled ='fa');
>>> CREATE TABLE
>>> postgres=# \d+ t1
>>>                                    Table "public.t1"
>>> Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description
>>> --------+---------+-----------+----------+---------+---------+--------------+-------------
>>> c1     | integer |           |          |         | plain   |              |
>>> Access method: heap
>>> Options: autovacuum_enabled=tr
>>> 
>> [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=# create table test_bool_type(a bool);
CREATE TABLE
postgres=# insert into test_bool_type values(true);
INSERT 0 1
postgres=# insert into test_bool_type values(false);
INSERT 0 1
postgres=# insert into test_bool_type values('false');
INSERT 0 1
postgres=# insert into test_bool_type values('t');
INSERT 0 1
postgres=# insert into test_bool_type values('f');
INSERT 0 1

postgres=# 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=# 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=# 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

view thread (9+ messages)  latest in thread

Message-ID: <C930FB4B-E89A-4608-B30C-2434EBF1FBC3@gmail.com>
Permalink:  ../C930FB4B-E89A-4608-B30C-2434EBF1FBC3@gmail.com/
Also on:    postgresql.org/message-id/C930FB4B-E89A-4608-B30C-2434EBF1FBC3@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: wjzeng2012@gmail.com, masahiko.sawada@2ndquadrant.com, euler.taveira@2ndquadrant.com, tushar.ahuja@enterprisedb.com, prabhat.sahu@enterprisedb.com
  Subject: Re: [bug] Wrong bool value parameter
  In-Reply-To: <C930FB4B-E89A-4608-B30C-2434EBF1FBC3@gmail.com>
  References: <C6E8C2E7-1906-4F6E-BCC8-7D9FC2FC5CFE@gmail.com> <CAH503wA1_burFuRPQkBfMdHXQoc_13R6wmQ06LkjfKN1SHQpSQ@mail.gmail.com> <CA+fd4k7zmTWzmZP6xPey=KZ2EtBOY+T6mnrLewjL4XV=n0s+og@mail.gmail.com> <C930FB4B-E89A-4608-B30C-2434EBF1FBC3@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox