mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-14 19:45:11 +00:00
Merge pull request #71014 from jirislav/increase_default_client_history_size
Make the Replxx client history size configurable
This commit is contained in:
commit
c4db9a0501
@ -190,6 +190,7 @@ You can pass parameters to `clickhouse-client` (all parameters have a default va
|
||||
- `--config-file` – The name of the configuration file.
|
||||
- `--secure` – If specified, will connect to server over secure connection (TLS). You might need to configure your CA certificates in the [configuration file](#configuration_files). The available configuration settings are the same as for [server-side TLS configuration](../operations/server-configuration-parameters/settings.md#openssl).
|
||||
- `--history_file` — Path to a file containing command history.
|
||||
- `--history_max_entries` — Maximum number of entries in the history file. Default value: 1 000 000.
|
||||
- `--param_<name>` — Value for a [query with parameters](#cli-queries-with-parameters).
|
||||
- `--hardware-utilization` — Print hardware utilization information in progress bar.
|
||||
- `--print-profile-events` – Print `ProfileEvents` packets.
|
||||
|
@ -192,6 +192,10 @@ void Client::parseConnectionsCredentials(Poco::Util::AbstractConfiguration & con
|
||||
history_file = home_path + "/" + history_file.substr(1);
|
||||
config.setString("history_file", history_file);
|
||||
}
|
||||
if (config.has(prefix + ".history_max_entries"))
|
||||
{
|
||||
config.setUInt("history_max_entries", history_max_entries);
|
||||
}
|
||||
if (config.has(prefix + ".accept-invalid-certificate"))
|
||||
config.setBool("accept-invalid-certificate", config.getBool(prefix + ".accept-invalid-certificate"));
|
||||
}
|
||||
|
@ -236,6 +236,7 @@ void DisksApp::runInteractiveReplxx()
|
||||
ReplxxLineReader lr(
|
||||
suggest,
|
||||
history_file,
|
||||
history_max_entries,
|
||||
/* multiline= */ false,
|
||||
/* ignore_shell_suspend= */ false,
|
||||
query_extenders,
|
||||
@ -398,6 +399,8 @@ void DisksApp::initializeHistoryFile()
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
history_max_entries = config().getUInt("history-max-entries", 1000000);
|
||||
}
|
||||
|
||||
void DisksApp::init(const std::vector<String> & common_arguments)
|
||||
|
@ -62,6 +62,8 @@ private:
|
||||
|
||||
// Fields responsible for the REPL work
|
||||
String history_file;
|
||||
UInt32 history_max_entries = 0; /// Maximum number of entries in the history file. Needs to be initialized to 0 since we don't have a proper constructor. Worry not, actual value is set within the initializeHistoryFile method.
|
||||
|
||||
LineReader::Suggest suggest;
|
||||
static LineReader::Patterns query_extenders;
|
||||
static LineReader::Patterns query_delimiters;
|
||||
|
@ -243,6 +243,8 @@ void KeeperClient::initialize(Poco::Util::Application & /* self */)
|
||||
}
|
||||
}
|
||||
|
||||
history_max_entries = config().getUInt("history-max-entries", 1000000);
|
||||
|
||||
String default_log_level;
|
||||
if (config().has("query"))
|
||||
/// We don't want to see any information log in query mode, unless it was set explicitly
|
||||
@ -319,6 +321,7 @@ void KeeperClient::runInteractiveReplxx()
|
||||
ReplxxLineReader lr(
|
||||
suggest,
|
||||
history_file,
|
||||
history_max_entries,
|
||||
/* multiline= */ false,
|
||||
/* ignore_shell_suspend= */ false,
|
||||
query_extenders,
|
||||
|
@ -59,6 +59,8 @@ protected:
|
||||
std::vector<String> getCompletions(const String & prefix) const;
|
||||
|
||||
String history_file;
|
||||
UInt32 history_max_entries; /// Maximum number of entries in the history file.
|
||||
|
||||
LineReader::Suggest suggest;
|
||||
|
||||
zkutil::ZooKeeperArgs zk_args;
|
||||
|
@ -167,7 +167,8 @@ void ClientApplicationBase::init(int argc, char ** argv)
|
||||
("query_kind", po::value<std::string>()->default_value("initial_query"), "One of initial_query/secondary_query/no_query")
|
||||
("query_id", po::value<std::string>(), "query_id")
|
||||
|
||||
("history_file", po::value<std::string>(), "path to history file")
|
||||
("history_file", po::value<std::string>(), "Path to a file containing command history.")
|
||||
("history_max_entries", po::value<UInt32>()->default_value(1000000), "Maximum number of entries in the history file.")
|
||||
|
||||
("stage", po::value<std::string>()->default_value("complete"), "Request query processing up to specified stage: complete,fetch_columns,with_mergeable_state,with_mergeable_state_after_aggregation,with_mergeable_state_after_aggregation_and_limit")
|
||||
("progress", po::value<ProgressOption>()->implicit_value(ProgressOption::TTY, "tty")->default_value(ProgressOption::DEFAULT, "default"), "Print progress of queries execution - to TTY: tty|on|1|true|yes; to STDERR non-interactive mode: err; OFF: off|0|false|no; DEFAULT - interactive to TTY, non-interactive is off")
|
||||
@ -350,6 +351,8 @@ void ClientApplicationBase::init(int argc, char ** argv)
|
||||
getClientConfiguration().setBool("highlight", options["highlight"].as<bool>());
|
||||
if (options.count("history_file"))
|
||||
getClientConfiguration().setString("history_file", options["history_file"].as<std::string>());
|
||||
if (options.count("history_max_entries"))
|
||||
getClientConfiguration().setUInt("history_max_entries", options["history_max_entries"].as<UInt32>());
|
||||
if (options.count("interactive"))
|
||||
getClientConfiguration().setBool("interactive", true);
|
||||
if (options.count("pager"))
|
||||
|
@ -2665,6 +2665,8 @@ void ClientBase::runInteractive()
|
||||
}
|
||||
}
|
||||
|
||||
history_max_entries = getClientConfiguration().getUInt("history_max_entries");
|
||||
|
||||
LineReader::Patterns query_extenders = {"\\"};
|
||||
LineReader::Patterns query_delimiters = {";", "\\G", "\\G;"};
|
||||
char word_break_characters[] = " \t\v\f\a\b\r\n`~!@#$%^&*()-=+[{]}\\|;:'\",<.>/?";
|
||||
@ -2677,6 +2679,7 @@ void ClientBase::runInteractive()
|
||||
ReplxxLineReader lr(
|
||||
*suggest,
|
||||
history_file,
|
||||
history_max_entries,
|
||||
getClientConfiguration().has("multiline"),
|
||||
getClientConfiguration().getBool("ignore_shell_suspend", true),
|
||||
query_extenders,
|
||||
|
@ -328,6 +328,7 @@ protected:
|
||||
|
||||
String home_path;
|
||||
String history_file; /// Path to a file containing command history.
|
||||
UInt32 history_max_entries; /// Maximum number of entries in the history file.
|
||||
|
||||
String current_profile;
|
||||
|
||||
|
@ -293,6 +293,7 @@ void ReplxxLineReader::setLastIsDelimiter(bool flag)
|
||||
ReplxxLineReader::ReplxxLineReader(
|
||||
Suggest & suggest,
|
||||
const String & history_file_path_,
|
||||
UInt32 history_max_entries_,
|
||||
bool multiline_,
|
||||
bool ignore_shell_suspend,
|
||||
Patterns extenders_,
|
||||
@ -313,6 +314,8 @@ ReplxxLineReader::ReplxxLineReader(
|
||||
{
|
||||
using Replxx = replxx::Replxx;
|
||||
|
||||
rx.set_max_history_size(static_cast<int>(history_max_entries_));
|
||||
|
||||
if (!history_file_path.empty())
|
||||
{
|
||||
history_file_fd = open(history_file_path.c_str(), O_RDWR);
|
||||
|
@ -14,6 +14,7 @@ public:
|
||||
(
|
||||
Suggest & suggest,
|
||||
const String & history_file_path,
|
||||
UInt32 history_max_entries,
|
||||
bool multiline,
|
||||
bool ignore_shell_suspend,
|
||||
Patterns extenders_,
|
||||
|
Loading…
Reference in New Issue
Block a user