Skip to content

Invalid UTF-8 name in connection string produces wrong error message in Linux #432

@david-puglielli

Description

@david-puglielli

See sqlsrv_connStr.phpt. When the server name is invalid in UTF-8, the connection attempt fails with an error message as follows:

Array
(
    [0] => Array
        (
            [0] => HYT00
            [SQLSTATE] => HYT00
            [1] => 0
            [code] => 0
            [2] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired
            [message] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]Login timeout expired
        )

    [1] => Array
        (
            [0] => 08001
            [SQLSTATE] => 08001
            [1] => 11002
            [code] => 11002
            [2] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: Error code 0x2AFA
            [message] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: Error code 0x2AFA
        )

    [2] => Array
        (
            [0] => 08001
            [SQLSTATE] => 08001
            [1] => 11002
            [code] => 11002
            [2] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
            [message] => [unixODBC][Microsoft][ODBC Driver 13 for SQL Server]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.
        )

)

This implies that the error is network-related, when in fact it is because the server name is not valid. The expected error message should correctly indicate that An error occurred translating the connection string to UTF-16. This may be fixed by replacing ToUtf16() with ToUtf16Strict() in convert_string_from_default_encoding() in core_util.cpp, but this change causes other test failures so further investigation is required.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions