Sam Mason <sam(at)samason(dot)me(dot)uk> wrote:
> you seem to be wanting in-memory representations of "string like
> types" to all use the same representation and only use the actual
> types when saving to/from disk.
Doing so when actually assigning to *something* of the more specific
type would probably be better. In my view, that's not happening here;
although I see that the code currently doesn't recognize the
difference.
>> test=# select case when true then 'xxx' else 'a'::"char" end from
t;
>> case
>> ------
>> x
>> (1 row)
>
> With the patch I gave, or something like it, this would throw an
> error because 'xxx' is being used to initialize a value of "char"
> type.
As I read the semantics of the CASE predicate, it returns one of the
given values. 'x' is not one of the given values, regardless of type.
I don't think an error is the right thing, I think returning the
specified value is the right thing. I don't think it's a good thing
that the type system decides that the result type for this case
predicate is "char" and that 'xxx' needs to be coerced to that type.
-Kevin