Skip to content

Commit

Permalink
Ensure the count is right when limit is specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcferretti committed Jul 19, 2024
1 parent 879c9b9 commit 1e2fbfd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/etcdserver/txn/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,13 @@ func processKvsInRange(r *pb.RangeRequest, rr *mvcc.RangeResult, resp *pb.RangeR
pruneKVs(rr, f)
}

// No more prunning after this point; we can count now.
resp.Count = int64(len(rr.KVs))
// If r.CountOnly was specified:
// * r.SortOrder is useless and ignored.
// * r.Limit is useless and ignored.
if r.CountOnly {
resp.Kvs = make([]*mvccpb.KeyValue, 0)
resp.Count = int64(len(rr.KVs))
return
}

Expand Down Expand Up @@ -272,7 +273,6 @@ func processKvsInRange(r *pb.RangeRequest, rr *mvcc.RangeResult, resp *pb.RangeR
}
resp.Kvs[i] = &rr.KVs[i]
}
resp.Count = int64(len(resp.Kvs))
}

func Txn(ctx context.Context, lg *zap.Logger, rt *pb.TxnRequest, txnModeWriteWithSharedBuffer bool, kv mvcc.KV, lessor lease.Lessor) (*pb.TxnResponse, *traceutil.Trace, error) {
Expand Down

0 comments on commit 1e2fbfd

Please sign in to comment.