// createPutRequest returns a ready-made request using the // specified key, value & txn ID. func createPutRequest(key roachpb.Key, value []byte, txn *roachpb.Transaction) (*roachpb.PutRequest, roachpb.BatchRequest_Header) { h := roachpb.BatchRequest_Header{} h.Txn = txn return &roachpb.PutRequest{ RequestHeader: roachpb.RequestHeader{ Key: key, }, Value: roachpb.Value{Bytes: value}, }, h }
func createDeleteRangeRequest(key, endKey roachpb.Key, txn *roachpb.Transaction) (*roachpb.DeleteRangeRequest, roachpb.BatchRequest_Header) { h := roachpb.BatchRequest_Header{} h.Txn = txn return &roachpb.DeleteRangeRequest{ RequestHeader: roachpb.RequestHeader{ Key: key, EndKey: endKey, }, }, h }
// UpdateForBatch updates the first argument (the header of a request contained // in a batch) from the second one (the batch header), returning an error when // inconsistencies are found. // It is checked that the individual call does not have a UserPriority // or Txn set that differs from the batch's. // TODO(tschottdorf): will go with #2143. func updateForBatch(args roachpb.Request, bHeader roachpb.BatchRequest_Header) error { // Disallow transaction, user and priority on individual calls, unless // equal. aHeader := args.Header() if aPrio := aHeader.GetUserPriority(); aPrio != roachpb.Default_RequestHeader_UserPriority && aPrio != bHeader.GetUserPriority() { return util.Errorf("conflicting user priority on call in batch") } aHeader.UserPriority = bHeader.UserPriority aHeader.Txn = bHeader.Txn // reqs always take Txn from batch return nil }