Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
sylzd committed Aug 19, 2021
1 parent 79f0b49 commit a6b44b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4525,6 +4525,10 @@ func (b *executorBuilder) validCanReadTemporaryTable(tbl *model.TableInfo) error

sessionVars := b.ctx.GetSessionVars()

if tbl.TempTableType == model.TempTableLocal && sessionVars.SnapshotTS != 0 {
return errors.New("can not read local temporary table when 'tidb_snapshot' is set")
}

if sessionVars.TxnCtx.IsStaleness || b.isStaleness {
return errors.New("can not stale read temporary table")
}
Expand Down
8 changes: 6 additions & 2 deletions executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8947,9 +8947,13 @@ func (s *testStaleTxnSuite) TestInvalidReadTemporaryTable(c *C) {

tk.MustExec("set @@tidb_snapshot=NOW(6)")
for _, query := range queries {
// forbidden historical read local temporary table
if strings.Contains(query.sql, "tmp2") {
tk.MustGetErrMsg(query.sql, "can not read local temporary table when 'tidb_snapshot' is set")
continue
}
// Will success here for compatibility with some tools like dumping
rs := tk.MustQuery(query.sql)
rs.Check(testkit.Rows())
tk.MustQuery(query.sql).Check(testkit.Rows())
}
}

Expand Down

0 comments on commit a6b44b7

Please sign in to comment.