Subject | Re: [firebird-support] Trailing spaces behaviour |
---|---|
Author | Mark Rotteveel |
Post date | 2018-03-20T18:07:12Z |
On 2018-03-20 15:34, Alexander Tabakov a.tabakov@...
[firebird-support] wrote:
(char/varchar), the shorter value is right padded with blanks to the
length of the longer value before comparison (or at least: behave as if
the shorter value is blank-padded). Blanks are either spaces (0x20) for
'normal' strings or NUL (0x00) for binary strings.
Mark
[firebird-support] wrote:
> Hi All,Yes it is. The SQL standard specifies that when comparing strings
>
> I have found strange behaviour concerning trailing spaces - following
> strings are equal:
>
> 'ABC ' = 'ABC'
>
> You can try the following query:
>
> _select_
> _ case when 'ABC ' = 'ABC' then 1 else 0 end,_
> _ case when cast('ABC ' as varchar(10)) = cast('ABC' as
> varchar(10)) then 1 else 0 end,_
> _ char_length('ABC '),_
> _ char_length('ABC')_
> _from_
> _ rdb$database_
>
> This query was tested on FB v.1.5.6, 2.5.8 & 3.0.3 - while char length
> (or strlen on 1.5) is different, the strings are always equal.
>
> Is this by design :)
(char/varchar), the shorter value is right padded with blanks to the
length of the longer value before comparison (or at least: behave as if
the shorter value is blank-padded). Blanks are either spaces (0x20) for
'normal' strings or NUL (0x00) for binary strings.
Mark