Skip to content

Commit

Permalink
Revert "sessionctx: Error/warning on unsupported isolation levels (#8625
Browse files Browse the repository at this point in the history
)"

This reverts commit c27705a.
  • Loading branch information
jackysp authored Apr 3, 2019
1 parent eedbc8d commit 3155040
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 42 deletions.
58 changes: 24 additions & 34 deletions executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,48 +149,37 @@ func (s *testSuite2) TestSetVar(c *C) {
tk.MustExec("SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED")
tk.MustQuery("select @@session.tx_isolation").Check(testkit.Rows("READ-COMMITTED"))
tk.MustQuery("select @@session.transaction_isolation").Check(testkit.Rows("READ-COMMITTED"))
// error
_, err = tk.Exec("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED")
c.Assert(terror.ErrorEqual(err, variable.ErrUnsupportedValueForVar), IsTrue, Commentf("err %v", err))
tk.MustQuery("select @@session.tx_isolation").Check(testkit.Rows("READ-COMMITTED"))
tk.MustQuery("select @@session.transaction_isolation").Check(testkit.Rows("READ-COMMITTED"))
// Fails
_, err = tk.Exec("SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE")
c.Assert(terror.ErrorEqual(err, variable.ErrUnsupportedValueForVar), IsTrue, Commentf("err %v", err))
tk.MustQuery("select @@global.tx_isolation").Check(testkit.Rows("REPEATABLE-READ"))
tk.MustQuery("select @@global.transaction_isolation").Check(testkit.Rows("REPEATABLE-READ"))
tk.MustExec("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED")
tk.MustQuery("select @@session.tx_isolation").Check(testkit.Rows("READ-UNCOMMITTED"))
tk.MustQuery("select @@session.transaction_isolation").Check(testkit.Rows("READ-UNCOMMITTED"))
tk.MustExec("SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE")
tk.MustQuery("select @@global.tx_isolation").Check(testkit.Rows("SERIALIZABLE"))
tk.MustQuery("select @@global.transaction_isolation").Check(testkit.Rows("SERIALIZABLE"))

// test synonyms variables
tk.MustExec("SET SESSION tx_isolation = 'READ-COMMITTED'")
tk.MustQuery("select @@session.tx_isolation").Check(testkit.Rows("READ-COMMITTED"))
tk.MustQuery("select @@session.transaction_isolation").Check(testkit.Rows("READ-COMMITTED"))

_, err = tk.Exec("SET SESSION tx_isolation = 'READ-UNCOMMITTED'")
c.Assert(terror.ErrorEqual(err, variable.ErrUnsupportedValueForVar), IsTrue, Commentf("err %v", err))
tk.MustQuery("select @@session.tx_isolation").Check(testkit.Rows("READ-COMMITTED"))
tk.MustQuery("select @@session.transaction_isolation").Check(testkit.Rows("READ-COMMITTED"))
tk.MustExec("SET SESSION tx_isolation = 'READ-UNCOMMITTED'")
tk.MustQuery("select @@session.tx_isolation").Check(testkit.Rows("READ-UNCOMMITTED"))
tk.MustQuery("select @@session.transaction_isolation").Check(testkit.Rows("READ-UNCOMMITTED"))

// fails
_, err = tk.Exec("SET SESSION transaction_isolation = 'SERIALIZABLE'")
c.Assert(terror.ErrorEqual(err, variable.ErrUnsupportedValueForVar), IsTrue, Commentf("err %v", err))
tk.MustQuery("select @@session.tx_isolation").Check(testkit.Rows("READ-COMMITTED"))
tk.MustQuery("select @@session.transaction_isolation").Check(testkit.Rows("READ-COMMITTED"))
tk.MustExec("SET SESSION transaction_isolation = 'SERIALIZABLE'")
tk.MustQuery("select @@session.tx_isolation").Check(testkit.Rows("SERIALIZABLE"))
tk.MustQuery("select @@session.transaction_isolation").Check(testkit.Rows("SERIALIZABLE"))

// fails
_, err = tk.Exec("SET GLOBAL transaction_isolation = 'SERIALIZABLE'")
c.Assert(terror.ErrorEqual(err, variable.ErrUnsupportedValueForVar), IsTrue, Commentf("err %v", err))
tk.MustQuery("select @@global.tx_isolation").Check(testkit.Rows("REPEATABLE-READ"))
tk.MustQuery("select @@global.transaction_isolation").Check(testkit.Rows("REPEATABLE-READ"))
tk.MustExec("SET GLOBAL transaction_isolation = 'SERIALIZABLE'")
tk.MustQuery("select @@global.tx_isolation").Check(testkit.Rows("SERIALIZABLE"))
tk.MustQuery("select @@global.transaction_isolation").Check(testkit.Rows("SERIALIZABLE"))

_, err = tk.Exec("SET GLOBAL transaction_isolation = 'READ-UNCOMMITTED'")
c.Assert(terror.ErrorEqual(err, variable.ErrUnsupportedValueForVar), IsTrue, Commentf("err %v", err))
tk.MustQuery("select @@global.tx_isolation").Check(testkit.Rows("REPEATABLE-READ"))
tk.MustQuery("select @@global.transaction_isolation").Check(testkit.Rows("REPEATABLE-READ"))
tk.MustExec("SET GLOBAL transaction_isolation = 'READ-UNCOMMITTED'")
tk.MustQuery("select @@global.tx_isolation").Check(testkit.Rows("READ-UNCOMMITTED"))
tk.MustQuery("select @@global.transaction_isolation").Check(testkit.Rows("READ-UNCOMMITTED"))

_, err = tk.Exec("SET GLOBAL tx_isolation = 'SERIALIZABLE'")
c.Assert(terror.ErrorEqual(err, variable.ErrUnsupportedValueForVar), IsTrue, Commentf("err %v", err))
tk.MustQuery("select @@global.tx_isolation").Check(testkit.Rows("REPEATABLE-READ"))
tk.MustQuery("select @@global.transaction_isolation").Check(testkit.Rows("REPEATABLE-READ"))
tk.MustExec("SET GLOBAL tx_isolation = 'SERIALIZABLE'")
tk.MustQuery("select @@global.tx_isolation").Check(testkit.Rows("SERIALIZABLE"))
tk.MustQuery("select @@global.transaction_isolation").Check(testkit.Rows("SERIALIZABLE"))

tk.MustExec("SET SESSION tx_read_only = 1")
tk.MustExec("SET SESSION tx_read_only = 0")
Expand Down Expand Up @@ -584,8 +573,9 @@ func (s *testSuite2) TestValidateSetVar(c *C) {
result = tk.MustQuery("select @@tx_isolation;")
result.Check(testkit.Rows("REPEATABLE-READ"))

_, err = tk.Exec("set @@tx_isolation='SERIALIZABLE'")
c.Assert(terror.ErrorEqual(err, variable.ErrUnsupportedValueForVar), IsTrue, Commentf("err %v", err))
tk.MustExec("set @@tx_isolation='SERIALIZABLE'")
result = tk.MustQuery("select @@tx_isolation;")
result.Check(testkit.Rows("SERIALIZABLE"))
}

func (s *testSuite2) TestSelectGlobalVar(c *C) {
Expand Down
4 changes: 0 additions & 4 deletions sessionctx/variable/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,6 @@ func (s *SessionVars) WithdrawAllPreparedStmt() {
func (s *SessionVars) SetSystemVar(name string, val string) error {
switch name {
case TxnIsolationOneShot:
switch val {
case "SERIALIZABLE", "READ-UNCOMMITTED":
return ErrUnsupportedValueForVar.GenWithStackByArgs(name, val)
}
s.TxnIsolationLevelOneShot.State = 1
s.TxnIsolationLevelOneShot.Value = val
case TimeZone:
Expand Down
4 changes: 0 additions & 4 deletions sessionctx/variable/varsutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,6 @@ func ValidateSetSystemVar(vars *SessionVars, name string, value string) (string,
if !exists {
return "", ErrWrongValueForVar.GenWithStackByArgs(name, value)
}
switch upVal {
case "SERIALIZABLE", "READ-UNCOMMITTED":
return "", ErrUnsupportedValueForVar.GenWithStackByArgs(name, value)
}
return upVal, nil
case TiDBInitChunkSize:
v, err := strconv.Atoi(value)
Expand Down

0 comments on commit 3155040

Please sign in to comment.