Skip to content

Commit

Permalink
Cherry-pick 5468f5d
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
vitess-bot[bot] authored and dbussink committed Jan 16, 2025
1 parent b9fedac commit d65ccb3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion go/vt/vtgate/engine/fake_vcursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (t *noopVCursor) Environment() *vtenv.Environment {
}

func (t *noopVCursor) TimeZone() *time.Location {
return nil
return time.Local
}

func (t *noopVCursor) SQLMode() string {
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/evalengine/fn_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (call *builtinNow) constant() bool {

func (call *builtinSysdate) eval(env *ExpressionEnv) (eval, error) {
now := SystemTime()
if tz := env.currentTimezone(); tz != nil {
if tz := env.currentTimezone(); tz != time.Local {
now = now.In(tz)
}
return newEvalDateTime(datetime.NewDateTimeFromStd(now), int(call.prec), false), nil
Expand Down Expand Up @@ -673,7 +673,7 @@ func (b *builtinFromUnixtime) eval(env *ExpressionEnv) (eval, error) {
}

t := time.Unix(sec, frac)
if tz := env.currentTimezone(); tz != nil {
if tz := env.currentTimezone(); tz != time.Local {
t = t.In(tz)
}

Expand Down
17 changes: 13 additions & 4 deletions go/vt/vtgate/safe_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"google.golang.org/protobuf/proto"

"vitess.io/vitess/go/mysql/datetime"

"vitess.io/vitess/go/sqltypes"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/srvtopo"
"vitess.io/vitess/go/vt/sysvars"
Expand Down Expand Up @@ -563,13 +563,22 @@ func (session *SafeSession) HasSystemVariables() (found bool) {

func (session *SafeSession) TimeZone() *time.Location {
session.mu.Lock()
tz, ok := session.SystemVariables["time_zone"]
zoneSQL, ok := session.SystemVariables["time_zone"]
session.mu.Unlock()

if !ok {
return nil
return time.Local
}

tz, err := sqltypes.DecodeStringSQL(zoneSQL)

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_partial_keyspace)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (schemadiff_vrepl)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (21)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_across_db_versions)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Local example using etcd on Ubuntu

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Local example using consul on Ubuntu

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Local example using zk2 on Ubuntu

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_migrate_vdiff2_convert_tz)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_recovery)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (18)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Region Sharding example using etcd on Ubuntu

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtbackup)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / End-to-End Test

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtorc)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (ers_prs_newfeatures_heavy)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_backup) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_godriver)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_concurrentdml)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtctlbackup_sharded_clustertest_heavy)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_reservedconn)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (12)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_foreign_key_stress)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_transaction)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (22)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_cellalias)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_partial_movetables_and_materialize)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_foreignkey_stress)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_queries)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_gen4)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_suite)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_readafterwrite)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vstream)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_etcd)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_schema_tracker)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_throttler_topo)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_backup)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql_server_vault)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 10

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_tablegc) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_scheduler) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_topo_consul)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_tablet_healthcheck_cache)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_unsharded)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vschema)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (mysql80)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_general_heavy)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr_xtrabackup) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Vitess Tester (vtgate)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (13)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_v2)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Unit Test (mysql57)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (topo_connection_cache)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vreplication_basic)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_tablegc)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_scheduler)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vttablet_prscomplex)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Code Coverage

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (tabletmanager_consul)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress_suite)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (15)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_revert)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_ghost) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Code Coverage

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_revert) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / End-to-End Test (Race)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtgate_vindex_heavy)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (vtorc) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (schemadiff_vrepl) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Unit Test (Race)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - E2E - Next Release

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Unit Test (mysql80)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Queries) Next Release

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_stress_suite) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (xb_recovery) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - Manual - Next Release

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old VTTablet

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: sqltypes.DecodeStringSQL) (typecheck)

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: sqltypes.DecodeStringSQL) (typecheck)

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: sqltypes.DecodeStringSQL) (typecheck)

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: sqltypes.DecodeStringSQL (typecheck)

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Static Code Checks Etc

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (backup_pitr_xtrabackup)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema) Next Release

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Query Serving (Schema)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_vrepl_suite) mysql57

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent New VTTablet

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Backups - Manual

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run endtoend tests on Cluster (onlineddl_ghost)

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent Old Vtctl

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Run Upgrade Downgrade Test - Reparent New Vtctl

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: sqltypes.DecodeStringSQL

Check failure on line 573 in go/vt/vtgate/safe_session.go

View workflow job for this annotation

GitHub Actions / Docker Test Cluster 25

undefined: sqltypes.DecodeStringSQL
if err != nil {
return time.Local
}

loc, err := datetime.ParseTimeZone(tz)
if err != nil {
return time.Local
}
loc, _ := datetime.ParseTimeZone(tz)
return loc
}

Expand Down
18 changes: 12 additions & 6 deletions go/vt/vtgate/safe_session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,31 @@ func TestTimeZone(t *testing.T) {
want string
}{
{
tz: "Europe/Amsterdam",
tz: "",
want: time.Local.String(),
},
{
tz: "'Europe/Amsterdam'",
want: "Europe/Amsterdam",
},
{
tz: "+02:00",
tz: "'+02:00'",
want: "UTC+02:00",
},
{
tz: "foo",
want: (*time.Location)(nil).String(),
want: time.Local.String(),
},
}

for _, tc := range testCases {
t.Run(tc.tz, func(t *testing.T) {
sysvars := map[string]string{}
if tc.tz != "" {
sysvars["time_zone"] = tc.tz
}
session := NewSafeSession(&vtgatepb.Session{
SystemVariables: map[string]string{
"time_zone": tc.tz,
},
SystemVariables: sysvars,
})

assert.Equal(t, tc.want, session.TimeZone().String())
Expand Down

0 comments on commit d65ccb3

Please sign in to comment.