client-go icon indicating copy to clipboard operation
client-go copied to clipboard

Empty value is not supported

Open sticnarf opened this issue 4 years ago • 4 comments

It is a historical problem. This client is extracted from TiDB. In TiDB, every key has a non-empty value. In the implementation, the client treats an empty value as the key does not exist, and it also rejects putting a pair with empty value.

But TiKV actually supports a key with zero-length value. The user can put a key with an empty value with another client (e.g. client-rust). Then, they will find the key does not exist when reading with this client.

cc @andylokandy @disksing

sticnarf avatar Jun 16 '21 11:06 sticnarf

The problem is not as simple as it seems, because client's unionstore(memberbuffer) also uses empty value to indicate deletion.

disksing avatar Jun 16 '21 13:06 disksing

Maybe we can distinguish them via []byte{nil} and []byte("").

Xuanwo avatar Jun 21 '21 01:06 Xuanwo

seems solved by https://github.com/tikv/client-go/pull/612

Smityz avatar Dec 23 '22 06:12 Smityz

now we only support nil value for rawkv API. txnkv still disallows empty value.

disksing avatar Jan 12 '23 06:01 disksing