diff --git a/store/tikv/snapshot.go b/store/tikv/snapshot.go index 571a6b0d3da5a..1e54955f5fe4e 100644 --- a/store/tikv/snapshot.go +++ b/store/tikv/snapshot.go @@ -557,8 +557,6 @@ func (s *KVSnapshot) SetOption(opt int, val interface{}) { s.notFillCache = val.(bool) case kv.SyncLog: s.syncLog = val.(bool) - case kv.KeyOnly: - s.keyOnly = val.(bool) case kv.SnapshotTS: s.setSnapshotTS(val.(uint64)) case kv.ReplicaRead: @@ -602,6 +600,11 @@ func (s *KVSnapshot) DelOption(opt int) { } } +// SetKeyOnly indicates if tikv can return only keys. +func (s *KVSnapshot) SetKeyOnly(b bool) { + s.keyOnly = b +} + // SetIsolationLevel sets the isolation level used to scan data from tikv. func (s *KVSnapshot) SetIsolationLevel(level IsoLevel) { s.isolationLevel = level diff --git a/store/tikv/tests/lock_test.go b/store/tikv/tests/lock_test.go index d6e20157bc7ac..3c6c652d96041 100644 --- a/store/tikv/tests/lock_test.go +++ b/store/tikv/tests/lock_test.go @@ -26,7 +26,6 @@ import ( "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/tidb/store/tikv" tikverr "github.com/pingcap/tidb/store/tikv/error" - "github.com/pingcap/tidb/store/tikv/kv" "github.com/pingcap/tidb/store/tikv/oracle" "github.com/pingcap/tidb/store/tikv/tikvrpc" ) @@ -142,7 +141,7 @@ func (s *testLockSuite) TestScanLockResolveWithSeekKeyOnly(c *C) { txn, err := s.store.Begin() c.Assert(err, IsNil) - txn.SetOption(kv.KeyOnly, true) + txn.GetSnapshot().SetKeyOnly(true) iter, err := txn.Iter([]byte("a"), nil) c.Assert(err, IsNil) for ch := byte('a'); ch <= byte('z'); ch++ { diff --git a/store/tikv/tests/scan_test.go b/store/tikv/tests/scan_test.go index 91e15747d3894..c64c6c3c52500 100644 --- a/store/tikv/tests/scan_test.go +++ b/store/tikv/tests/scan_test.go @@ -146,7 +146,7 @@ func (s *testScanSuite) TestScan(c *C) { check(c, scan, upperBound, false) txn3 := s.beginTxn(c) - txn3.SetOption(kv.KeyOnly, true) + txn3.GetSnapshot().SetKeyOnly(true) // Test scan without upper bound scan, err = txn3.Iter(s.recordPrefix, nil) c.Assert(err, IsNil) @@ -157,7 +157,7 @@ func (s *testScanSuite) TestScan(c *C) { check(c, scan, upperBound, true) // Restore KeyOnly to false - txn3.SetOption(kv.KeyOnly, false) + txn3.GetSnapshot().SetKeyOnly(false) scan, err = txn3.Iter(s.recordPrefix, nil) c.Assert(err, IsNil) check(c, scan, rowNum, true)