Skip to content

Commit d42d0c7

Browse files
authored
fix(zset): register zdiffstore as write command (#3486)
`ZDIFFSTORE` writes results to a destination key, but it was previously registered as `read-only slow`. I fix it. I used codex gpt-5.5 to find and fix it.
1 parent b654013 commit d42d0c7

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/commands/cmd_zset.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,6 @@ REDIS_REGISTER_COMMANDS(ZSet, MakeCmdAttr<CommandZAdd>("zadd", -4, "write", 1, 1
15941594
MakeCmdAttr<CommandZUnion>("zunion", -3, "read-only slow", CommandZUnion::Range),
15951595
MakeCmdAttr<CommandZRandMember>("zrandmember", -2, "read-only", 1, 1, 1),
15961596
MakeCmdAttr<CommandZDiff>("zdiff", -3, "read-only slow", CommandZDiff::Range),
1597-
MakeCmdAttr<CommandZDiffStore>("zdiffstore", -3, "read-only slow", CommandZDiffStore::Range), )
1597+
MakeCmdAttr<CommandZDiffStore>("zdiffstore", -3, "write slow", CommandZDiffStore::Range), )
15981598

15991599
} // namespace redis

tests/gocase/unit/command/command_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ func TestCommand(t *testing.T) {
5353
require.EqualValues(t, 1, v[5])
5454
})
5555

56+
t.Run("acquire ZDIFFSTORE command info by COMMAND INFO", func(t *testing.T) {
57+
r := rdb.Do(ctx, "COMMAND", "INFO", "ZDIFFSTORE")
58+
vs, err := r.Slice()
59+
require.NoError(t, err)
60+
require.Len(t, vs, 1)
61+
v := vs[0].([]interface{})
62+
require.Len(t, v, 6)
63+
require.Equal(t, "zdiffstore", v[0])
64+
require.EqualValues(t, -3, v[1])
65+
require.Equal(t, []interface{}{"write", "slow"}, v[2])
66+
})
67+
5668
t.Run("acquire renamed command info by COMMAND INFO", func(t *testing.T) {
5769
r := rdb.Do(ctx, "COMMAND", "INFO", "KEYS")
5870
vs, err := r.Slice()

0 commit comments

Comments
 (0)