22.02.2021 13:40, Dimitry Sibiryakov wrote:
Currently Firebird uses rule "CHAR(X)+CHAR(Y)=>CHAR(MAX(X,Y))".
Theoretically it can be changed into "CHAR(X)+CHAR(Y)=>CHAR(X) if
X==Y and CHAR(X)+CHAR(Y)=>VARCHAR(MAX(X,Y)) if X!=Y".
But what SQL standard says about it?
IIRC, current implementation was made accordingly to the standard. But
later I've discovered some inconsistencies and perhaps we understood
something wrong, or maybe the standard was changed in newer versions.
First thing which IMO is totally wrong is to use the same rules for
CASE/COALESCE and UNION. I have blogged about that in the past:
https://dyemanov.github.io/data-types/
Second, I'd reconsider the CHAR vs VARCHAR rules in CASE/COALESCE to
derive VARCHAR in all tricky cases. It's worth double checking the SQL
specification before that, but I'd go that way (prefer VARCHAR over CHAR
if lengths are different) even if it's non-standard.
Dmitry
Firebird-Devel mailing list, web interface at
https://lists.sourceforge.net/lists/listinfo/firebird-devel