mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
prototype: show server group name in client
This commit is contained in:
parent
07a11de679
commit
0b26189fab
@ -148,6 +148,10 @@ void Connection::receiveHello()
|
|||||||
{
|
{
|
||||||
readStringBinary(server_timezone, *in);
|
readStringBinary(server_timezone, *in);
|
||||||
}
|
}
|
||||||
|
if (server_revision >= DBMS_MIN_REVISION_WITH_SERVER_GROUP_NAME)
|
||||||
|
{
|
||||||
|
readStringBinary(server_group_name, *in);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (packet_type == Protocol::Server::Exception)
|
else if (packet_type == Protocol::Server::Exception)
|
||||||
receiveException()->rethrow();
|
receiveException()->rethrow();
|
||||||
@ -203,6 +207,14 @@ const String & Connection::getServerTimezone()
|
|||||||
return server_timezone;
|
return server_timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const String & Connection::getServerGroupname()
|
||||||
|
{
|
||||||
|
if (!connected)
|
||||||
|
connect();
|
||||||
|
|
||||||
|
return server_group_name;
|
||||||
|
}
|
||||||
|
|
||||||
void Connection::forceConnected()
|
void Connection::forceConnected()
|
||||||
{
|
{
|
||||||
if (!connected)
|
if (!connected)
|
||||||
|
@ -134,6 +134,7 @@ public:
|
|||||||
void getServerVersion(String & name, UInt64 & version_major, UInt64 & version_minor, UInt64 & revision);
|
void getServerVersion(String & name, UInt64 & version_major, UInt64 & version_minor, UInt64 & revision);
|
||||||
|
|
||||||
const String & getServerTimezone();
|
const String & getServerTimezone();
|
||||||
|
const String & getServerGroupname();
|
||||||
|
|
||||||
/// For log and exception messages.
|
/// For log and exception messages.
|
||||||
const String & getDescription() const;
|
const String & getDescription() const;
|
||||||
@ -213,6 +214,7 @@ private:
|
|||||||
UInt64 server_version_minor = 0;
|
UInt64 server_version_minor = 0;
|
||||||
UInt64 server_revision = 0;
|
UInt64 server_revision = 0;
|
||||||
String server_timezone;
|
String server_timezone;
|
||||||
|
String server_group_name;
|
||||||
|
|
||||||
std::unique_ptr<Poco::Net::StreamSocket> socket;
|
std::unique_ptr<Poco::Net::StreamSocket> socket;
|
||||||
std::shared_ptr<ReadBuffer> in;
|
std::shared_ptr<ReadBuffer> in;
|
||||||
|
@ -60,6 +60,7 @@
|
|||||||
#define DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO 54060
|
#define DBMS_MIN_REVISION_WITH_QUOTA_KEY_IN_CLIENT_INFO 54060
|
||||||
#define DBMS_MIN_REVISION_WITH_TABLES_STATUS 54226
|
#define DBMS_MIN_REVISION_WITH_TABLES_STATUS 54226
|
||||||
#define DBMS_MIN_REVISION_WITH_TIME_ZONE_PARAMETER_IN_DATETIME_DATA_TYPE 54337
|
#define DBMS_MIN_REVISION_WITH_TIME_ZONE_PARAMETER_IN_DATETIME_DATA_TYPE 54337
|
||||||
|
#define DBMS_MIN_REVISION_WITH_SERVER_GROUP_NAME 54355
|
||||||
|
|
||||||
/// Version of ClickHouse TCP protocol. Set to git tag with latest protocol change.
|
/// Version of ClickHouse TCP protocol. Set to git tag with latest protocol change.
|
||||||
#define DBMS_TCP_PROTOCOL_VERSION 54226
|
#define DBMS_TCP_PROTOCOL_VERSION 54226
|
||||||
|
@ -153,6 +153,7 @@ private:
|
|||||||
/// If the last query resulted in exception.
|
/// If the last query resulted in exception.
|
||||||
bool got_exception = false;
|
bool got_exception = false;
|
||||||
String server_version;
|
String server_version;
|
||||||
|
String server_group_name;
|
||||||
|
|
||||||
Stopwatch watch;
|
Stopwatch watch;
|
||||||
|
|
||||||
@ -425,6 +426,7 @@ private:
|
|||||||
connection->getServerVersion(server_name, server_version_major, server_version_minor, server_revision);
|
connection->getServerVersion(server_name, server_version_major, server_version_minor, server_revision);
|
||||||
|
|
||||||
server_version = toString(server_version_major) + "." + toString(server_version_minor) + "." + toString(server_revision);
|
server_version = toString(server_version_major) + "." + toString(server_version_minor) + "." + toString(server_revision);
|
||||||
|
server_group_name = connection->getServerGroupname();
|
||||||
if (is_interactive)
|
if (is_interactive)
|
||||||
{
|
{
|
||||||
std::cout << "Connected to " << server_name
|
std::cout << "Connected to " << server_name
|
||||||
@ -450,7 +452,8 @@ private:
|
|||||||
{
|
{
|
||||||
String query;
|
String query;
|
||||||
String prev_query;
|
String prev_query;
|
||||||
while (char * line_ = readline(query.empty() ? ":) " : ":-] "))
|
String prompt = server_group_name.length() ? "[" + server_group_name + "] :) " : ":) ";
|
||||||
|
while (char * line_ = readline(query.empty() ? prompt.c_str() : ":-] "))
|
||||||
{
|
{
|
||||||
String line = line_;
|
String line = line_;
|
||||||
free(line_);
|
free(line_);
|
||||||
|
@ -508,6 +508,10 @@ void TCPHandler::sendHello()
|
|||||||
{
|
{
|
||||||
writeStringBinary(DateLUT::instance().getTimeZone(), *out);
|
writeStringBinary(DateLUT::instance().getTimeZone(), *out);
|
||||||
}
|
}
|
||||||
|
if (client_revision >= DBMS_MIN_REVISION_WITH_SERVER_GROUP_NAME)
|
||||||
|
{
|
||||||
|
writeStringBinary(server.config().getString("group_name"), *out);
|
||||||
|
}
|
||||||
out->next();
|
out->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<count>10</count>
|
<count>10</count>
|
||||||
<!-- <console>1</console> --> <!-- Default behavior is autodetection (log to console if not daemon mode and is tty) -->
|
<!-- <console>1</console> --> <!-- Default behavior is autodetection (log to console if not daemon mode and is tty) -->
|
||||||
</logger>
|
</logger>
|
||||||
|
<group_name>staging</group_name>
|
||||||
<http_port>8123</http_port>
|
<http_port>8123</http_port>
|
||||||
<tcp_port>9000</tcp_port>
|
<tcp_port>9000</tcp_port>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user