diff --git a/e2e_test/database/timezone.slt b/e2e_test/database/timezone.slt index 5ee196a8bf17..6a223c453bc0 100644 --- a/e2e_test/database/timezone.slt +++ b/e2e_test/database/timezone.slt @@ -71,3 +71,11 @@ set time zone 12.3; statement error set time zone interval '1' hour; + +# support a special case for clients which would send when initializing the connection +statement ok +SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE; + +# only support '+00:00' +statement error +SET TIME ZONE INTERVAL '+01:00' HOUR TO MINUTE; \ No newline at end of file diff --git a/src/sqlparser/src/parser.rs b/src/sqlparser/src/parser.rs index 1ee9b0639216..061446e588d3 100644 --- a/src/sqlparser/src/parser.rs +++ b/src/sqlparser/src/parser.rs @@ -4289,6 +4289,26 @@ impl Parser<'_> { let value = alt(( Keyword::DEFAULT.value(SetTimeZoneValue::Default), Keyword::LOCAL.value(SetTimeZoneValue::Local), + preceded( + Keyword::INTERVAL, + cut_err(Self::parse_literal_interval.try_map(|e| match e { + // support a special case for clients which would send when initializing the connection + // like: SET TIME ZONE INTERVAL '+00:00' HOUR TO MINUTE; + Expr::Value(v) => match v { + Value::Interval { value, .. } => { + if value != "+00:00" { + return Err(StrError("only support \"+00:00\" ".into())); + } + Ok(SetTimeZoneValue::Ident(Ident::with_quote_unchecked( + '\'', + "UTC".to_string(), + ))) + } + _ => Err(StrError("expect Value::Interval".into())), + }, + _ => Err(StrError("expect Expr::Value".into())), + })), + ), Self::parse_identifier.map(SetTimeZoneValue::Ident), Self::parse_value.map(SetTimeZoneValue::Literal), ))