Merge branch 'master' of https://github.com/yandex/ClickHouse into llvm-jit

This commit is contained in:
pyos 2018-05-10 13:25:26 +03:00
commit 4776168c3b
13 changed files with 269 additions and 204 deletions

View File

@ -108,6 +108,7 @@ Block MergeSortingBlockInputStream::readImpl()
*/
if (max_bytes_before_external_sort && sum_bytes_in_blocks > max_bytes_before_external_sort)
{
Poco::File(tmp_path).createDirectories();
temporary_files.emplace_back(new Poco::TemporaryFile(tmp_path));
const std::string & path = temporary_files.back()->path();
WriteBufferFromFile file_buf(path);

View File

@ -837,6 +837,7 @@ void Aggregator::writeToTemporaryFile(AggregatedDataVariants & data_variants)
Stopwatch watch;
size_t rows = data_variants.size();
Poco::File(params.tmp_path).createDirectories();
auto file = std::make_unique<Poco::TemporaryFile>(params.tmp_path);
const std::string & path = file->path();
WriteBufferFromFile file_buf(path);

View File

@ -1362,10 +1362,12 @@ public:
}
}
ioctl(0, TIOCGWINSZ, &terminal_size);
#define DECLARE_SETTING(TYPE, NAME, DEFAULT, DESCRIPTION) (#NAME, boost::program_options::value<std::string> (), DESCRIPTION)
/// Main commandline options related to client functionality and all parameters from Settings.
boost::program_options::options_description main_description("Main options");
boost::program_options::options_description main_description("Main options", terminal_size.ws_col);
main_description.add_options()
("help", "produce help message")
("config-file,c", boost::program_options::value<std::string>(), "config-file path")
@ -1451,7 +1453,7 @@ public:
}
}
/// Extract settings and limits from the options.
/// Extract settings from the options.
#define EXTRACT_SETTING(TYPE, NAME, DEFAULT, DESCRIPTION) \
if (options.count(#NAME)) \
context.setSetting(#NAME, options[#NAME].as<std::string>());

View File

@ -16,6 +16,7 @@
#include <Common/Macros.h>
#include <Common/Config/ConfigProcessor.h>
#include <Common/escapeForFileName.h>
#include <Common/ClickHouseRevision.h>
#include <IO/ReadBufferFromString.h>
#include <IO/WriteBufferFromString.h>
#include <IO/WriteBufferFromFileDescriptor.h>
@ -27,6 +28,8 @@
#include <AggregateFunctions/registerAggregateFunctions.h>
#include <TableFunctions/registerTableFunctions.h>
#include <Storages/registerStorages.h>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options.hpp>
namespace DB
@ -53,178 +56,42 @@ void LocalServer::initialize(Poco::Util::Application & self)
Poco::Util::Application::initialize(self);
// Turn off server logging to stderr
if (config().has("silent"))
if (!config().has("verbose"))
{
Poco::Logger::root().setLevel("none");
Poco::Logger::root().setChannel(Poco::AutoPtr<Poco::NullChannel>(new Poco::NullChannel()));
}
}
void LocalServer::defineOptions(Poco::Util::OptionSet& _options)
void LocalServer::applyCmdSettings(Context & context)
{
Poco::Util::Application::defineOptions (_options);
_options.addOption(
Poco::Util::Option("config-file", "", "Load configuration from a given file")
.required(false)
.repeatable(false)
.argument("[config.xml]")
.binding("config-file"));
/// Arguments that define first query creating initial table:
/// (If structure argument is omitted then initial query is not generated)
_options.addOption(
Poco::Util::Option("structure", "S", "Structure of initial table(list columns names with their types)")
.required(false)
.repeatable(false)
.argument("[name Type]")
.binding("table-structure"));
/// Turn off logging
_options.addOption(
Poco::Util::Option("silent", "s", "Quiet mode, print only errors")
.required(false)
.repeatable(false)
.binding("silent"));
_options.addOption(
Poco::Util::Option("table", "N", "Name of initial table")
.required(false)
.repeatable(false)
.argument("[table]")
.binding("table-name"));
_options.addOption(
Poco::Util::Option("file", "f", "Path to file with data of initial table (stdin if not specified)")
.required(false)
.repeatable(false)
.argument(" stdin")
.binding("table-file"));
_options.addOption(
Poco::Util::Option("input-format", "if", "Input format of initial table data")
.required(false)
.repeatable(false)
.argument("<TSV>")
.binding("table-data-format"));
/// List of queries to execute
_options.addOption(
Poco::Util::Option("query", "q", "Queries to execute")
.required(false)
.repeatable(false)
.argument("<query>")
.binding("query"));
/// Default Output format
_options.addOption(
Poco::Util::Option("output-format", "of", "Default output format")
.required(false)
.repeatable(false)
.argument("[TSV]", true)
.binding("output-format"));
/// Alias for previous one, required for clickhouse-client compatibility
_options.addOption(
Poco::Util::Option("format", "", "Default output format")
.required(false)
.repeatable(false)
.argument("[TSV]", true)
.binding("format"));
_options.addOption(
Poco::Util::Option("stacktrace", "", "Print stack traces of exceptions")
.required(false)
.repeatable(false)
.binding("stacktrace"));
_options.addOption(
Poco::Util::Option("verbose", "", "Print info about execution of queries")
.required(false)
.repeatable(false)
.noArgument()
.binding("verbose"));
_options.addOption(
Poco::Util::Option("help", "", "Display help information")
.required(false)
.repeatable(false)
.noArgument()
.binding("help")
.callback(Poco::Util::OptionCallback<LocalServer>(this, &LocalServer::handleHelp)));
/// These arrays prevent "variable tracking size limit exceeded" compiler notice.
static const char * settings_names[] = {
#define DECLARE_SETTING(TYPE, NAME, DEFAULT, DESCRIPTION) #NAME,
APPLY_FOR_SETTINGS(DECLARE_SETTING)
#undef DECLARE_SETTING
nullptr};
for (const char ** name = settings_names; *name; ++name)
_options.addOption(Poco::Util::Option(*name, "", "Settings.h").required(false).argument("<value>")
.repeatable(false).binding(*name));
}
void LocalServer::applyOptions()
{
context->setDefaultFormat(config().getString("output-format", config().getString("format", "TSV")));
/// settings and limits could be specified in config file, but passed settings has higher priority
#define EXTRACT_SETTING(TYPE, NAME, DEFAULT, DESCRIPTION) \
if (config().has(#NAME) && !context->getSettingsRef().NAME.changed) \
context->setSetting(#NAME, config().getString(#NAME));
if (cmd_settings.NAME.changed) \
context.getSettingsRef().NAME = cmd_settings.NAME;
APPLY_FOR_SETTINGS(EXTRACT_SETTING)
#undef EXTRACT_SETTING
}
void LocalServer::displayHelp()
{
Poco::Util::HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("[initial table definition] [--query <query>]");
helpFormatter.setHeader("\n"
"clickhouse-local allows to execute SQL queries on your data files via single command line call.\n"
"To do so, intially you need to define your data source and its format.\n"
"After you can execute your SQL queries in the usual manner.\n"
"There are two ways to define initial table keeping your data:\n"
"either just in first query like this:\n"
" CREATE TABLE <table> (<structure>) ENGINE = File(<input-format>, <file>);\n"
"either through corresponding command line parameters."
);
helpFormatter.setWidth(132); /// 80 is ugly due to wide settings params
helpFormatter.format(std::cerr);
std::cerr << "Example printing memory used by each Unix user:\n"
"ps aux | tail -n +2 | awk '{ printf(\"%s\\t%s\\n\", $1, $4) }' | "
"clickhouse-local -S \"user String, mem Float64\" -q \"SELECT user, round(sum(mem), 2) as memTotal FROM table GROUP BY user ORDER BY memTotal DESC FORMAT Pretty\"\n";
}
void LocalServer::handleHelp(const std::string & /*name*/, const std::string & /*value*/)
{
displayHelp();
stopOptionsProcessing();
}
/// If path is specified and not empty, will try to setup server environment and load existing metadata
void LocalServer::tryInitPath()
{
if (!config().has("path") || (path = config().getString("path")).empty())
return;
std::string path = config().getString("path", "");
Poco::trimInPlace(path);
if (path.empty())
if (!path.empty())
{
if (path.back() != '/')
path += '/';
context->setPath(path);
return;
if (path.back() != '/')
path += '/';
}
context->setPath(path);
StatusFile status{path + "status"};
/// In case of empty path set paths to helpful directories
std::string cd = Poco::Path::current();
context->setTemporaryPath(cd + "tmp");
context->setFlagsPath(cd + "flags");
context->setUserFilesPath(""); // user's files are everywhere
}
@ -235,11 +102,8 @@ try
if (!config().has("query") && !config().has("table-structure")) /// Nothing to process
{
if (!config().hasOption("help"))
{
if (!config().hasOption("silent"))
std::cerr << "There are no queries to process." << std::endl;
displayHelp();
}
return Application::EXIT_OK;
}
@ -258,7 +122,7 @@ try
context->setApplicationType(Context::ApplicationType::LOCAL);
tryInitPath();
applyOptions();
std::optional<StatusFile> status;
/// Skip temp path installation
@ -304,13 +168,17 @@ try
* Otherwise, metadata of temporary File(format, EXPLICIT_PATH) tables will pollute metadata/ directory;
* if such tables will not be dropped, clickhouse-server will not be able to load them due to security reasons.
*/
const std::string default_database = "_local";
std::string default_database = config().getString("default_database", "_local");
context->addDatabase(default_database, std::make_shared<DatabaseMemory>(default_database));
context->setCurrentDatabase(default_database);
applyCmdSettings(*context);
if (!path.empty())
if (!context->getPath().empty())
{
LOG_DEBUG(log, "Loading metadata from " << path);
/// Lock path directory before read
status.emplace(context->getPath() + "status");
LOG_DEBUG(log, "Loading metadata from " << context->getPath());
loadMetadataSystem(*context);
attachSystemTables();
loadMetadata(*context);
@ -330,20 +198,8 @@ try
}
catch (const Exception & e)
{
bool print_stack_trace = config().has("stacktrace");
std::string text = e.displayText();
auto embedded_stack_trace_pos = text.find("Stack trace");
if (std::string::npos != embedded_stack_trace_pos && !print_stack_trace)
text.resize(embedded_stack_trace_pos);
std::cerr << "Code: " << e.code() << ". " << text << std::endl << std::endl;
if (print_stack_trace && std::string::npos == embedded_stack_trace_pos)
{
std::cerr << "Stack trace:" << std::endl << e.getStackTrace().toString();
}
if (!config().hasOption("silent"))
std::cerr << getCurrentExceptionMessage(config().hasOption("stacktrace"));
/// If exception code isn't zero, we should return non-zero return code anyway.
return e.code() ? e.code() : -1;
@ -397,32 +253,52 @@ void LocalServer::attachSystemTables()
void LocalServer::processQueries()
{
Logger * log = &logger();
String initial_create_query = getInitialCreateTableQuery();
String queries_str = initial_create_query + config().getString("query");
bool verbose = config().hasOption("verbose");
std::vector<String> queries;
auto parse_res = splitMultipartQuery(queries_str, queries);
if (!parse_res.second)
throw Exception("Cannot parse and execute the following part of query: " + String(parse_res.first), ErrorCodes::SYNTAX_ERROR);
context->setSessionContext(*context);
context->setQueryContext(*context);
context->setUser("default", "", Poco::Net::SocketAddress{}, "");
context->setCurrentQueryId("");
applyCmdSettings(*context);
bool echo_query = config().hasOption("echo") || config().hasOption("verbose");
std::exception_ptr exception;
for (const auto & query : queries)
{
ReadBufferFromString read_buf(query);
WriteBufferFromFileDescriptor write_buf(STDOUT_FILENO);
if (verbose)
LOG_INFO(log, "Executing query: " << query);
if (echo_query)
std::cerr << query << "\n";
executeQuery(read_buf, write_buf, /* allow_into_outfile = */ true, *context, {});
try
{
executeQuery(read_buf, write_buf, /* allow_into_outfile = */ true, *context, {});
}
catch (...)
{
if (!config().hasOption("ignore-error"))
throw;
if (!exception)
exception = std::current_exception();
if (!config().has("silent"))
std::cerr << getCurrentExceptionMessage(config().hasOption("stacktrace"));
}
}
if (exception)
std::rethrow_exception(exception);
}
static const char * minimal_default_user_xml =
@ -477,6 +353,133 @@ void LocalServer::setupUsers()
throw Exception("Can't load config for users", ErrorCodes::CANNOT_LOAD_CONFIG);
}
static void showClientVersion()
{
std::cout << "ClickHouse client version " << DBMS_VERSION_MAJOR
<< "." << DBMS_VERSION_MINOR
<< "." << ClickHouseRevision::get()
<< "." << std::endl;
}
std::string LocalServer::getHelpHeader() const
{
return
"usage: clickhouse-local [initial table definition] [--query <query>]\n"
"clickhouse-local allows to execute SQL queries on your data files via single command line call."
" To do so, initially you need to define your data source and its format."
" After you can execute your SQL queries in usual manner.\n"
"There are two ways to define initial table keeping your data."
" Either just in first query like this:\n"
" CREATE TABLE <table> (<structure>) ENGINE = File(<input-format>, <file>);\n"
"Either through corresponding command line parameters --table --structure --input-format and --file.";
}
std::string LocalServer::getHelpFooter() const
{
return
"Example printing memory used by each Unix user:\n"
"ps aux | tail -n +2 | awk '{ printf(\"%s\\t%s\\n\", $1, $4) }' | "
"clickhouse-local -S \"user String, mem Float64\" -q"
" \"SELECT user, round(sum(mem), 2) as mem_total FROM table GROUP BY user ORDER"
" BY mem_total DESC FORMAT PrettyCompact\"";
}
void LocalServer::init(int argc, char ** argv)
{
/// Don't parse options with Poco library, we prefer neat boost::program_options
stopOptionsProcessing();
winsize terminal_size{};
ioctl(0, TIOCGWINSZ, &terminal_size);
namespace po = boost::program_options;
#define DECLARE_SETTING(TYPE, NAME, DEFAULT, DESCRIPTION) (#NAME, po::value<std::string> (), DESCRIPTION)
po::options_description description("Main options", terminal_size.ws_col);
description.add_options()
("help", "produce help message")
("config-file,c", po::value<std::string>(), "config-file path")
("query,q", po::value<std::string>(), "query")
("database,d", po::value<std::string>(), "database")
("table,N", po::value<std::string>(), "name of the initial table")
/// If structure argument is omitted then initial query is not generated
("structure,S", po::value<std::string>(), "structure of the initial table (list of column and type names)")
("file,f", po::value<std::string>(), "path to file with data of the initial table (stdin if not specified)")
("input-format", po::value<std::string>(), "input format of the initial table data")
("format,f", po::value<std::string>(), "default output format (clickhouse-client compatibility)")
("output-format", po::value<std::string>(), "default output format")
("silent,s", "quiet mode, do not print errors")
("stacktrace", "print stack traces of exceptions")
("echo", "print query before execution")
("verbose", "print query and other debugging info")
("ignore-error", "do not stop processing if a query failed")
("version,V", "print version information and exit")
APPLY_FOR_SETTINGS(DECLARE_SETTING);
#undef DECLARE_SETTING
/// Parse main commandline options.
po::parsed_options parsed = po::command_line_parser(argc, argv).options(description).run();
po::variables_map options;
po::store(parsed, options);
if (options.count("version") || options.count("V"))
{
showClientVersion();
exit(0);
}
if (options.count("help"))
{
std::cout << getHelpHeader() << "\n";
std::cout << description << "\n";
std::cout << getHelpFooter() << "\n";
exit(0);
}
/// Extract settings and limits from the options.
#define EXTRACT_SETTING(TYPE, NAME, DEFAULT, DESCRIPTION) \
if (options.count(#NAME)) \
cmd_settings.set(#NAME, options[#NAME].as<std::string>());
APPLY_FOR_SETTINGS(EXTRACT_SETTING)
#undef EXTRACT_SETTING
/// Save received data into the internal config.
if (options.count("config-file"))
config().setString("config-file", options["config-file"].as<std::string>());
if (options.count("query"))
config().setString("query", options["query"].as<std::string>());
if (options.count("database"))
config().setString("default_database", options["database"].as<std::string>());
if (options.count("table"))
config().setString("table-name", options["table"].as<std::string>());
if (options.count("file"))
config().setString("table-file", options["file"].as<std::string>());
if (options.count("structure"))
config().setString("table-structure", options["structure"].as<std::string>());
if (options.count("input-format"))
config().setString("table-data-format", options["input-format"].as<std::string>());
if (options.count("format"))
config().setString("format", options["format"].as<std::string>());
if (options.count("output-format"))
config().setString("output-format", options["output-format"].as<std::string>());
if (options.count("silent"))
config().setBool("silent", true);
if (options.count("stacktrace"))
config().setBool("stacktrace", true);
if (options.count("echo"))
config().setBool("echo", true);
if (options.count("verbose"))
config().setBool("verbose", true);
if (options.count("ignore-error"))
config().setBool("ignore-error", true);
}
}
int mainEntryClickHouseLocal(int argc, char ** argv)

View File

@ -1,8 +1,10 @@
#pragma once
#include <Interpreters/Settings.h>
#include <Poco/Util/Application.h>
#include <memory>
namespace DB
{
@ -19,10 +21,10 @@ public:
void initialize(Poco::Util::Application & self) override;
void defineOptions(Poco::Util::OptionSet& _options) override;
int main(const std::vector<std::string> & args) override;
void init(int argc, char ** argv);
~LocalServer();
private:
@ -34,17 +36,20 @@ private:
std::string getInitialCreateTableQuery();
void tryInitPath();
void applyOptions();
void applyCmdSettings(Context & context);
void attachSystemTables();
void processQueries();
void setupUsers();
void displayHelp();
void handleHelp(const std::string & name, const std::string & value);
std::string getHelpHeader() const;
std::string getHelpFooter() const;
protected:
std::unique_ptr<Context> context;
std::string path;
/// Settings specified via command line args
Settings cmd_settings;
};
}

View File

@ -6,4 +6,12 @@
0 0 0
0 0 0
max_rows_in_distinct 33
max_rows_in_distinct 33
0
SELECT nothing_to_do();
SELECT 42;
42
1

View File

@ -20,8 +20,8 @@ function pack_unpack_compare()
local res_db_file=$(${CLICKHOUSE_CLIENT} --max_threads=1 --query "SELECT $TABLE_HASH FROM test.buf_file")
${CLICKHOUSE_CLIENT} --max_threads=1 --query "SELECT * FROM test.buf FORMAT $3" > "$buf_file"
local res_ch_local1=$(${CLICKHOUSE_LOCAL} -s --structure "$2" --file "$buf_file" --table "my super table" --input-format "$3" --output-format TabSeparated --query "SELECT $TABLE_HASH FROM \`my super table\`")
local res_ch_local2=$(${CLICKHOUSE_LOCAL} -s --structure "$2" --table "my super table" --input-format "$3" --output-format TabSeparated --query "SELECT $TABLE_HASH FROM \`my super table\`" < "$buf_file")
local res_ch_local1=$(${CLICKHOUSE_LOCAL} --structure "$2" --file "$buf_file" --table "my super table" --input-format "$3" --output-format TabSeparated --query "SELECT $TABLE_HASH FROM \`my super table\`")
local res_ch_local2=$(${CLICKHOUSE_LOCAL} --structure "$2" --table "my super table" --input-format "$3" --output-format TabSeparated --query "SELECT $TABLE_HASH FROM \`my super table\`" < "$buf_file")
${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS test.buf"
${CLICKHOUSE_CLIENT} --query "DROP TABLE IF EXISTS test.buf_file"
@ -38,7 +38,15 @@ pack_unpack_compare "SELECT name, is_aggregate FROM system.functions" "name Stri
pack_unpack_compare "SELECT name, is_aggregate FROM system.functions" "name String, is_aggregate UInt8" "Native"
pack_unpack_compare "SELECT name, is_aggregate FROM system.functions" "name String, is_aggregate UInt8" "TSKV"
echo
${CLICKHOUSE_LOCAL} -s -q "CREATE TABLE sophisticated_default
# Check settings are passed correctly
${CLICKHOUSE_LOCAL} --max_rows_in_distinct=33 -q "SELECT name, value FROM system.settings WHERE name = 'max_rows_in_distinct'"
${CLICKHOUSE_LOCAL} -q "SET max_rows_in_distinct=33; SELECT name, value FROM system.settings WHERE name = 'max_rows_in_distinct'"
${CLICKHOUSE_LOCAL} --max_bytes_before_external_group_by=1 --max_block_size=10 -q "SELECT sum(ignore(*)) FROM (SELECT number, count() FROM numbers(1000) GROUP BY number)"
echo
# Check exta options
(${CLICKHOUSE_LOCAL} --ignore-error --echo --silent -q "SELECT nothing_to_do();SELECT 42;" 2>&1 && echo "Wrong RC") || true
echo
${CLICKHOUSE_LOCAL} -q "CREATE TABLE sophisticated_default
(
a UInt8 DEFAULT
(
@ -52,4 +60,19 @@ ${CLICKHOUSE_LOCAL} -s -q "CREATE TABLE sophisticated_default
) ENGINE = Memory; SELECT count() FROM system.tables WHERE name='sophisticated_default';"
# Help is not skipped
[[ `${CLICKHOUSE_LOCAL} -s --help 2>&1 | wc -l` > 100 ]]
[[ `${CLICKHOUSE_LOCAL} --help | wc -l` > 100 ]]
# Check that help width is adaptive
stty cols 99999
rows1=`${CLICKHOUSE_LOCAL} --help | wc -l`
stty cols 80
rows2=`${CLICKHOUSE_LOCAL} --help | wc -l`
[[ $rows1 < $rows2 ]]
stty cols 99999
rows1=`${CLICKHOUSE_CLIENT} --help | wc -l`
stty cols 80
rows2=`${CLICKHOUSE_CLIENT} --help | wc -l`
[[ $rows1 < $rows2 ]]
shopt -s checkwinsize || true

View File

@ -339,6 +339,8 @@ It works for JSONEachRow and TSKV formats.
If the value is true, integers appear in quotes when using JSON\* Int64 and UInt64 formats (for compatibility with most JavaScript implementations); otherwise, integers are output without the quotes.
<a name="format_csv_delimiter"></a>
## format_csv_delimiter
The character to be considered as a delimiter in CSV data. By default, `,`.

View File

@ -4,7 +4,8 @@
Веб-интерфейс для ClickHouse в проекте [Tabix](https://github.com/tabixio/tabix).
Основные особенности:
Основные возможности:
- Работает с ClickHouse напрямую из браузера, без необходимости установки дополнительного ПО.
- Редактор запросов с подсветкой синтаксиса.
- Автодополнение команд.
@ -15,4 +16,17 @@
## HouseOps
[HouseOps](https://github.com/HouseOps/HouseOps) is a unique Desktop ClickHouse Ops UI / IDE for OSX, Linux and Windows.
[HouseOps](https://github.com/HouseOps/HouseOps) — UI/IDE для OSX, Linux и Windows.
Основные возможности:
- Создание запросов.
Планируется разработка следующих возможностей:
- Управление базами.
- Управление пользователями.
- Управление кластером.
- Анализ данных в режиме реального времени.
- Мониторинг кластера.
- Мониторинг реплицированных и Kafka таблиц.

View File

@ -2,7 +2,7 @@
Пользователи и права доступа настраиваются в конфиге пользователей. Обычно это `users.xml`.
Пользователи прописаны в секции users. Рассмотрим фрагмент файла `users.xml`:
Пользователи прописаны в секции `users`. Рассмотрим фрагмент файла `users.xml`:
```xml
<!-- Пользователи и ACL. -->
@ -67,7 +67,7 @@
Пароль указывается либо в открытом виде (не рекомендуется), либо в виде SHA-256. Хэш не содержит соль. В связи с этим, не следует рассматривать такие пароли, как защиту от потенциального злоумышленника. Скорее, они нужны для защиты от сотрудников.
Указывается список сетей, из которых разрешён доступ. В этом примере, список сетей для обеих пользователей, загружается из отдельного файла (/etc/metrika.xml), содержащего подстановку networks. Вот его фрагмент:
Указывается список сетей, из которых разрешён доступ. В этом примере, список сетей для обеих пользователей, загружается из отдельного файла (`/etc/metrika.xml`), содержащего подстановку `networks`. Вот его фрагмент:
```xml
<yandex>
@ -81,17 +81,17 @@
</yandex>
```
Можно было бы указать этот список сетей непосредственно в users.xml, или в файле в директории users.d (подробнее смотрите раздел "Конфигурационные файлы").
Можно было бы указать этот список сетей непосредственно в `users.xml`, или в файле в директории `users.d` (подробнее смотрите раздел "[Конфигурационные файлы](configuration_files.md#configuration_files)").
В конфиге приведён комментарий, указывающий, как можно открыть доступ отовсюду.
Для продакшен использования, указывайте только элементы вида ip (IP-адреса и их маски), так как использование host и host_regexp может вызывать лишние задержки.
Для продакшен использования, указывайте только элементы вида `ip` (IP-адреса и их маски), так как использование `host` и `host_regexp` может вызывать лишние задержки.
Далее указывается используемый профиль настроек пользователя (смотрите раздел "Профили настроек"). Вы можете указать профиль по умолчанию - `default`. Профиль может называться как угодно; один и тот же профиль может быть указан для разных пользователей. Наиболее важная вещь, которую вы можете прописать в профиле настроек - настройку readonly, равную 1, что обеспечивает доступ только на чтение.
Далее указывается используемый профиль настроек пользователя (смотрите раздел "[Профили настроек](settings/settings_profiles.md#settings_profiles)"). Вы можете указать профиль по умолчанию - `default`. Профиль может называться как угодно; один и тот же профиль может быть указан для разных пользователей. Наиболее важная вещь, которую вы можете прописать в профиле настроек `readonly=1`, что обеспечивает доступ только на чтение.
Затем указывается используемая квота (смотрите раздел "Квоты"). Вы можете указать квоту по умолчанию - `default`. Она настроена в конфиге по умолчанию так, что только считает использование ресурсов, но никак их не ограничивает. Квота может называться как угодно; одна и та же квота может быть указана для разных пользователей - в этом случае, подсчёт использования ресурсов делается для каждого пользователя по отдельности.
Затем указывается используемая квота (смотрите раздел "[Квоты](quotas.md#quotas)"). Вы можете указать квоту по умолчанию `default`. Она настроена в конфиге по умолчанию так, что только считает использование ресурсов, но никак их не ограничивает. Квота может называться как угодно. Одна и та же квота может быть указана для разных пользователей, в этом случае подсчёт использования ресурсов делается для каждого пользователя по отдельности.
Также в необязательном разделе `<allow_databases>` можно указать перечень баз, к которым у пользователя будет доступ. По умолчанию пользователю доступны все базы. Можно указать базу данных `default`, в этом случае пользователь получит доступ к базе данных по умолчанию.
Также, в необязательном разделе `<allow_databases>` можно указать перечень баз, к которым у пользователя будет доступ. По умолчанию пользователю доступны все базы. Можно указать базу данных `default`, в этом случае пользователь получит доступ к базе данных по умолчанию.
Доступ к БД `system` всегда считается разрешённым (так как эта БД используется для выполнения запросов).

View File

@ -1,3 +1,5 @@
<a name="quotas"></a>
# Квоты
Квоты позволяют ограничить использование ресурсов за некоторый интервал времени, или просто подсчитывать использование ресурсов.

View File

@ -336,6 +336,8 @@ ClickHouse применяет настройку в том случае, ког
Если значение истинно, то при использовании JSON\* форматов UInt64 и Int64 числа выводятся в кавычках (из соображений совместимости с большинством реализаций JavaScript), иначе - без кавычек.
<a name="format_csv_delimiter"></a>
## format_csv_delimiter
Символ, интерпретируемый как разделитель в данных формата CSV. По умолчанию — `,`.

View File

@ -1,3 +1,5 @@
<a name="settings_profiles"></a>
# Профили настроек
Профили настроек - это множество настроек, сгруппированных под одним именем. Для каждого пользователя ClickHouse указывается некоторый профиль.