Skip to content

Dash in database name is not supported by V2 client #2463

@k-popov

Description

@k-popov

It looks like parsing of JDBC URL does not support dash (hyphen) in database name. This results in Code: 81. DB::Exception: Database test does not exist. when trying to connect to database named test-dash.

Found in 0.8.4 but this part of code in master is the same.

RegEx at

private static final Pattern URL_REGEXP = Pattern.compile("(https?:)?\\/\\/([\\w\\.\\-]+|\\[[0-9a-fA-F:]+\\]):?([\\d]*)(?:\\/([\\w]+))?\\/?\\??(.*)$");
shows the following when testing:

>>> import re >>> re.match('(https?:)?\\/\\/([\\w\\.\\-]+|\\[[0-9a-fA-F:]+\\]):?([\\d]*)(?:\\/([\\w]+))?\\/?\\??(.*)$', 'https://host-name:8123/test-dash?param=pampam').groups() ('https:', 'host-name', '8123', 'test', '-dash?param=pampam') 

(Tested in python as it was a quick test but I assume \w is the same)
Note the 4th group only has test and -dash is already in 5th group where params should reside.

Adding - to characters set seems to fix parsing:

> re.match('(https?:)?\\/\\/([\\w\\.\\-]+|\\[[0-9a-fA-F:]+\\]):?([\\d]*)(?:\\/([\\w-]+))?\\/?\\??(.*)$', 'https://host-name:8123/test-dash?param=pampam').groups() ('https:', 'host-name', '8123', 'test-dash', 'param=pampam') 

Here the 4th group contains full DB name test-dash

There was already a similar issue long ago: #251 but that was for client V1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions