Skip to content

ASCII_CHAR(13) being first character of EOL is ignored by ascii_val(), char_length() and comparison operator "=" #8585

Open
@pavel-zotov

Description

@pavel-zotov

Consider two .sql scripts from attached .zip file.
sql-check-EOL-handling_-_linux-vs-windows.zip

File "check-linux-line-EOL.sql" was created in Linux text editor (one that built-in in mc) and, of couse, has appropriate EOL characters = ascii_char(10):
Image

File "check-windows-line-EOL.sql" was created in Windows and has EOL = concatenated ascii_char(13) and ascii_char(10):
Image

Now run this scriprs in corresponding OS.
On Linux output will be expected:

select ascii_val( '
' )
from rdb$database;
       10
-------------------------------------------------------
select char_length( '
' )
from rdb$database;
           1
-------------------------------------------------------
select ascii_char(10) = '
'
from rdb$database;
<true>
-------------------------------------------------------
select '
' = ascii_char(10)
from rdb$database;
<true>
-------------------------------------------------------
select trim('
') = trim(ascii_char(10))
from rdb$database;
<true>

On Windows output shows that ASCII_CHAR() ignores first character of EOL that is used on that OS, i.e. chr(13).
And we get wrong results for all statements of this script:

select ascii_val( '
' )
from rdb$database;
       10 ---------------- ?? why not 13 ??
-------------------------------------------------------
select char_length( '
' )
from rdb$database;
           1 --------------------- ?? why not 2 ??
-------------------------------------------------------
select ascii_char(13) || ascii_char(10) = '
'
from rdb$database;
<false>
-------------------------------------------------------
select '
' = ascii_char(13) || ascii_char(10)
from rdb$database;
<false>

PS.
Checked on 6.0.0.765

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions