Skip to content

SQLConnect fails with passwords containing a closing curly brace #497

@slabko

Description

@slabko

When calling SQLConnect with a password that contains a closing curly brace (}), the driver throws the following error:

1:[HY000][1][unixODBC]';' expected

This occurs because the driver constructs a connection string that wraps every value in curly braces, e.g.:

DSN={your dsn name};Username={your_user_name};Password={your_password}

If the password includes a closing curly brace, the connection string becomes unparsable.

However, the driver works correctly with such passwords when using SQLDriverConnect, as long as the password is not wrapped in curly braces, which is not always possible for complicated passwords, for example the ones that contain semicolons.

This issue could be resolved by introducing an escape sequence for curly braces. For example, Microsoft uses double braces as escape sequences: {{ for { and }} for }. Currently, the driver does not support any escape sequence for braces.

Implications:

Most applications, such as Power BI, do not use SQLConnect; instead, they construct the entire connection string and use SQLDriverConnect. In this case, a password containing a } character is not an issue. It only becomes problematic when the password contains both a } and either a ; or a space. This is because ; forces the application to wrap the password in curly braces, e.g. {My; Pass}). If the password also contains a }, the driver—lacking support for escape sequences for closing curly braces—cannot determine where the password ends in the connection string.

Configuration

Environment

ClickHouse server

  • ClickHouse Server version: 24.3.18.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions