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 1qVpjo-001KUc-Gr for pgsql-general@arkaria.postgresql.org; Tue, 15 Aug 2023 08:49:17 +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 1qVpjn-00CQen-3p for pgsql-general@arkaria.postgresql.org; Tue, 15 Aug 2023 08:49:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qVpjm-00CQef-MX for pgsql-general@lists.postgresql.org; Tue, 15 Aug 2023 08:49:14 +0000 Received: from mail.proses.de ([87.234.246.173]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qVpji-000Fi9-0I for pgsql-general@lists.postgresql.org; Tue, 15 Aug 2023 08:49:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quipsy.de; s=seg; t=1692089348; bh=MeL94roMiX2dd4XjcQxzCvpeQDp+8p3GTGmDUgG6Er4=; h=From:To:Subject:Date; b=YQw/qefLYZLDSo/O2K94vC6TF0x+1BmRwXttjwGyaGIEhgcKB3ErQUTBODIrbBGC6 cnEbUq7SMZSVmy32lEjfOUnBsYUfjEZ8Ow3v6A2q0NL9hdJ7s4kLtjozMbhFU3AsDe qo45OXsvDv51FumdeoQXXvfjATZgBO3FAF2FO0ncBRXfJFHFDdajMMcRhqWXYmhD+E yJPe43RcKd23TNjQmriv62ND1ukBYynjL98LxPIVVpo7OADdYmvxQXOzhQwVmE6fpB xjSvqAVpYaM55pgYVAjiNFGQLjGqHRFEBs55VroL3hSCFsHfFWdLRC426yp5dEy85p UPbI1U8A/WBOA== Received: from ProSeS-MX2016.proses.de (Not Verified[10.147.37.34]) by mail.proses.de with Trustwave SEG (v10,0,1,2030) id ; Tue, 15 Aug 2023 10:49:08 +0200 Received: from ProSeS-MX2016.proses.de (10.147.37.34) by ProSeS-MX2016.proses.de (10.147.37.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.2242.10; Tue, 15 Aug 2023 10:49:08 +0200 Received: from ProSeS-MX2016.proses.de ([::1]) by ProSeS-MX2016.proses.de ([::1]) with mapi id 15.01.2242.010; Tue, 15 Aug 2023 10:49:08 +0200 From: "[Quipsy] Markus Karg" To: "pgsql-general@lists.postgresql.org" Subject: Cast INTEGER to BIT confusion Thread-Topic: Cast INTEGER to BIT confusion Thread-Index: AdnPU7wz/gKWq6bxS6CYQv5fuMPMIQ== Date: Tue, 15 Aug 2023 08:49:08 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.147.32.78] Content-Type: multipart/alternative; boundary="_000_fbc716336d544e93b6af5e11af3e4aa0quipsyde_" MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.4 cv=acffITkt c=1 sm=1 tr=0 ts=64db3c04 a=hljXQ6ALYVQa6Cx5z6SxUg==:117 a=xqWC_Br6kY4A:10 a=O53yQbXMW-gA:10 a=UttIx32zK-AA:10 a=sd0gIsOKhztxXMGYnHwA:9 a=CjuIK1q_8ugA:10 a=yMhMjlubAAAA:8 a=SSmOFEACAAAA:8 a=q6qecEnCnAk3WEluTigA:9 a=KhE03BznkzLXKUP3:21 a=gKO2Hq4RSVkA:10 a=UiCQ7L4-1S4A:10 a=hTZeC7Yk6K0A:10 a=frz4AuCg-hUA:10 a=rVnDm9A_-c-k2ki-JAcA:9 X-SEG-SpamProfiler-Score: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_fbc716336d544e93b6af5e11af3e4aa0quipsyde_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hello PostgreSQL Community, I have 25+ years of experience with some other RDBMS, but I am a PostgreSQL= starter, so I assume the following is rather a simple beginner's question.= ..: I like to store just a single bit but that can be either 1 or 0, so I tried= to do this: CREATE TABLE T (c BIT); INSERT INTO T VALUES (1); -- I MUST NOT change both lines in any way as these are part of a third-par= ty application! Unfortunately this tells me: column "c" is of type bit but expression is of type integer So I logged in as a cluster admin and I tried this: CREATE CAST (integer AS bit) WITH INOUT AS IMPLICIT; Unfortunately that tells me: cast from type integer to type bit already exists This is confusing! Apparently PostgreSQL 15.3 comes with the needed cast ou= t-of-the-box but it does not apply it? This is confusing! What is my fault? Thanks! -Markus --_000_fbc716336d544e93b6af5e11af3e4aa0quipsyde_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hello PostgreSQL Community,

 

I have 25+ years of experience with some other R= DBMS, but I am a PostgreSQL starter, so I assume the following is rather a = simple beginner’s question…:

 

I like to store just a single bit but that can be ei= ther 1 or 0, so I tried to do this:

 

CREATE TABLE T (c BIT);

INSERT INTO T VALUES (1);

-- I MUST NOT change both lines in any way as these= are part of a third-party application!

 

Unfortunately this tells me:

 

column "c" is = of type bit but expression is of type integer

 

So I logged in as a cluster admin and I tried this:<= o:p>

 

CREATE CAST (integer AS bit) WITH INOUT AS IMPLICIT= ;

 

Unfortunately that tells me:

 

cast from type integer t= o type bit already exists

 

This is confusing! Apparently PostgreSQL 15.3 comes = with the needed cast out-of-the-box but it does not apply it? This is confu= sing!

 

What is my fault?

 

Thanks!

-Markus

--_000_fbc716336d544e93b6af5e11af3e4aa0quipsyde_--