-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add type.tcl and quit.tcl files, fix some bug #398
Changes from 6 commits
3f581dd
bd4d7db
880a7af
48d1a5a
ab864d3
7743948
25c10ac
d4550e6
142b0c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,12 @@ void CmdWorkThreadPoolWorker::Work() { | |
auto [cmdPtr, ret] = cmd_table_manager_.GetCommand(task->CmdName(), task->Client().get()); | ||
|
||
if (!cmdPtr) { | ||
if (ret == CmdRes::kInvalidParameter) { | ||
task->Client()->SetRes(CmdRes::kInvalidParameter); | ||
if (ret == CmdRes::kUnknownCmd) { | ||
task->Client()->SetRes(CmdRes::kErrOther, "unknown command '" + task->CmdName() + "'"); | ||
} else if (ret == CmdRes::kUnknownSubCmd) { | ||
task->Client()->SetRes(CmdRes::kErrOther, "unknown sub command '" + task->Client().get()->argv_[1] + "'"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里是不是应该需要检查一下task->Client().get()中argv[]的大小,避免访问非法内存地址 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} else { | ||
task->Client()->SetRes(CmdRes::kSyntaxErr, "unknown command '" + task->CmdName() + "'"); | ||
task->Client()->SetRes(CmdRes::kInvalidParameter); | ||
} | ||
g_pikiwidb->PushWriteTask(task->Client()); | ||
continue; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,27 +24,29 @@ start_server {tags {"type"}} { | |
assert_equal set [r type key5] | ||
} | ||
|
||
test "ptype none" { | ||
r flushdb | ||
assert_equal {} [r ptype key] | ||
} | ||
|
||
test "ptype command" { | ||
r flushdb | ||
|
||
r set key1 key1 | ||
assert_equal string [r ptype key1] | ||
|
||
r hset key1 key key1 | ||
assert_equal {string hash} [r ptype key1] | ||
|
||
r lpush key1 key1 | ||
assert_equal {string hash list} [r ptype key1] | ||
|
||
r zadd key1 100 key1 | ||
assert_equal {string hash list zset} [r ptype key1] | ||
|
||
r sadd key1 key1 | ||
assert_equal {string hash list zset set} [r ptype key1] | ||
} | ||
#Pikiwidb does not support the ptype command | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ptype这个可以直接删掉了,这个是之前多key版本留下来的测试 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
#test "ptype none" { | ||
# r flushdb | ||
# assert_equal {} [r ptype key] | ||
#} | ||
|
||
#Pikiwidb does not support the ptype command | ||
#test "ptype command" { | ||
# r flushdb | ||
# | ||
# r set key1 key1 | ||
# assert_equal string [r ptype key1] | ||
# | ||
# r hset key1 key key1 | ||
# assert_equal {string hash} [r ptype key1] | ||
# | ||
# r lpush key1 key1 | ||
# assert_equal {string hash list} [r ptype key1] | ||
# | ||
# r zadd key1 100 key1 | ||
# assert_equal {string hash list zset} [r ptype key1] | ||
# | ||
# r sadd key1 key1 | ||
# assert_equal {string hash list zset set} [r ptype key1] | ||
#} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为什么返回改为OK了,是不是原来的逻辑是错的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个方法的逻辑,前面把所有的异常逻辑都 retuen,如果走到最后,应该是正常的 case