mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-25 03:00:49 +00:00
Merge remote-tracking branch 'upstream/master' into METR-23466
This commit is contained in:
commit
da6f40ac12
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
@ -0,0 +1 @@
|
||||
2001-09-09 01:46:40
|
3
dbms/tests/queries/0_stateless/00387_use_client_time_zone.sh
Executable file
3
dbms/tests/queries/0_stateless/00387_use_client_time_zone.sh
Executable file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
TZ=UTC clickhouse --client --use_client_time_zone=1 --query="SELECT toDateTime(1000000000)"
|
Loading…
Reference in New Issue
Block a user