ClickHouse / ClickHouse/clickhouse-odbc

SQLConnect fails with passwords containing a closing curly brace

Open
#497 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
285
Forks
105
Avg merge
3h 56m
Merged PRs (30d)
3

Description

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
* Driver version: [1.3.3.20250317](https://github.com/ClickHouse/clickhouse-odbc/releases/tag/1.3.3.20250317)
* OS: Windows, Linux, MacOS

#### ClickHouse server
* ClickHouse Server version: 24.3.18.7

Contributor guide

Open the contributing guide

Research direction

Start at the SQLConnect and SQLDriverConnect entry points and trace the connection-string parsing and brace handling; the issue does not name specific files or tests. Confirm the behavior for passwords containing `}`, semicolons, and spaces, then add regression coverage showing that escaped braces parse correctly without breaking existing connection strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.