Skip to content

Commit

Permalink
Merge branch 'master' into rwmutex_replace_mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
likzn committed Apr 6, 2022
2 parents cf94d6b + 164261c commit bdfc31c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions executor/stale_txn_test.go
Expand Up @@ -1334,3 +1334,19 @@ func TestIssue30872(t *testing.T) {
tk.MustExec("set autocommit=0")
tk.MustQuery("select * from t1 as of timestamp @a").Check(testkit.Rows("1 10"))
}

func TestIssue33728(t *testing.T) {
store, _, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t1 (id int primary key, v int)")
err := tk.ExecToErr("select * from t1 as of timestamp NULL")
require.Error(t, err)
require.Equal(t, "[planner:8135]invalid as of timestamp: as of timestamp cannot be NULL", err.Error())

err = tk.ExecToErr("start transaction read only as of timestamp NULL")
require.Error(t, err)
require.Equal(t, "[planner:8135]invalid as of timestamp: as of timestamp cannot be NULL", err.Error())
}
5 changes: 5 additions & 0 deletions sessiontxn/staleread/util.go
Expand Up @@ -31,6 +31,11 @@ func CalculateAsOfTsExpr(sctx sessionctx.Context, asOfClause *ast.AsOfClause) (u
if err != nil {
return 0, err
}

if tsVal.IsNull() {
return 0, errAsOf.FastGenWithCause("as of timestamp cannot be NULL")
}

toTypeTimestamp := types.NewFieldType(mysql.TypeTimestamp)
// We need at least the millionsecond here, so set fsp to 3.
toTypeTimestamp.Decimal = 3
Expand Down

0 comments on commit bdfc31c

Please sign in to comment.