mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
lmdb support empty values, but not empty keys (#674)
This commit is contained in:
parent
5b051d9ab3
commit
e09b386fc3
@ -95,7 +95,7 @@ func testPutGet(db MinDatabase, t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, k := range testValues {
|
||||
err := db.Put(testBucket, []byte(k), []byte{1})
|
||||
err := db.Put(testBucket, []byte(k), []byte{})
|
||||
if err != nil {
|
||||
t.Fatalf("put failed: %v", err)
|
||||
}
|
||||
@ -106,8 +106,8 @@ func testPutGet(db MinDatabase, t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("get failed: %v", err)
|
||||
}
|
||||
if len(data) != 1 {
|
||||
t.Fatalf("get returned wrong result, got %q expected 1", string(data))
|
||||
if len(data) != 0 {
|
||||
t.Fatalf("get returned wrong result, got %q expected nil", string(data))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,9 +425,6 @@ func (b *lmdbBucket) Put(key []byte, value []byte) error {
|
||||
if len(key) == 0 {
|
||||
return fmt.Errorf("lmdb doesn't support empty keys. bucket: %s", dbutils.Buckets[b.id])
|
||||
}
|
||||
if len(value) == 0 {
|
||||
return fmt.Errorf("lmdb doesn't support empty values. bucket: %s", dbutils.Buckets[b.id])
|
||||
}
|
||||
|
||||
err := b.tx.tx.Put(b.dbi, key, value, 0)
|
||||
if err != nil {
|
||||
@ -601,9 +598,6 @@ func (c *lmdbCursor) Put(key []byte, value []byte) error {
|
||||
if len(key) == 0 {
|
||||
return fmt.Errorf("lmdb doesn't support empty keys. bucket: %s", dbutils.Buckets[c.bucket.id])
|
||||
}
|
||||
if len(value) == 0 {
|
||||
return fmt.Errorf("lmdb doesn't support empty values. bucket: %s", dbutils.Buckets[c.bucket.id])
|
||||
}
|
||||
if c.cursor == nil {
|
||||
if err := c.initCursor(); err != nil {
|
||||
return err
|
||||
|
Loading…
Reference in New Issue
Block a user