Merge pull request #780 from pingcap/ngaut/clean-up

kv: Remove CommittedVersion from transaction
This commit is contained in:
Ewan Chou
2015-12-23 13:17:17 +08:00
4 changed files with 5 additions and 24 deletions

View File

@ -66,9 +66,6 @@ type Transaction interface {
UnionStore
// Commit commits the transaction operations to KV store.
Commit() error
// CommittedVersion returns the version of this committed transaction. If this
// transaction has not been committed, returns ErrNotCommitted error.
CommittedVersion() (Version, error)
// Rollback undoes the transaction operations to KV store.
Rollback() error
// String implements fmt.Stringer interface.

View File

@ -155,14 +155,6 @@ func (txn *hbaseTxn) Commit() error {
return txn.doCommit()
}
func (txn *hbaseTxn) CommittedVersion() (kv.Version, error) {
// Check if this transaction is not committed.
if txn.version.Cmp(kv.MinVersion) == 0 {
return kv.MinVersion, kv.ErrNotCommitted
}
return txn.version, nil
}
func (txn *hbaseTxn) close() error {
txn.UnionStore.Release()
txn.valid = false

View File

@ -165,14 +165,14 @@ func (t *testMvccSuite) TestSnapshotGet(c *C) {
c.Assert(err, IsNil)
tx.Commit()
lastVer, err := globalVersionProvider.CurrentVersion()
c.Assert(err, IsNil)
// Modify
tx, _ = t.s.Begin()
err = tx.Set(encodeInt(1), []byte("new"))
c.Assert(err, IsNil)
err = tx.Commit()
c.Assert(err, IsNil)
v, err := tx.CommittedVersion()
c.Assert(err, IsNil)
testKey := encodeTestDataKey(1)
snapshot, err := t.s.GetSnapshot(kv.MaxVersion)
@ -182,7 +182,7 @@ func (t *testMvccSuite) TestSnapshotGet(c *C) {
c.Assert(string(b), Equals, "new")
// Get last version
lastVerSnapshot, err := t.s.GetSnapshot(kv.NewVersion(v.Ver - 1))
lastVerSnapshot, err := t.s.GetSnapshot(lastVer)
c.Assert(err, IsNil)
b, err = lastVerSnapshot.Get(testKey)
c.Assert(err, IsNil)
@ -230,7 +230,7 @@ func (t *testMvccSuite) TestMvccSeek(c *C) {
c.Assert(err, IsNil)
err = txn.Commit()
c.Assert(err, IsNil)
v1, err := txn.CommittedVersion()
v1, err := globalVersionProvider.CurrentVersion()
c.Assert(err, IsNil)
txn, err = t.s.Begin()
@ -239,7 +239,7 @@ func (t *testMvccSuite) TestMvccSeek(c *C) {
c.Assert(err, IsNil)
err = txn.Commit()
c.Assert(err, IsNil)
v2, err := txn.CommittedVersion()
v2, err := globalVersionProvider.CurrentVersion()
c.Assert(err, IsNil)
s = t.getSnapshot(c, v2)

View File

@ -142,14 +142,6 @@ func (txn *dbTxn) Commit() error {
return errors.Trace(txn.doCommit())
}
func (txn *dbTxn) CommittedVersion() (kv.Version, error) {
// Check if this transaction is not committed.
if txn.version.Cmp(kv.MinVersion) == 0 {
return kv.MinVersion, kv.ErrNotCommitted
}
return txn.version, nil
}
func (txn *dbTxn) close() error {
txn.UnionStore.Release()
txn.snapshotVals = nil