Skip to content

Commit

Permalink
Merge pull request #6163 from planetscale/fix-sysvarset
Browse files Browse the repository at this point in the history
make setsysvar map for first time
  • Loading branch information
harshit-gangal authored May 8, 2020
2 parents 7c01c40 + 23ad71c commit 4209ae3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go/test/endtoend/vtgate/setstatement/sysvar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ func TestSetSysVar(t *testing.T) {
}, {
query: `set @@sql_mode = concat(@@sql_mode,"ALLOW_INVALID_DATES")`,
expectedWarning: "[[VARCHAR(\"Warning\") UINT16(1235) VARCHAR(\"Modification not allowed using set construct for: sql_mode\")]]",
}, {
query: `set @@SQL_SAFE_UPDATES = 1`,
expectedRows: ``, rowsAffected: 0,
}}

conn, err := mysql.Connect(ctx, &vtParams)
Expand Down
3 changes: 3 additions & 0 deletions go/vt/vtgate/safe_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,8 @@ func (session *SafeSession) SetTargetString(target string) {
func (session *SafeSession) SetSystemVariable(name string, expr string) {
session.mu.Lock()
defer session.mu.Unlock()
if session.SystemVariables == nil {
session.SystemVariables = make(map[string]string)
}
session.SystemVariables[name] = expr
}

0 comments on commit 4209ae3

Please sign in to comment.