Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGGj7-00ERfY-Rp for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Dec 2023 10:56:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rGGj6-006xRD-K0 for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Dec 2023 10:56:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGGj6-006xR4-AC for pgsql-hackers@lists.postgresql.org; Thu, 21 Dec 2023 10:56:28 +0000 Received: from feynman.df7cb.de ([195.49.152.168]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGGj3-00BUEu-9T for pgsql-hackers@lists.postgresql.org; Thu, 21 Dec 2023 10:56:27 +0000 Received: from msg.df7cb.de (unknown [62.23.211.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by feynman.df7cb.de (Postfix) with ESMTPSA id 4SwnRW4GmVz3G0Q for ; Thu, 21 Dec 2023 11:56:23 +0100 (CET) Date: Thu, 21 Dec 2023 11:56:22 +0100 From: Christoph Berg To: PostgreSQL Hackers Subject: int4->bool test coverage Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="/1M/m83OTNDtKeu/" Content-Disposition: inline Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --/1M/m83OTNDtKeu/ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit I was surprised to learn that 2 is a valid boolean (thanks Berge): # select 2::boolean; bool ────── t ... while '2' is not: # select '2'::boolean; ERROR: 22P02: invalid input syntax for type boolean: "2" LINE 1: select '2'::boolean; ^ LOCATION: boolin, bool.c:151 The first cast is the int4_bool function, but it isn't covered by the regression tests at all. The attached patch adds tests. Christoph --/1M/m83OTNDtKeu/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Add-tests-for-int4_bool.patch" From 5752d75122db323b4066dd604d0c7a19077641a6 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Thu, 21 Dec 2023 11:43:28 +0100 Subject: [PATCH] Add tests for int4_bool This cast was previously not covered at all by the regression tests. --- src/test/regress/expected/boolean.out | 19 +++++++++++++++++++ src/test/regress/sql/boolean.sql | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/src/test/regress/expected/boolean.out b/src/test/regress/expected/boolean.out index ee9c244bf8..ff9440df7e 100644 --- a/src/test/regress/expected/boolean.out +++ b/src/test/regress/expected/boolean.out @@ -566,6 +566,25 @@ SELECT isnul OR istrue OR isfalse FROM booltbl4; t (1 row) +-- Casts +SELECT 0::boolean; + bool +------ + f +(1 row) + +SELECT 1::boolean; + bool +------ + t +(1 row) + +SELECT 2::boolean; + bool +------ + t +(1 row) + -- -- Clean up -- Many tables are retained by the regression test, but these do not seem diff --git a/src/test/regress/sql/boolean.sql b/src/test/regress/sql/boolean.sql index bc9937d692..cde6cd3576 100644 --- a/src/test/regress/sql/boolean.sql +++ b/src/test/regress/sql/boolean.sql @@ -251,6 +251,12 @@ SELECT istrue OR isfalse OR isnul FROM booltbl4; SELECT isnul OR istrue OR isfalse FROM booltbl4; +-- Casts +SELECT 0::boolean; +SELECT 1::boolean; +SELECT 2::boolean; + + -- -- Clean up -- Many tables are retained by the regression test, but these do not seem -- 2.43.0 --/1M/m83OTNDtKeu/--