Merge remote-tracking branch 'upstream/master' into METR-23466

This commit is contained in:
proller 2016-11-17 04:09:58 +03:00
commit da6f40ac12
6 changed files with 37 additions and 29 deletions

View File

@ -130,7 +130,7 @@ public:
void getServerVersion(String & name, UInt64 & version_major, UInt64 & version_minor, UInt64 & revision);
const String & getServerTimezone() const;
const String & getServerTimezone();
/// For log and exception messages.
const String & getDescription() const;

View File

@ -327,6 +327,33 @@ private:
connect();
/// Инициализируем DateLUT, чтобы потраченное время не отображалось, как время, потраченное на запрос.
DateLUT::instance();
if (!context.getSettingsRef().use_client_time_zone)
{
const auto & time_zone = connection->getServerTimezone();
if (!time_zone.empty())
{
try
{
DateLUT::setDefaultTimezone(time_zone);
}
catch (...)
{
std::cerr << "Warning: could not switch to server time zone: " << time_zone
<< ", reason: " << getCurrentExceptionMessage(/* with_stacktrace = */ false) << std::endl
<< "Proceeding with local time zone."
<< std::endl << std::endl;
}
}
else
{
std::cerr << "Warning: could not determine server time zone. "
<< "Proceeding with local time zone."
<< std::endl << std::endl;
}
}
if (is_interactive)
{
if (print_time_to_stderr)
@ -355,33 +382,6 @@ private:
Poco::File(history_file).createFile();
}
/// Инициализируем DateLUT, чтобы потраченное время не отображалось, как время, потраченное на запрос.
DateLUT::instance();
if (!context.getSettingsRef().use_client_time_zone)
{
const auto & time_zone = connection->getServerTimezone();
if (!time_zone.empty())
{
try
{
DateLUT::setDefaultTimezone(time_zone);
}
catch (...)
{
std::cerr << "Warning: could not switch to server time zone: " << time_zone
<< ", reason: " << getCurrentExceptionMessage(/* with_stacktrace = */ false) << std::endl
<< "Proceeding with local time zone."
<< std::endl << std::endl;
}
}
else
{
std::cerr << "Warning: could not determine server time zone. "
<< "Proceeding with local time zone."
<< std::endl << std::endl;
}
}
loop();
std::cout << (isNewYearMode() ? "Happy new year." : "Bye.") << std::endl;

View File

@ -184,8 +184,11 @@ void Connection::getServerVersion(String & name, UInt64 & version_major, UInt64
revision = server_revision;
}
const String & Connection::getServerTimezone() const
const String & Connection::getServerTimezone()
{
if (!connected)
connect();
return server_timezone;
}

View File

@ -4,6 +4,7 @@
<default>
<networks replace="replace">
<ip>::1</ip>
<ip>0.0.0.0</ip>
<ip>127.0.0.1</ip>
</networks>
</default>

View File

@ -0,0 +1 @@
2001-09-09 01:46:40

View File

@ -0,0 +1,3 @@
#!/bin/sh -e
TZ=UTC clickhouse --client --use_client_time_zone=1 --query="SELECT toDateTime(1000000000)"