Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmgvx-0001Bq-LS for pgsql-general@arkaria.postgresql.org; Thu, 24 Jan 2019 15:28:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gmgvv-00019i-Vh for pgsql-general@arkaria.postgresql.org; Thu, 24 Jan 2019 15:28:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmgvv-00019b-Jl for pgsql-general@lists.postgresql.org; Thu, 24 Jan 2019 15:28:47 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmgvo-0006qq-WC for pgsql-general@lists.postgresql.org; Thu, 24 Jan 2019 15:28:46 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 0187D22A8A; Thu, 24 Jan 2019 10:28:40 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 24 Jan 2019 10:28:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=y zyE0+nGW4XSrWYGeZp+DVgpgpmaJkG1zdik0cfinIs=; b=AV8/cs9jo2qGn+u6u c6QR0d1tWF2w3t2fLK9OY2VVssy+SCChnjdXbfWMPO35PWfIcdBBbGrF+00uJsE2 QW+Mdkq8OcpW81QhVaJ8nmXCco/8gBJIcJZOt+WHXgKxxvaOa1+qnHhAkla6zbOq HyMfTWaToO7NJEVZ9YUtlytZbmhT7jA4lMAxtrfCtlDVGFnpkCAMv4qTvbaqFoZN 8f9V2Al/R/Pkz2fJPp7hlv0LRMqiTSRCcRUPyKwNuLzm394Ijs3koGRKswMAHNQv EIWS1wi6hk6YQgfMVoIfwxOh2KQxKaiEIWklq981Hu1f/igYcUYlt/s22ZYPP9F/ 4zCvw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=yzyE0+nGW4XSrWYGeZp+DVgpgpmaJkG1zdik0cfin Is=; b=hxvo96PBwMHVfIpVUuEuLpcUu5C/xjj6HSY/OMke+LUjwM95St1yCEIRm bF+Q4UIhXaHGB+vnZX2BZFlVkw//Tn/YKmxrWTo8IVbVGQb1R9z29FKTFvCqIEWm ++B1hZQBb51Qc0hvoQRM5WQz/jIh1fZDvjF1ROVx/xPfr/LX5nXYzPs4AqLGcllT bN4/X7hWp0Mhr4utzJ3UTnOqKgQYyLlyckI27/NmQj00Eyi8BptLSWOIFLV4sbRy EJmZ56hkkME9dFYSdZvPTyVSOHisAK5NPQK1pl0mHbmWMImq5BLa8yYQ1bv1Egsh 0GkSalHFn36vukwL76rErVARVuD8w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledriedvgdejhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepuffvfhfhkffffg ggjggtgfesthejredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegr ughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucfkphepjedurddvud dvrddufeegrdefnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghv vghrsegrkhhlrghvvghrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.2] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 255BAE4383; Thu, 24 Jan 2019 10:28:38 -0500 (EST) Subject: Re: Casting Integer to Boolean in assignment To: Geoff Winkless , Tom Lane Cc: "David G. Johnston" , Alexandre GRAIL , "pgsql-generallists.postgresql.org" References: <17453.1548342682@sss.pgh.pa.us> From: Adrian Klaver Message-ID: <1bc32f58-a479-ee28-353f-b11810bab95e@aklaver.com> Date: Thu, 24 Jan 2019 07:28:37 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/24/19 7:21 AM, Geoff Winkless wrote: > On Thu, 24 Jan 2019 at 15:11, Tom Lane 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