Re: BUG #17765: SELECT CAST(true AS BIGINT);

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "vvinnikov(at)list(dot)ru" <vvinnikov(at)list(dot)ru>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17765: SELECT CAST(true AS BIGINT);
Date: 2023-01-31 14:48:53
Message-ID: CAKFQuwaubwk8FHRnztvJFq-LcgbeEAxXnbu44fjPDdjfd=JG-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tuesday, January 31, 2023, PG Bug reporting form <noreply(at)postgresql(dot)org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference: 17765
> Logged by: Vladimir Vinnikov
> Email address: vvinnikov(at)list(dot)ru
> PostgreSQL version: 15.1
> Operating system: x86_64-pc-linux-gnu
> Description:
>
> ERROR: cannot cast type boolean to bigint
>
> That's inconsistent since casting boolean to int is OK (SELECT CAST(true AS
> INT);) or double casting is OK (SELECT CAST(CAST(true AS INT) AS BIGINT);).
>
>
If you want to create your own cast by all means, but just because we are
stuck with allowing bool-to-int doesn’t mean we have allow bool-to-bigint.
This is neither a big nor, IMO, a desirable feature. Casts that don’t make
sense should not exist. And I have no clue how the double-casting example
means anything here. Of course integer to bigint is a valid cast.

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2023-01-31 15:00:25 Re: BUG #17765: SELECT CAST(true AS BIGINT);
Previous Message PG Bug reporting form 2023-01-31 13:39:58 BUG #17765: SELECT CAST(true AS BIGINT);