diff --git a/conn.go b/conn.go index 3daca6250..da834cc20 100644 --- a/conn.go +++ b/conn.go @@ -1554,6 +1554,10 @@ func (c *Conn) executeBatch(ctx context.Context, batch *Batch) *Iter { customPayload: batch.CustomPayload, } + if c.version > protoVersion4 { + req.keyspace = c.currentKeyspace + } + stmts := make(map[string]string, len(batch.Entries)) for i := 0; i < n; i++ { diff --git a/frame.go b/frame.go index d374ae574..80b79c943 100644 --- a/frame.go +++ b/frame.go @@ -1659,6 +1659,9 @@ type writeBatchFrame struct { //v4+ customPayload map[string][]byte + + //v5+ + keyspace string } func (w *writeBatchFrame) buildFrame(framer *framer, streamID int) error { @@ -1719,6 +1722,9 @@ func (f *framer) writeBatchFrame(streamID int, w *writeBatchFrame, customPayload } if f.proto > protoVersion4 { + if w.keyspace != "" { + flags |= flagWithKeyspace + } f.writeUint(uint32(flags)) } else { f.writeByte(flags) @@ -1737,6 +1743,13 @@ func (f *framer) writeBatchFrame(streamID int, w *writeBatchFrame, customPayload } f.writeLong(ts) } + + if w.keyspace != "" { + if f.proto < protoVersion5 { + panic(fmt.Errorf("the keyspace can only be set with protocol 5 or higher")) + } + f.writeString(w.keyspace) + } } return f.finish()