Skip to content

Commit

Permalink
Merge branch 'master' into tpcc-tune3
Browse files Browse the repository at this point in the history
  • Loading branch information
qw4990 authored Nov 29, 2022
2 parents f958c5a + f1215a5 commit f7e0c06
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion br/pkg/lightning/backend/local/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ go_test(
],
embed = [":local"],
flaky = True,
shard_count = 20,
shard_count = 40,
deps = [
"//br/pkg/errors",
"//br/pkg/lightning/backend",
Expand Down
1 change: 1 addition & 0 deletions br/pkg/utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ go_test(
],
embed = [":utils"],
flaky = True,
shard_count = 20,
deps = [
"//br/pkg/errors",
"//br/pkg/metautil",
Expand Down
1 change: 1 addition & 0 deletions ddl/concurrentddltest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ go_test(
],
flaky = True,
race = "on",
shard_count = 2,
deps = [
"//config",
"//ddl",
Expand Down
13 changes: 13 additions & 0 deletions ddl/metadatalocktest/mdl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1105,3 +1105,16 @@ func TestMDLRenameTable(t *testing.T) {
tk.MustGetErrCode("select * from test2.t1;", mysql.ErrNoSuchTable)
tk.MustExec("commit")
}

func TestMDLPrepareFail(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk2 := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(a int);")
_, _, _, err := tk.Session().PrepareStmt("select b from t")
require.Error(t, err)

tk2.MustExec("alter table test.t add column c int")
}
1 change: 1 addition & 0 deletions executor/fktest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_test(
"main_test.go",
],
flaky = True,
shard_count = 20,
deps = [
"//config",
"//executor",
Expand Down
8 changes: 3 additions & 5 deletions session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -2450,7 +2450,6 @@ func (s *session) PrepareStmt(sql string) (stmtID uint32, paramCount int, fields
}

ctx := context.Background()
inTxn := s.GetSessionVars().InTxn()
// NewPrepareExec may need startTS to build the executor, for example prepare statement has subquery in int.
// So we have to call PrepareTxnCtx here.
if err = s.PrepareTxnCtx(ctx); err != nil {
Expand All @@ -2467,13 +2466,12 @@ func (s *session) PrepareStmt(sql string) (stmtID uint32, paramCount int, fields
}
prepareExec := executor.NewPrepareExec(s, sql)
err = prepareExec.Next(ctx, nil)
// Rollback even if err is nil.
s.rollbackOnError(ctx)

if err != nil {
return
}
if !inTxn {
// We could start a transaction to build the prepare executor before, we should rollback it here.
s.RollbackTxn(ctx)
}
return prepareExec.ID, prepareExec.ParamCount, prepareExec.Fields, nil
}

Expand Down

0 comments on commit f7e0c06

Please sign in to comment.