mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
update tests + exception
This commit is contained in:
parent
a7a3c9d1a6
commit
e92501d5dd
@ -107,6 +107,7 @@ namespace ErrorCodes
|
|||||||
extern const int UNRECOGNIZED_ARGUMENTS;
|
extern const int UNRECOGNIZED_ARGUMENTS;
|
||||||
extern const int LOGICAL_ERROR;
|
extern const int LOGICAL_ERROR;
|
||||||
extern const int CANNOT_OPEN_FILE;
|
extern const int CANNOT_OPEN_FILE;
|
||||||
|
extern const int CANNOT_PARSE_DATETIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1599,6 +1600,9 @@ void ClientBase::processParsedSingleQuery(const String & full_query, const Strin
|
|||||||
progress_indication.resetProgress();
|
progress_indication.resetProgress();
|
||||||
profile_events.watch.restart();
|
profile_events.watch.restart();
|
||||||
|
|
||||||
|
/// A query may contain timezone setting. To handle this, old client-wide tz is saved here.
|
||||||
|
/// If timezone was set for a query, after its execution client tz will be back to old one.
|
||||||
|
/// If it was a settings query, new setting will be applied to client.
|
||||||
const std::string old_timezone = DateLUT::instance().getTimeZone();
|
const std::string old_timezone = DateLUT::instance().getTimeZone();
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -1649,8 +1653,18 @@ void ClientBase::processParsedSingleQuery(const String & full_query, const Strin
|
|||||||
|
|
||||||
bool is_async_insert = global_context->getSettingsRef().async_insert && insert && insert->hasInlinedData();
|
bool is_async_insert = global_context->getSettingsRef().async_insert && insert && insert->hasInlinedData();
|
||||||
|
|
||||||
if (!global_context->getSettingsRef().timezone.toString().empty())
|
/// pre-load timezone from (query) settings -- new timezone may also be specified in query.
|
||||||
DateLUT::setDefaultTimezone(global_context->getSettingsRef().timezone);
|
try
|
||||||
|
{
|
||||||
|
if (!global_context->getSettingsRef().timezone.toString().empty())
|
||||||
|
DateLUT::setDefaultTimezone(global_context->getSettingsRef().timezone);
|
||||||
|
}
|
||||||
|
catch (Poco::Exception &)
|
||||||
|
{
|
||||||
|
throw Exception(ErrorCodes::CANNOT_PARSE_DATETIME,
|
||||||
|
"Invalid time zone {} in client settings. Use `SET timezone = \'New/TZ\'` to set a proper timezone.",
|
||||||
|
global_context->getSettingsRef().timezone.toString());
|
||||||
|
}
|
||||||
|
|
||||||
/// INSERT query for which data transfer is needed (not an INSERT SELECT or input()) is processed separately.
|
/// INSERT query for which data transfer is needed (not an INSERT SELECT or input()) is processed separately.
|
||||||
if (insert && (!insert->select || input_function) && !insert->watch && !is_async_insert)
|
if (insert && (!insert->select || input_function) && !insert->watch && !is_async_insert)
|
||||||
@ -1687,9 +1701,17 @@ void ClientBase::processParsedSingleQuery(const String & full_query, const Strin
|
|||||||
|
|
||||||
global_context->addQueryParameters(set_query->query_parameters);
|
global_context->addQueryParameters(set_query->query_parameters);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!global_context->getSettingsRef().timezone.toString().empty())
|
if (!global_context->getSettingsRef().timezone.toString().empty())
|
||||||
DateLUT::setDefaultTimezone(global_context->getSettingsRef().timezone);
|
DateLUT::setDefaultTimezone(global_context->getSettingsRef().timezone);
|
||||||
|
}
|
||||||
|
catch (Poco::Exception &)
|
||||||
|
{
|
||||||
|
throw Exception(ErrorCodes::CANNOT_PARSE_DATETIME,
|
||||||
|
"Invalid time zone {} in client settings. Use `SET timezone = \'New/TZ\'` to set a proper timezone.",
|
||||||
|
global_context->getSettingsRef().timezone.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (const auto * use_query = parsed_query->as<ASTUseQuery>())
|
if (const auto * use_query = parsed_query->as<ASTUseQuery>())
|
||||||
{
|
{
|
||||||
|
@ -5,5 +5,5 @@ SELECT toDateTime64(toDateTime64('1999-12-12 23:23:23.123', 3), 3, 'Europe/Zuric
|
|||||||
SET timezone = 'Europe/Zurich';
|
SET timezone = 'Europe/Zurich';
|
||||||
SELECT toDateTime64(toDateTime64('1999-12-12 23:23:23.123', 3), 3, 'Asia/Novosibirsk');
|
SELECT toDateTime64(toDateTime64('1999-12-12 23:23:23.123', 3), 3, 'Asia/Novosibirsk');
|
||||||
|
|
||||||
SET timezone = 'Абырвалг';
|
SET timezone = 'Абырвалг'; -- { clientError CANNOT_PARSE_DATETIME }
|
||||||
select now(); -- { serverError POCO_EXCEPTION }
|
select now(); -- { clientError CANNOT_PARSE_DATETIME }
|
Loading…
Reference in New Issue
Block a user