Skip to content

Commit

Permalink
Merge pull request #6494 from planetscale/set-allowmultiscope
Browse files Browse the repository at this point in the history
Allow set to have scope for each setting
  • Loading branch information
systay committed Jul 30, 2020
2 parents 808c7b7 + db8922c commit f5d091f
Show file tree
Hide file tree
Showing 4 changed files with 1,652 additions and 1,643 deletions.
12 changes: 6 additions & 6 deletions go/test/endtoend/vtgate/setstatement/sysvar_test.go
Expand Up @@ -47,7 +47,7 @@ func TestCharsetIntro(t *testing.T) {
require.EqualValues(t, 0, qr.RowsAffected)
}

func TestSetSysVar(t *testing.T) {
func TestSetSysVarSingle(t *testing.T) {
defer cluster.PanicHandler(t)
ctx := context.Background()
vtParams := mysql.ConnParams{
Expand Down Expand Up @@ -111,14 +111,14 @@ func TestSetSystemVariable(t *testing.T) {
require.NoError(t, err)
defer conn.Close()

checkedExec(t, conn, "set @@sql_mode = 'NO_ZERO_DATE'")
q := `select str_to_date('00/00/0000', '%m/%d/%Y')`
assertMatches(t, conn, q, `[[NULL]]`)
checkedExec(t, conn, "set session sql_mode = 'NO_ZERO_DATE', session default_week_format = 1")
q := `select str_to_date('00/00/0000', '%m/%d/%Y'), WEEK('2008-02-20')`
assertMatches(t, conn, q, `[[NULL INT64(8)]]`)

assertMatches(t, conn, "select @@sql_mode", `[[VARCHAR("NO_ZERO_DATE")]]`)
checkedExec(t, conn, "set @@sql_mode = ''")
checkedExec(t, conn, "set @@sql_mode = '', session default_week_format = 0")

assertMatches(t, conn, q, `[[DATE("0000-00-00")]]`)
assertMatches(t, conn, q, `[[DATE("0000-00-00") INT64(7)]]`)

checkedExec(t, conn, "SET @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483")
assertMatches(t, conn, "select @@sql_mode", `[[VARCHAR("NO_AUTO_VALUE_ON_ZERO,STRICT_ALL_TABLES")]]`)
Expand Down
6 changes: 6 additions & 0 deletions go/vt/sqlparser/parse_test.go
Expand Up @@ -832,6 +832,12 @@ var (
}, {
input: "set session wait_timeout = 3600",
output: "set session wait_timeout = 3600",
}, {
input: "set session wait_timeout = 3600, session autocommit = off",
output: "set session wait_timeout = 3600, session autocommit = 'off'",
}, {
input: "set session wait_timeout = 3600, @@global.autocommit = off",
output: "set session wait_timeout = 3600, @@global.autocommit = 'off'",
}, {
input: "set /* list */ a = 3, b = 4",
}, {
Expand Down

0 comments on commit f5d091f

Please sign in to comment.