Merge pull request #11613 from azat/system.zookeeper-path-prepend-slash

Prepend slash for path while querying system.zookeeper
This commit is contained in:
alexey-milovidov 2020-06-12 18:19:10 +03:00 committed by GitHub
commit fc8da2abd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,8 +112,13 @@ void StorageSystemZooKeeper::fillData(MutableColumns & res_columns, const Contex
zkutil::ZooKeeperPtr zookeeper = context.getZooKeeper();
String path_corrected;
/// path should starts with '/', otherwise ZBADARGUMENTS will be thrown in
/// ZooKeeper::sendThread and the session will fail.
if (path[0] != '/')
path_corrected = '/';
path_corrected += path;
/// In all cases except the root, path must not end with a slash.
String path_corrected = path;
if (path_corrected != "/" && path_corrected.back() == '/')
path_corrected.resize(path_corrected.size() - 1);