@@ -135,6 +135,27 @@ func (s *testSuite) TearDownSuite(c *C) {
135
135
s .store .Close ()
136
136
}
137
137
138
+ func enablePessimisticTxn (enable bool ) {
139
+ newConf := config .NewConfig ()
140
+ newConf .PessimisticTxn .Enable = enable
141
+ config .StoreGlobalConfig (newConf )
142
+ }
143
+
144
+ func (s * testSuite ) TestPessimisticSelectForUpdate (c * C ) {
145
+ defer func () { enablePessimisticTxn (false ) }()
146
+ enablePessimisticTxn (true )
147
+ tk := testkit .NewTestKit (c , s .store )
148
+ tk .MustExec ("use test" )
149
+ tk .MustExec ("drop table if exists t" )
150
+ tk .MustExec ("create table t(id int primary key, a int)" )
151
+ tk .MustExec ("insert into t values(1, 1)" )
152
+ tk .MustExec ("begin PESSIMISTIC" )
153
+ tk .MustQuery ("select a from t where id=1 for update" ).Check (testkit .Rows ("1" ))
154
+ tk .MustExec ("update t set a=a+1 where id=1" )
155
+ tk .MustExec ("commit" )
156
+ tk .MustQuery ("select a from t where id=1" ).Check (testkit .Rows ("2" ))
157
+ }
158
+
138
159
func (s * testSuite ) TearDownTest (c * C ) {
139
160
tk := testkit .NewTestKit (c , s .store )
140
161
tk .MustExec ("use test" )
@@ -3960,6 +3981,12 @@ func (s *testOOMSuite) TestDistSQLMemoryControl(c *C) {
3960
3981
tk .Se .GetSessionVars ().MemQuotaDistSQL = - 1
3961
3982
}
3962
3983
3984
+ func setOOMAction (action string ) {
3985
+ newConf := config .NewConfig ()
3986
+ newConf .OOMAction = action
3987
+ config .StoreGlobalConfig (newConf )
3988
+ }
3989
+
3963
3990
func (s * testSuite ) TestOOMPanicAction (c * C ) {
3964
3991
tk := testkit .NewTestKit (c , s .store )
3965
3992
tk .MustExec ("use test" )
@@ -3971,7 +3998,11 @@ func (s *testSuite) TestOOMPanicAction(c *C) {
3971
3998
}
3972
3999
tk .Se .SetSessionManager (sm )
3973
4000
s .domain .ExpensiveQueryHandle ().SetSessionManager (sm )
3974
- config .GetGlobalConfig ().OOMAction = config .OOMActionCancel
4001
+ orgAction := config .GetGlobalConfig ().OOMAction
4002
+ setOOMAction (config .OOMActionCancel )
4003
+ defer func () {
4004
+ setOOMAction (orgAction )
4005
+ }()
3975
4006
tk .MustExec ("set @@tidb_mem_quota_query=1;" )
3976
4007
err := tk .QueryToErr ("select sum(b) from t group by a;" )
3977
4008
c .Assert (err , NotNil )
0 commit comments