From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Geoff Winkless <pgsqladmin@geoff.dj>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Alexandre GRAIL <postgresql.general@augure.net>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Casting Integer to Boolean in assignment
Date: Thu, 24 Jan 2019 07:28:37 -0800
Message-ID: <1bc32f58-a479-ee28-353f-b11810bab95e@aklaver.com> (raw)
In-Reply-To: <CAEzk6fd-KniDxJWHPMh4e0AAGuNu=Hq914kW7aeQOjE2ybNVzw@mail.gmail.com>
References: <d8fe822a-ac75-5763-00b3-273f11394fc5@augure-ng.fr>
<CAKFQuwZXYgDxDLkB4a2jVn+bcuyxEWyROoKL8z-fwfrbS1pFgA@mail.gmail.com>
<CAEzk6ffv_490p4z-0mKoxGcp0gVNLmkv84kCn1OvB-=mg_B+tg@mail.gmail.com>
<17453.1548342682@sss.pgh.pa.us>
<CAEzk6fd-KniDxJWHPMh4e0AAGuNu=Hq914kW7aeQOjE2ybNVzw@mail.gmail.com>
On 1/24/19 7:21 AM, Geoff Winkless wrote:
> On Thu, 24 Jan 2019 at 15:11, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> People don't generally post to the lists after a type-mismatch error
>> catches a typo for them. So it's pretty hard to tell about "how
>> many" developers would find one behavior more useful than the other.
>> It is safe to say, though, that the same developer complaining today
>> might have their bacon saved tomorrow.
>
> I've missed off WHERE clauses on a live database (oops) in my time,
> and I'm happy to see work being done to safeguard against that
> (although I tend to be of the opinion that it's not something you ever
> do twice!) but I can confidently state that I've never once been
> caught out by being surprised that a number was treated as a boolean.
>
> How could you even write a query like the one Thomas posted? It
> doesn't even look remotely sensible.
create table delete_test(id integer);
insert into delete_test values (2), (3), (4);
delete from delete_test where 1::boolean;
DELETE 3
select * from delete_test ;
id
----
(0 rows)
>
> But I have been caught out by boolean vs int, enough that I bothered
> to search out that ALTER statement. And I'm a lazy person at heart, so
> if something irritated me enough to bother doing that, you can be sure
> it was _really_ irritating me.
>
> Geoff
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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-general@postgresql.org
Cc: adrian.klaver@aklaver.com, pgsqladmin@geoff.dj, tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, postgresql.general@augure.net
Subject: Re: Casting Integer to Boolean in assignment
In-Reply-To: <1bc32f58-a479-ee28-353f-b11810bab95e@aklaver.com>
References: <d8fe822a-ac75-5763-00b3-273f11394fc5@augure-ng.fr> <CAKFQuwZXYgDxDLkB4a2jVn+bcuyxEWyROoKL8z-fwfrbS1pFgA@mail.gmail.com> <CAEzk6ffv_490p4z-0mKoxGcp0gVNLmkv84kCn1OvB-=mg_B+tg@mail.gmail.com> <17453.1548342682@sss.pgh.pa.us> <CAEzk6fd-KniDxJWHPMh4e0AAGuNu=Hq914kW7aeQOjE2ybNVzw@mail.gmail.com> <1bc32f58-a479-ee28-353f-b11810bab95e@aklaver.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