This is an automated email from the ASF dual-hosted git repository.
hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 9e4bb2ca Fix wrongly append the ERR prefix in no script error (#1162)
9e4bb2ca is described below
commit 9e4bb2ca4ff03a5aa1514c383e5e152406ce4e3b
Author: hulk <[email protected]>
AuthorDate: Tue Dec 6 09:53:38 2022 +0800
Fix wrongly append the ERR prefix in no script error (#1162)
---
src/commands/redis_cmd.cc | 23 +++++++++--------------
tests/gocase/unit/scripting/scripting_test.go | 6 +++---
2 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/src/commands/redis_cmd.cc b/src/commands/redis_cmd.cc
index 6560fc6e..8edcef61 100644
--- a/src/commands/redis_cmd.cc
+++ b/src/commands/redis_cmd.cc
@@ -80,6 +80,7 @@ const char *errLimitOptionNotAllowed = "syntax error, LIMIT
cannot be used witho
const char *errZSetLTGTNX = "GT, LT, and/or NX options at the same time are
not compatible";
const char *errScoreIsNotValidFloat = "score is not a valid float";
const char *errValueIsNotFloat = "value is not a valid float";
+const char *errNoMatchingScript = "NOSCRIPT No matching script. Please use
EVAL";
enum class AuthResult {
OK,
@@ -5311,14 +5312,11 @@ class CommandEval : public Commander {
class CommandEvalSHA : public Commander {
public:
- Status Parse(const std::vector<std::string> &args) override {
- if (args[1].size() != 40) {
- return {Status::NotOK, "NOSCRIPT No matching script. Please use EVAL"};
- }
- return Status::OK();
- }
-
Status Execute(Server *svr, Connection *conn, std::string *output) override {
+ if (args_[1].size() != 40) {
+ *output = Redis::Error(errNoMatchingScript);
+ return Status::OK();
+ }
return Lua::evalGenericCommand(conn, args_, true, output);
}
};
@@ -5332,14 +5330,11 @@ class CommandEvalRO : public Commander {
class CommandEvalSHARO : public Commander {
public:
- Status Parse(const std::vector<std::string> &args) override {
- if (args[1].size() != 40) {
- return {Status::NotOK, "NOSCRIPT No matching script. Please use EVAL"};
- }
- return Status::OK();
- }
-
Status Execute(Server *svr, Connection *conn, std::string *output) override {
+ if (args_[1].size() != 40) {
+ *output = Redis::Error(errNoMatchingScript);
+ return Status::OK();
+ }
return Lua::evalGenericCommand(conn, args_, true, output, true);
}
};
diff --git a/tests/gocase/unit/scripting/scripting_test.go
b/tests/gocase/unit/scripting/scripting_test.go
index 984f6cbd..cf9549bc 100644
--- a/tests/gocase/unit/scripting/scripting_test.go
+++ b/tests/gocase/unit/scripting/scripting_test.go
@@ -120,13 +120,13 @@ func TestScripting(t *testing.T) {
t.Run("EVALSHA - Do we get an error on invalid SHA1?", func(t
*testing.T) {
r := rdb.EvalSha(ctx, "NotValidShaSUM", []string{})
- util.ErrorRegexp(t, r.Err(), "ERR NOSCRIPT.*")
+ util.ErrorRegexp(t, r.Err(), "NOSCRIPT.*")
require.Nil(t, r.Val())
})
t.Run("EVALSHA - Do we get an error on non defined SHA1?", func(t
*testing.T) {
r := rdb.EvalSha(ctx,
"ffd632c7d33e571e9f24556ebed26c3479a87130", []string{})
- util.ErrorRegexp(t, r.Err(), "ERR NOSCRIPT.*")
+ util.ErrorRegexp(t, r.Err(), "NOSCRIPT.*")
require.Nil(t, r.Val())
})
@@ -354,7 +354,7 @@ assert(bit.bor(1,2,4,8,16,32,64,128) == 255)
require.Equal(t, "myval", r.Val())
require.NoError(t, rdb.ScriptFlush(ctx).Err())
r = rdb.EvalSha(ctx,
"fd758d1589d044dd850a6f05d52f2eefd27f033f", []string{"mykey"})
- util.ErrorRegexp(t, r.Err(), "ERR NOSCRIPT.*")
+ util.ErrorRegexp(t, r.Err(), "NOSCRIPT.*")
})
t.Run("SCRIPT EXISTS - can detect already defined scripts?", func(t
*testing.T) {