|
@@ -58,6 +58,8 @@ type txn struct {
|
|
|
cthen bool
|
|
cthen bool
|
|
|
celse bool
|
|
celse bool
|
|
|
|
|
|
|
|
|
|
+ isWrite bool
|
|
|
|
|
+
|
|
|
cmps []*pb.Compare
|
|
cmps []*pb.Compare
|
|
|
|
|
|
|
|
sus []*pb.RequestUnion
|
|
sus []*pb.RequestUnion
|
|
@@ -101,6 +103,7 @@ func (txn *txn) Then(ops ...Op) Txn {
|
|
|
txn.cthen = true
|
|
txn.cthen = true
|
|
|
|
|
|
|
|
for _, op := range ops {
|
|
for _, op := range ops {
|
|
|
|
|
+ txn.isWrite = txn.isWrite || op.isWrite()
|
|
|
txn.sus = append(txn.sus, op.toRequestUnion())
|
|
txn.sus = append(txn.sus, op.toRequestUnion())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -118,6 +121,7 @@ func (txn *txn) Else(ops ...Op) Txn {
|
|
|
txn.celse = true
|
|
txn.celse = true
|
|
|
|
|
|
|
|
for _, op := range ops {
|
|
for _, op := range ops {
|
|
|
|
|
+ txn.isWrite = txn.isWrite || op.isWrite()
|
|
|
txn.fas = append(txn.fas, op.toRequestUnion())
|
|
txn.fas = append(txn.fas, op.toRequestUnion())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -137,6 +141,10 @@ func (txn *txn) Commit() (*TxnResponse, error) {
|
|
|
return (*TxnResponse)(resp), nil
|
|
return (*TxnResponse)(resp), nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if txn.isWrite {
|
|
|
|
|
+ return nil, err
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if isRPCError(err) {
|
|
if isRPCError(err) {
|
|
|
return nil, err
|
|
return nil, err
|
|
|
}
|
|
}
|