Re: Inconsistent cast to "char" - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Inconsistent cast to "char"
Date
Msg-id 2120116.1638473263@sss.pgh.pa.us
Whole thread Raw
In response to Re: Inconsistent cast to "char"  ("Ian R. Campbell" <ian.campbell@thepathcentral.com>)
Responses Re: Inconsistent cast to "char"  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
"Ian R. Campbell" <ian.campbell@thepathcentral.com> writes:
> It makes sense that "char" is not part of the string family. After all,
> "char" != char.

If it allowed more than one byte, maybe you could call it a "string",
but it seems hard to justify without that.

> In the scenarios I give, one would expect the same output for all integer
> width casting inputs, so you have my vote on the change you suggested.

To be clear, the change I'm thinking of would result in errors, not in
silently applying the int4 cast.  As a quick-n-dirty test:

regression=# update pg_type set typcategory = 'x' where typname = 'char';
UPDATE 1
regression=# select 1::int8::"char", 1::int4::"char", 1::int2::"char";
ERROR:  cannot cast type bigint to "char"
LINE 1: select 1::int8::"char", 1::int4::"char", 1::int2::"char";
                      ^

            regards, tom lane



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #17305: to_timestamp accept dates rejected by timestamptz cast
Next
From: Tom Lane
Date:
Subject: Re: Inconsistent cast to "char"