mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-04 04:12:55 +00:00
feat: supports select @@session.time_zone (#6212)
This commit is contained in:
@@ -183,7 +183,7 @@ fn select_variable(query: &str, query_context: QueryContextRef) -> Option<Output
|
||||
|
||||
// get value of variables from known sources or fallback to defaults
|
||||
let value = match var_as[0] {
|
||||
"time_zone" => query_context.timezone().to_string(),
|
||||
"session.time_zone" | "time_zone" => query_context.timezone().to_string(),
|
||||
"system_time_zone" => system_timezone_name(),
|
||||
_ => VAR_VALUES
|
||||
.get(var_as[0])
|
||||
|
||||
@@ -339,6 +339,8 @@ pub async fn test_mysql_timezone(store_type: StorageType) {
|
||||
|
||||
let timezone = conn.fetch_all("SELECT @@time_zone").await.unwrap();
|
||||
assert_eq!(timezone[0].get::<String, usize>(0), "Asia/Shanghai");
|
||||
let timezone = conn.fetch_all("SELECT @@session.time_zone").await.unwrap();
|
||||
assert_eq!(timezone[0].get::<String, usize>(0), "Asia/Shanghai");
|
||||
let timezone = conn.fetch_all("SELECT @@system_time_zone").await.unwrap();
|
||||
assert_eq!(timezone[0].get::<String, usize>(0), "UTC");
|
||||
let _ = conn.execute("SET time_zone = 'UTC'").await.unwrap();
|
||||
@@ -367,6 +369,8 @@ pub async fn test_mysql_timezone(store_type: StorageType) {
|
||||
let _ = conn.execute("SET time_zone = '+08:00'").await.unwrap();
|
||||
let timezone = conn.fetch_all("SELECT @@time_zone").await.unwrap();
|
||||
assert_eq!(timezone[0].get::<String, usize>(0), "+08:00");
|
||||
let timezone = conn.fetch_all("SELECT @@session.time_zone").await.unwrap();
|
||||
assert_eq!(timezone[0].get::<String, usize>(0), "+08:00");
|
||||
|
||||
let rows2 = conn.fetch_all("select ts from demo").await.unwrap();
|
||||
// we use Utc here for format only
|
||||
@@ -391,6 +395,8 @@ pub async fn test_mysql_timezone(store_type: StorageType) {
|
||||
);
|
||||
let timezone = conn.fetch_all("SELECT @@time_zone").await.unwrap();
|
||||
assert_eq!(timezone[0].get::<String, usize>(0), "-07:00");
|
||||
let timezone = conn.fetch_all("SELECT @@session.time_zone").await.unwrap();
|
||||
assert_eq!(timezone[0].get::<String, usize>(0), "-07:00");
|
||||
|
||||
let _ = fe_mysql_server.shutdown().await;
|
||||
guard.remove_all().await;
|
||||
|
||||
Reference in New Issue
Block a user