add config and fix style check

This commit is contained in:
Han Fei 2022-05-31 23:18:05 +08:00
parent 7870e02fdf
commit 5693e6212d
3 changed files with 11 additions and 3 deletions

View File

@ -584,6 +584,8 @@ static constexpr UInt64 operator""_GiB(unsigned long long value)
\
M(Bool, allow_unrestricted_reads_from_keeper, false, "Allow unrestricted (without condition on path) reads from system.zookeeper table, can be handy, but is not safe for zookeeper", 0) \
\
M(Bool, allow_writes_to_zookeeper, false, "Allow writes to system.zookeeper table, can be handy, but is not safe for zookeeper", 0) \
\
/** Experimental functions */ \
M(Bool, allow_experimental_funnel_functions, false, "Enable experimental functions for funnel analysis.", 0) \
M(Bool, allow_experimental_nlp_functions, false, "Enable experimental functions for natural language processing.", 0) \

View File

@ -21,7 +21,7 @@
#include <boost/algorithm/string.hpp>
#include <algorithm>
#include <deque>
#include <limits.h>
#include <climits>
namespace DB
@ -53,7 +53,7 @@ struct ZkNodeCache
{
/// If this node has an empty name, just skip it.
/// Possibly a "/a//b///c//d/" will cause empty node.
while(index < nodes.size() && nodes[index].empty())
while (index < nodes.size() && nodes[index].empty())
++index;
if (index == nodes.size())
@ -130,7 +130,8 @@ public:
throw Exception("Column `name` should not be empty", ErrorCodes::BAD_ARGUMENTS);
}
if (path.size() + name.size() > PATH_MAX) {
if (path.size() + name.size() > PATH_MAX)
{
throw Exception("Sum of `name` length and `path` length should not exceed PATH_MAX", ErrorCodes::BAD_ARGUMENTS);
}
@ -151,6 +152,8 @@ public:
SinkToStoragePtr StorageSystemZooKeeper::write(const ASTPtr &, const StorageMetadataPtr &, ContextPtr context)
{
if (!context->getSettingsRef().allow_writes_to_zookeeper)
throw Exception("Prohibit writing to system.zookeeper unless `set allow_writes_to_zookeeper = 'true'`", ErrorCodes::BAD_ARGUMENTS);
Block write_header;
write_header.insert(ColumnWithTypeAndName(std::make_shared<DataTypeString>(), "name"));
write_header.insert(ColumnWithTypeAndName(std::make_shared<DataTypeString>(), "value"));

View File

@ -1,6 +1,9 @@
-- Tags: zookeeper
insert into system.zookeeper (name, path, value) values ('a', '/b', 'y'); -- { serverError 36 }
set allow_unrestricted_reads_from_keeper = 'true';
set allow_writes_to_zookeeper = 'true';
drop table if exists test_zkinsert;