Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions errno/errcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@ const (
ErrNotSupportedWithSem = 8132
ErrDataInConsistentExtraIndex = 8133
ErrDataInConsistentMisMatchIndex = 8134
ErrAsOf = 8135

// Error codes used by TiDB ddl package
ErrUnsupportedDDLOperation = 8200
Expand Down
1 change: 1 addition & 0 deletions errno/errname.go
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,7 @@ var MySQLErrName = map[uint16]*mysql.ErrMessage{
ErrInvalidPlacementSpec: mysql.Message("Invalid placement policy '%s': %s", nil),
ErrPlacementPolicyCheck: mysql.Message("Placement policy didn't meet the constraint, reason: %s", nil),
ErrMultiStatementDisabled: mysql.Message("client has multi-statement capability disabled. Run SET GLOBAL tidb_multi_statement_mode='ON' after you understand the security risk", nil),
ErrAsOf: mysql.Message("invalid as of timestamp: %s", nil),

// TiKV/PD errors.
ErrPDServerTimeout: mysql.Message("PD server timeout", nil),
Expand Down
5 changes: 5 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,11 @@ error = '''
Feature '%s' is not supported when security enhanced mode is enabled
'''

["planner:8135"]
error = '''
invalid as of timestamp: %s
'''

["privilege:1141"]
error = '''
There is no such grant defined for user '%-.48s' on host '%-.64s'
Expand Down
4 changes: 2 additions & 2 deletions executor/stale_txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ func (s *testStaleTxnSuite) TestStaleSelect(c *C) {

// test prepared stale select in txn
tk.MustExec("begin")
tk.MustQuery("execute s").Check(staleRows)
c.Assert(tk.ExecToErr(staleSQL), NotNil)
tk.MustExec("commit")

// test stale select in stale txn
Expand All @@ -825,7 +825,7 @@ func (s *testStaleTxnSuite) TestStaleSelect(c *C) {

// test prepared stale select in stale txn
tk.MustExec(fmt.Sprintf(`start transaction read only as of timestamp '%s'`, time2.Format("2006-1-2 15:04:05.000")))
tk.MustQuery("execute s").Check(staleRows)
c.Assert(tk.ExecToErr(staleSQL), NotNil)
tk.MustExec("commit")

// test prepared stale select with schema change
Expand Down
3 changes: 3 additions & 0 deletions planner/core/common_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ func (e *Execute) OptimizePreparedPlan(ctx context.Context, sctx sessionctx.Cont

var snapshotTS uint64
if preparedObj.SnapshotTSEvaluator != nil {
if vars.InTxn() {
return ErrAsOf.FastGenWithCause("as of timestamp can't be set in transaction.")
}
// if preparedObj.SnapshotTSEvaluator != nil, it is a stale read SQL:
// which means its infoschema is specified by the SQL, not the current/latest infoschema
var err error
Expand Down
3 changes: 1 addition & 2 deletions planner/core/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ var (
ErrAccessDenied = dbterror.ClassOptimizer.NewStdErr(mysql.ErrAccessDenied, mysql.MySQLErrName[mysql.ErrAccessDeniedNoPassword])
ErrBadNull = dbterror.ClassOptimizer.NewStd(mysql.ErrBadNull)
ErrNotSupportedWithSem = dbterror.ClassOptimizer.NewStd(mysql.ErrNotSupportedWithSem)
ErrDifferentAsOf = dbterror.ClassOptimizer.NewStd(mysql.ErrUnknown)
ErrAsOf = dbterror.ClassOptimizer.NewStd(mysql.ErrUnknown)
ErrAsOf = dbterror.ClassOptimizer.NewStd(mysql.ErrAsOf)
ErrOptOnTemporaryTable = dbterror.ClassOptimizer.NewStd(mysql.ErrOptOnTemporaryTable)
)
2 changes: 1 addition & 1 deletion planner/core/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ func (p *preprocessor) handleAsOfAndReadTS(node *ast.AsOfClause) {
}
}
if p.LastSnapshotTS != ts {
p.err = ErrDifferentAsOf.GenWithStack("can not set different time in the as of")
p.err = ErrAsOf.GenWithStack("can not set different time in the as of")
return
}
if p.LastSnapshotTS != 0 {
Expand Down