Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: Add binlog tests for local temporary table #27273

Merged
merged 10 commits into from
Aug 17, 2021
41 changes: 41 additions & 0 deletions sessionctx/binloginfo/binloginfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,4 +740,45 @@ func (s *testBinlogSuite) TestTempTableBinlog(c *C) {
tk.MustExec(ddlQuery)
ok = mustGetDDLBinlog(s, ddlQuery, c)
c.Assert(ok, IsTrue)

// for local temporary table
latestNonLocalTemporaryTableDDL := ddlQuery
tk.MustExec("set tidb_enable_noop_functions=true")
tk.MustExec("create temporary table l_temp_table(id int)")
// create temporary table do not write to bin log, so the latest ddl binlog is the previous one
ok = mustGetDDLBinlog(s, latestNonLocalTemporaryTableDDL, c)
c.Assert(ok, IsTrue)

tk.MustExec("insert l_temp_table value(1)")
prewriteVal = getLatestBinlogPrewriteValue(c, s.pump)
c.Assert(len(prewriteVal.Mutations), Equals, 0)

tk.MustExec("update l_temp_table set id=id+1")
prewriteVal = getLatestBinlogPrewriteValue(c, s.pump)
c.Assert(len(prewriteVal.Mutations), Equals, 0)

tk.MustExec("delete from l_temp_table")
prewriteVal = getLatestBinlogPrewriteValue(c, s.pump)
c.Assert(len(prewriteVal.Mutations), Equals, 0)

tk.MustExec("begin")
tk.MustExec("insert l_temp_table value(1)")
tk.MustExec("update l_temp_table set id=id+1")
tk.MustExec("commit")
prewriteVal = getLatestBinlogPrewriteValue(c, s.pump)
c.Assert(len(prewriteVal.Mutations), Equals, 0)

tk.MustExec("begin")
tk.MustExec("delete from l_temp_table")
tk.MustExec("commit")
prewriteVal = getLatestBinlogPrewriteValue(c, s.pump)
c.Assert(len(prewriteVal.Mutations), Equals, 0)

tk.MustExec("truncate table l_temp_table")
ok = mustGetDDLBinlog(s, latestNonLocalTemporaryTableDDL, c)
c.Assert(ok, IsTrue)

tk.MustExec("drop table l_temp_table")
ok = mustGetDDLBinlog(s, latestNonLocalTemporaryTableDDL, c)
c.Assert(ok, IsTrue)
}