Skip to content

Commit 1cff1e8

Browse files
bootjpCopilot
andauthored
Update proxy/pubsub.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent dc10487 commit 1cff1e8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

proxy/pubsub.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,14 @@ func (s *pubsubSession) handleProxySpecialCommand(name string, args [][]byte) bo
333333
if name != "SELECT" {
334334
return false
335335
}
336-
if len(args) > 1 && string(args[1]) != "0" && string(args[1]) != fmt.Sprintf("%d", s.proxy.cfg.PrimaryDB) {
337-
s.writeError(fmt.Sprintf("ERR proxy does not support SELECT %s (configured DB: %d)", string(args[1]), s.proxy.cfg.PrimaryDB))
336+
// Enforce Redis arity: SELECT requires exactly one DB index argument.
337+
if len(args) != 2 {
338+
s.writeError("ERR wrong number of arguments for 'select' command")
339+
return true
340+
}
341+
dbStr := string(args[1])
342+
if dbStr != fmt.Sprintf("%d", s.proxy.cfg.PrimaryDB) {
343+
s.writeError(fmt.Sprintf("ERR proxy configured for DB %d, but SELECT %s requested", s.proxy.cfg.PrimaryDB, dbStr))
338344
return true
339345
}
340346
s.writeString("OK")

0 commit comments

Comments
 (0)