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 1gmhQk-0002uH-VX for pgsql-general@arkaria.postgresql.org; Thu, 24 Jan 2019 16:00:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gmhQi-0000bd-AV for pgsql-general@arkaria.postgresql.org; Thu, 24 Jan 2019 16:00:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmhQi-0000bA-1r for pgsql-general@lists.postgresql.org; Thu, 24 Jan 2019 16:00:36 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gmhQf-0000ii-Fn for pgsql-general@lists.postgresql.org; Thu, 24 Jan 2019 16:00:35 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 372122438E; Thu, 24 Jan 2019 11:00:32 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 24 Jan 2019 11:00:32 -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=k 1wN9roYVtdgak7yjRBlbaJMsZBFnub9gRGdKfzYf3c=; b=BBH8BWlxlnyCYF5X0 hYnpySHUmcYlvUAmlfPGkiNecqKJfloMqRGSgvugrGbdqGLAR0swpAMBnSz7f0xU CQKrPRhoxm7vWU3nLICc1Ure1+oPoYKVVA+H/1ob95wzBAXpoP/BFO5fLHwN7wrf UDTFrnMxxzZJxUt6U7mKGjCIcyYdx342jyEjFpuTnUYohGBZTz/mEDGNwkEtl6Ab svsOEzOk2YCUxEzyBIqglWoSUZf3EVXx3O2cSXGwakwUhUFiWpT/9VU1fVfFm0SH cxnHE4KVxW7yetxs0a4lRRPrtg21eZHFMYbKygH7e0BzxAfyM6iy3opRK4IZL2wa NgUgg== 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=k1wN9roYVtdgak7yjRBlbaJMsZBFnub9gRGdKfzYf 3c=; b=V8Z0fyuUILJ4XECmtgHT9sAa4IXlB926V733JTaJnPzY1I3stwBIawB5k g5i/aCB50Lw2Dau+H0tpt8jwFXwEVGrmWy3YoEIcG63dCebpcIGfrit2ScNnknbj 2Rjx9BX0UzD3CO1IdMCuYIiJKuw+KCkT1hZci0XM8TEP3+OuEw4eUvYoswDOKcAE IWRx/NV/6lk4xsX46A4H9s523y4bdZfrxyoyH/Uqm0heJvTFWFsAphW+zB37wWka ganx6ewd45rPGrpsoM5JNCifiDDCrroEd5AvF8ohYHPwJ9qgSMeOw7xDGvTmfwoz tSy9XwWRRJWWoENNhc4CB22a1ubbQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledriedvgdekudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepuffvfhfhkffffg ggjggtgfesthejredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegr ughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucffohhmrghinhepph hoshhtghhrvghsqhhlrdhorhhgnecukfhppeejuddrvdduvddrudefgedrfeenucfrrghr rghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.2] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id A0801E4741; Thu, 24 Jan 2019 11:00:29 -0500 (EST) Subject: Re: Casting Integer to Boolean in assignment To: Geoff Winkless Cc: Tom Lane , "David G. Johnston" , Alexandre GRAIL , "pgsql-generallists.postgresql.org" References: <17453.1548342682@sss.pgh.pa.us> <1bc32f58-a479-ee28-353f-b11810bab95e@aklaver.com> <52d4616a-af35-68fa-a613-b823ab3d2eb4@aklaver.com> From: Adrian Klaver Message-ID: <984fa130-e8a1-6cb0-b7f8-f57e853f8dfd@aklaver.com> Date: Thu, 24 Jan 2019 08:00:27 -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:48 AM, Geoff Winkless wrote: > On Thu, 24 Jan 2019 at 15:40, Adrian Klaver wrote: >> delete from delete_test where >> >> and then forget the 'field =' part. Though my more common mistake along >> that line is: >> >> delete from delete_test; >> >> At any rate, if it can be done it will be done. > > If you follow that logic, then having a single boolean test at all > should be invalid. > > CREATE TABLE mytest (myval char (1)); > INSERT INTO mytest VALUES ('a'),('b'),('c'),('s'),('t'); > DELETE FROM mytest WHERE 't'; > SELECT * FROM mytest; > myval > ------- > (0 rows) People are going to make mistakes that is a given. Eliminating a boolean test is not going to change that. Where this particular sub-thread started was with this from a previous post of yours: "My own opinion is that non-0 should implicitly cast as true and 0 should cast as false. ..." That opens an infinite number of values that could be seen as True. That in turn leads to greater chance of fat-thumbing yourself into an oops. Like you say it is a matter of opinion. The projects opinion is here: https://www.postgresql.org/docs/11/datatype-boolean.html and it works for me. > > Geoff > -- Adrian Klaver adrian.klaver@aklaver.com