Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
>> And I'm not even sure how I'd explain the rules to someone.
>
> text is preferred to "char" which is preferred to unknown.
>
> This particular example would be less confusing if 'Hey'::"char"
> threw an error, but that behavior is the result of an ancient
> (bad?) decision in the input function of one legacy datatype.
> It's not, IMNSHO, evidence of an overall failure of the type system
> as a whole.
So the behavior of the "char" type is anomalous in this regard? Other
character-based types behave like varchar (which has the behavior I
would expect here)? That is encouraging. Why isn't the behavior of
"char" in this regard considered a bug to be fixed?
I'm not sure I'm exactly understanding why the varchar(2) worked,
though. Perhaps it would be more clear if I grasped why *that* one
does what I would think is the right thing. At this point my first
guess would be that it discards the length for a varchar, and just
treats it as text (or some other "neutral" character-based type). If
so, perhaps "char" should do the same?
-Kevin