git-hulk commented on code in PR #3294:
URL: https://github.com/apache/kvrocks/pull/3294#discussion_r2616952347


##########
src/commands/cmd_server.cc:
##########
@@ -201,8 +201,29 @@ class CommandPing : public Commander {
 
 class CommandSelect : public Commander {
  public:
-  Status Execute([[maybe_unused]] engine::Context &ctx, [[maybe_unused]] 
Server *srv, [[maybe_unused]] Connection *conn,
+  Status Execute([[maybe_unused]] engine::Context &ctx, Server *srv, 
Connection *conn,
                  std::string *output) override {
+    Config *config = srv->GetConfig();
+    // If redis-select-compatible is not enabled, just return OK (default 
behavior)
+    if (!config->redis_select_compatible) {
+      *output = redis::RESP_OK;
+      return Status::OK();
+    }
+
+    // Parse database index
+    auto parse_result = ParseInt<int>(args_[1], 10);
+    if (!parse_result) {
+      return {Status::RedisParseErr, "Invalid DB index"};
+    }
+    int db_index = *parse_result;
+    // Validate database index range
+    if (db_index < 0 || db_index >= config->redis_databases) {
+      return {Status::RedisParseErr, "Invalid DB index"};
+    }
+
+    // Use database index as namespace
+    std::string ns = std::to_string(db_index);

Review Comment:
   Should we use the default namespace if the DB is 0?



##########
src/server/server.cc:
##########
@@ -158,6 +158,18 @@ Status Server::Start() {
   if (!s.IsOK()) {
     return s;
   }
+
+  // Validate redis-select-compatible mode configuration
+  if (config_->redis_select_compatible) {

Review Comment:
   You can check this after loading the configuration file: 
https://github.com/apache/kvrocks/blob/unstable/src/config/config.cc#L886C16-L886C22



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to