@@ -102,13 +102,23 @@ class CommandNamespace : public Commander {
102102 Status s = srv->GetNamespace ()->Del (args_[2 ]);
103103 *output = s.IsOK () ? redis::RESP_OK : redis::Error (s);
104104 warn (" Deleted namespace: {}, addr: {}, result: {}" , args_[2 ], conn->GetAddr (), s.Msg ());
105+ } else if (args_.size () == 2 && sub_command == " current" ) {
106+ *output = redis::BulkString (conn->GetNamespace ());
105107 } else {
106- return {Status::RedisExecErr, " NAMESPACE subcommand must be one of GET, SET, DEL, ADD" };
108+ return {Status::RedisExecErr, " NAMESPACE subcommand must be one of GET, SET, DEL, ADD and CURRENT " };
107109 }
108110 return Status::OK ();
109111 }
110112};
111113
114+ static uint64_t GenerateNamespaceFlag (uint64_t flags, const std::vector<std::string> &args) {
115+ if (args.size () >= 2 && util::EqualICase (args[1 ], " current" )) {
116+ return flags & ~kCmdAdmin ;
117+ }
118+
119+ return flags;
120+ }
121+
112122class CommandKeys : public Commander {
113123 public:
114124 Status Execute (engine::Context &ctx, Server *srv, Connection *conn, std::string *output) override {
@@ -1539,49 +1549,48 @@ class CommandFlushBlockCache : public Commander {
15391549 }
15401550};
15411551
1542- REDIS_REGISTER_COMMANDS (Server, MakeCmdAttr<CommandAuth>(" auth" , 2 , " read-only ok-loading auth" , NO_KEY ),
1543- MakeCmdAttr<CommandPing>(" ping" , -1 , " read-only" , NO_KEY ),
1544- MakeCmdAttr<CommandSelect>(" select" , 2 , " read-only" , NO_KEY ),
1545- MakeCmdAttr<CommandInfo>(" info" , -1 , " read-only ok-loading" , NO_KEY ),
1546- MakeCmdAttr<CommandRole>(" role" , 1 , " read-only ok-loading" , NO_KEY ),
1547- MakeCmdAttr<CommandConfig>(" config" , -2 , " read-only admin" , NO_KEY , GenerateConfigFlag),
1548- MakeCmdAttr<CommandNamespace>(" namespace" , -3 , " read-only admin" , NO_KEY ),
1549- MakeCmdAttr<CommandKeys>(" keys" , 2 , " read-only slow" , NO_KEY ),
1550- MakeCmdAttr<CommandFlushDB>(" flushdb" , 1 , " write no-dbsize-check exclusive" , NO_KEY ),
1551- MakeCmdAttr<CommandFlushAll>(" flushall" , 1 , " write no-dbsize-check exclusive admin" , NO_KEY ),
1552- MakeCmdAttr<CommandDBSize>(" dbsize" , -1 , " read-only" , NO_KEY ),
1553- MakeCmdAttr<CommandSlowlog>(" slowlog" , -2 , " read-only" , NO_KEY ),
1554- MakeCmdAttr<CommandKProfile>(" kprofile" , -3 , " read-only admin" , NO_KEY ),
1555- MakeCmdAttr<CommandPerfLog>(" perflog" , -2 , " read-only" , NO_KEY ),
1556- MakeCmdAttr<CommandClient>(" client" , -2 , " read-only" , NO_KEY ),
1557- MakeCmdAttr<CommandMonitor>(" monitor" , 1 , " read-only no-multi no-script" , NO_KEY ),
1558- MakeCmdAttr<CommandShutdown>(" shutdown" , 1 , " read-only exclusive no-multi no-script admin" ,
1559- NO_KEY ),
1560- MakeCmdAttr<CommandQuit>(" quit" , 1 , " read-only" , NO_KEY ),
1561- MakeCmdAttr<CommandScan>(" scan" , -2 , " read-only" , NO_KEY ),
1562- MakeCmdAttr<CommandRandomKey>(" randomkey" , 1 , " read-only" , NO_KEY ),
1563- MakeCmdAttr<CommandDebug>(" debug" , -2 , " read-only exclusive" , NO_KEY , CommandDebug::FlagGen),
1564- MakeCmdAttr<CommandCommand>(" command" , -1 , " read-only" , NO_KEY ),
1565- MakeCmdAttr<CommandEcho>(" echo" , 2 , " read-only" , NO_KEY ),
1566- MakeCmdAttr<CommandTime>(" time" , 1 , " read-only ok-loading" , NO_KEY ),
1567- MakeCmdAttr<CommandDisk>(" disk" , 3 , " read-only" , 2 , 2 , 1 ),
1568- MakeCmdAttr<CommandMemory>(" memory" , 3 , " read-only" , 2 , 2 , 1 ),
1569- MakeCmdAttr<CommandHello>(" hello" , -1 , " read-only ok-loading auth" , NO_KEY ),
1570- MakeCmdAttr<CommandRestore>(" restore" , -4 , " write" , 1 , 1 , 1 ),
1571-
1572- MakeCmdAttr<CommandCompact>(" compact" , 1 , " read-only no-script" , NO_KEY ),
1573- MakeCmdAttr<CommandBGSave>(" bgsave" , 1 , " read-only no-script admin" , NO_KEY ),
1574- MakeCmdAttr<CommandLastSave>(" lastsave" , -1 , " read-only admin" , NO_KEY ),
1575- MakeCmdAttr<CommandFlushBackup>(" flushbackup" , 1 , " read-only no-script admin" , NO_KEY ),
1576- MakeCmdAttr<CommandSlaveOf>(" slaveof" , 3 , " read-only exclusive no-script admin" , NO_KEY ),
1577- MakeCmdAttr<CommandSlaveOf>(" replicaof" , 3 , " read-only exclusive no-script admin" , NO_KEY ),
1578- MakeCmdAttr<CommandStats>(" stats" , 1 , " read-only" , NO_KEY ),
1579- MakeCmdAttr<CommandRdb>(" rdb" , -3 , " write exclusive admin" , NO_KEY ),
1580- MakeCmdAttr<CommandReset>(" reset" , 1 , " ok-loading bypass-multi no-script" , NO_KEY ),
1581- MakeCmdAttr<CommandApplyBatch>(" applybatch" , -2 , " write no-multi" , NO_KEY ),
1582- MakeCmdAttr<CommandDump>(" dump" , 2 , " read-only" , 1 , 1 , 1 ),
1583- MakeCmdAttr<CommandPollUpdates>(" pollupdates" , -2 , " read-only admin" , NO_KEY ),
1584- MakeCmdAttr<CommandSST>(" sst" , -3 , " write exclusive admin" , 1 , 1 , 1 ),
1585- MakeCmdAttr<CommandFlushMemTable>(" flushmemtable" , -1 , " exclusive write" , NO_KEY ),
1586- MakeCmdAttr<CommandFlushBlockCache>(" flushblockcache" , 1 , " exclusive write" , NO_KEY ), )
1552+ REDIS_REGISTER_COMMANDS (
1553+ Server, MakeCmdAttr<CommandAuth>(" auth" , 2 , " read-only ok-loading auth" , NO_KEY ),
1554+ MakeCmdAttr<CommandPing>(" ping" , -1 , " read-only" , NO_KEY ),
1555+ MakeCmdAttr<CommandSelect>(" select" , 2 , " read-only" , NO_KEY ),
1556+ MakeCmdAttr<CommandInfo>(" info" , -1 , " read-only ok-loading" , NO_KEY ),
1557+ MakeCmdAttr<CommandRole>(" role" , 1 , " read-only ok-loading" , NO_KEY ),
1558+ MakeCmdAttr<CommandConfig>(" config" , -2 , " read-only admin" , NO_KEY , GenerateConfigFlag),
1559+ MakeCmdAttr<CommandNamespace>(" namespace" , -2 , " read-only admin" , NO_KEY , GenerateNamespaceFlag),
1560+ MakeCmdAttr<CommandKeys>(" keys" , 2 , " read-only slow" , NO_KEY ),
1561+ MakeCmdAttr<CommandFlushDB>(" flushdb" , 1 , " write no-dbsize-check exclusive" , NO_KEY ),
1562+ MakeCmdAttr<CommandFlushAll>(" flushall" , 1 , " write no-dbsize-check exclusive admin" , NO_KEY ),
1563+ MakeCmdAttr<CommandDBSize>(" dbsize" , -1 , " read-only" , NO_KEY ),
1564+ MakeCmdAttr<CommandSlowlog>(" slowlog" , -2 , " read-only" , NO_KEY ),
1565+ MakeCmdAttr<CommandKProfile>(" kprofile" , -3 , " read-only admin" , NO_KEY ),
1566+ MakeCmdAttr<CommandPerfLog>(" perflog" , -2 , " read-only" , NO_KEY ),
1567+ MakeCmdAttr<CommandClient>(" client" , -2 , " read-only" , NO_KEY ),
1568+ MakeCmdAttr<CommandMonitor>(" monitor" , 1 , " read-only no-multi no-script" , NO_KEY ),
1569+ MakeCmdAttr<CommandShutdown>(" shutdown" , 1 , " read-only exclusive no-multi no-script admin" , NO_KEY ),
1570+ MakeCmdAttr<CommandQuit>(" quit" , 1 , " read-only" , NO_KEY ), MakeCmdAttr<CommandScan>(" scan" , -2 , " read-only" , NO_KEY ),
1571+ MakeCmdAttr<CommandRandomKey>(" randomkey" , 1 , " read-only" , NO_KEY ),
1572+ MakeCmdAttr<CommandDebug>(" debug" , -2 , " read-only exclusive" , NO_KEY , CommandDebug::FlagGen),
1573+ MakeCmdAttr<CommandCommand>(" command" , -1 , " read-only" , NO_KEY ),
1574+ MakeCmdAttr<CommandEcho>(" echo" , 2 , " read-only" , NO_KEY ),
1575+ MakeCmdAttr<CommandTime>(" time" , 1 , " read-only ok-loading" , NO_KEY ),
1576+ MakeCmdAttr<CommandDisk>(" disk" , 3 , " read-only" , 2 , 2 , 1 ),
1577+ MakeCmdAttr<CommandMemory>(" memory" , 3 , " read-only" , 2 , 2 , 1 ),
1578+ MakeCmdAttr<CommandHello>(" hello" , -1 , " read-only ok-loading auth" , NO_KEY ),
1579+ MakeCmdAttr<CommandRestore>(" restore" , -4 , " write" , 1 , 1 , 1 ),
1580+
1581+ MakeCmdAttr<CommandCompact>(" compact" , 1 , " read-only no-script" , NO_KEY ),
1582+ MakeCmdAttr<CommandBGSave>(" bgsave" , 1 , " read-only no-script admin" , NO_KEY ),
1583+ MakeCmdAttr<CommandLastSave>(" lastsave" , -1 , " read-only admin" , NO_KEY ),
1584+ MakeCmdAttr<CommandFlushBackup>(" flushbackup" , 1 , " read-only no-script admin" , NO_KEY ),
1585+ MakeCmdAttr<CommandSlaveOf>(" slaveof" , 3 , " read-only exclusive no-script admin" , NO_KEY ),
1586+ MakeCmdAttr<CommandSlaveOf>(" replicaof" , 3 , " read-only exclusive no-script admin" , NO_KEY ),
1587+ MakeCmdAttr<CommandStats>(" stats" , 1 , " read-only" , NO_KEY ),
1588+ MakeCmdAttr<CommandRdb>(" rdb" , -3 , " write exclusive admin" , NO_KEY ),
1589+ MakeCmdAttr<CommandReset>(" reset" , 1 , " ok-loading bypass-multi no-script" , NO_KEY ),
1590+ MakeCmdAttr<CommandApplyBatch>(" applybatch" , -2 , " write no-multi" , NO_KEY ),
1591+ MakeCmdAttr<CommandDump>(" dump" , 2 , " read-only" , 1 , 1 , 1 ),
1592+ MakeCmdAttr<CommandPollUpdates>(" pollupdates" , -2 , " read-only admin" , NO_KEY ),
1593+ MakeCmdAttr<CommandSST>(" sst" , -3 , " write exclusive admin" , 1 , 1 , 1 ),
1594+ MakeCmdAttr<CommandFlushMemTable>(" flushmemtable" , -1 , " exclusive write" , NO_KEY ),
1595+ MakeCmdAttr<CommandFlushBlockCache>(" flushblockcache" , 1 , " exclusive write" , NO_KEY ), )
15871596} // namespace redis
0 commit comments