Prepend slash to path for system.zookeeper queries

path should starts with '/', otherwise ZBADARGUMENTS will be thrown in
ZooKeeper::sendThread and the session will fail.
This commit is contained in:
Azat Khuzhin 2020-06-11 20:51:14 +03:00
parent d5c2008c7d
commit 176ebb26e0

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);