pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: [Quipsy] Markus Karg <karg@quipsy.de>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Cast INTEGER to BIT confusion
Date: Tue, 15 Aug 2023 08:49:08 +0000
Message-ID: <fbc716336d544e93b6af5e11af3e4aa0@quipsy.de> (raw)

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-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:

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 out-of-the-box but it does not apply it? This is confusing!

What is my fault?

Thanks!
-Markus

view thread (6+ messages)  latest in thread

Message-ID: <fbc716336d544e93b6af5e11af3e4aa0@quipsy.de>
Permalink:  ../fbc716336d544e93b6af5e11af3e4aa0@quipsy.de/
Also on:    postgresql.org/message-id/fbc716336d544e93b6af5e11af3e4aa0@quipsy.de

 · 

reply

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: karg@quipsy.de
  Subject: Re: Cast INTEGER to BIT confusion
  In-Reply-To: <fbc716336d544e93b6af5e11af3e4aa0@quipsy.de>
  References: <fbc716336d544e93b6af5e11af3e4aa0@quipsy.de>

* 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