Skip to content

Commit

Permalink
Fix only panic, leave other bug for now
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
  • Loading branch information
dbussink committed Jan 20, 2025
1 parent d65ccb3 commit 1d32f2f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions go/vt/vtgate/safe_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ 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,18 +562,13 @@ func (session *SafeSession) HasSystemVariables() (found bool) {

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

if !ok {
return time.Local
}

tz, err := sqltypes.DecodeStringSQL(zoneSQL)
if err != nil {
return time.Local
}

loc, err := datetime.ParseTimeZone(tz)
if err != nil {
return time.Local
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/safe_session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ func TestTimeZone(t *testing.T) {
want: time.Local.String(),
},
{
tz: "'Europe/Amsterdam'",
tz: "Europe/Amsterdam",
want: "Europe/Amsterdam",
},
{
tz: "'+02:00'",
tz: "+02:00",
want: "UTC+02:00",
},
{
Expand Down

0 comments on commit 1d32f2f

Please sign in to comment.