diff --git a/src/config.c b/src/config.c index 5b90ebbd60..9629cd0072 100644 --- a/src/config.c +++ b/src/config.c @@ -919,7 +919,7 @@ void configSetCommand(client *c) { err: if (deny_loading_error) { /* We give the loading error precedence because it may be handled by clients differently, unlike a plain -ERR. */ - addReplyErrorObject(c, shared.loadingerr); + addReplyErrorObject(c, server.extended_redis_compat ? shared.loadingerr_compat : shared.loadingerr); } else if (invalid_arg_name) { addReplyErrorFormat(c, "Unknown option or number of arguments for CONFIG SET - '%s'", invalid_arg_name); } else if (errstr) { diff --git a/src/db.c b/src/db.c index 94074bf668..d09bc14de4 100644 --- a/src/db.c +++ b/src/db.c @@ -1361,11 +1361,11 @@ void shutdownCommand(client *c) { if (server.busy_module_yield_flags && server.busy_module_yield_reply) { addReplyErrorFormat(c, "-BUSY %s", server.busy_module_yield_reply); } else if (server.busy_module_yield_flags) { - addReplyErrorObject(c, shared.slowmoduleerr); + addReplyErrorObject(c, server.extended_redis_compat ? shared.slowmoduleerr_compat : shared.slowmoduleerr); } else if (scriptIsEval()) { - addReplyErrorObject(c, shared.slowevalerr); + addReplyErrorObject(c, server.extended_redis_compat ? shared.slowevalerr_compat : shared.slowevalerr); } else { - addReplyErrorObject(c, shared.slowscripterr); + addReplyErrorObject(c, server.extended_redis_compat ? shared.slowscripterr_compat : shared.slowscripterr); } return; } diff --git a/src/debug.c b/src/debug.c index 915e0c264d..b96386b193 100644 --- a/src/debug.c +++ b/src/debug.c @@ -723,7 +723,7 @@ void debugCommand(client *c) { if (getPositiveLongFromObjectOrReply(c, c->argv[2], &keys, NULL) != C_OK) return; if (server.loading || server.async_loading) { - addReplyErrorObject(c, shared.loadingerr); + addReplyErrorObject(c, server.extended_redis_compat ? shared.loadingerr_compat : shared.loadingerr); return; } diff --git a/src/functions.c b/src/functions.c index 0d003f7fac..5b7992dbb0 100644 --- a/src/functions.c +++ b/src/functions.c @@ -554,7 +554,7 @@ int functionsUnregisterEngine(const char *engine_name) { */ void functionStatsCommand(client *c) { if (scriptIsRunning() && scriptIsEval()) { - addReplyErrorObject(c, shared.slowevalerr); + addReplyErrorObject(c, server.extended_redis_compat ? shared.slowevalerr_compat : shared.slowevalerr); return; } diff --git a/src/script.c b/src/script.c index a8e5b18eb9..0d420b64fd 100644 --- a/src/script.c +++ b/src/script.c @@ -315,12 +315,12 @@ void scriptKill(client *c, int is_eval) { } if (is_eval && !(curr_run_ctx->flags & SCRIPT_EVAL_MODE)) { /* Kill a function with 'SCRIPT KILL' is not allow */ - addReplyErrorObject(c, shared.slowscripterr); + addReplyErrorObject(c, server.extended_redis_compat ? shared.slowscripterr_compat : shared.slowscripterr); return; } if (!is_eval && (curr_run_ctx->flags & SCRIPT_EVAL_MODE)) { /* Kill an eval with 'FUNCTION KILL' is not allow */ - addReplyErrorObject(c, shared.slowevalerr); + addReplyErrorObject(c, server.extended_redis_compat ? shared.slowevalerr_compat : shared.slowevalerr); return; } curr_run_ctx->flags |= SCRIPT_KILLED; diff --git a/src/server.c b/src/server.c index 8255b57e25..bb112b4d9e 100644 --- a/src/server.c +++ b/src/server.c @@ -1963,154 +1963,182 @@ void afterSleep(struct aeEventLoop *eventLoop, int numevents) { * called when the config changes. When the config is phased out, these * initializations can be moved back inside createSharedObjects() below. */ void createSharedObjectsWithCompat(void) { - const char *name = server.extended_redis_compat ? "Redis" : SERVER_TITLE; - if (shared.loadingerr) decrRefCount(shared.loadingerr); - shared.loadingerr = - createObject(OBJ_STRING, sdscatfmt(sdsempty(), "-LOADING %s is loading the dataset in memory\r\n", name)); - if (shared.slowevalerr) decrRefCount(shared.slowevalerr); - shared.slowevalerr = createObject( + const char *name = SERVER_TITLE; + const char *name_compat = "Redis"; + + shared.loadingerr = makeObjectShared(createObject( + OBJ_STRING, sdscatfmt(sdsempty(), "-LOADING %s is loading the dataset in memory\r\n", name))); + shared.loadingerr_compat = makeObjectShared(createObject( + OBJ_STRING, sdscatfmt(sdsempty(), "-LOADING %s is loading the dataset in memory\r\n", name_compat))); + + shared.slowevalerr = makeObjectShared(createObject( + OBJ_STRING, + sdscatfmt(sdsempty(), + "-BUSY %s is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.\r\n", name))); + shared.slowevalerr_compat = makeObjectShared(createObject( OBJ_STRING, sdscatfmt(sdsempty(), - "-BUSY %s is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.\r\n", name)); - if (shared.slowscripterr) decrRefCount(shared.slowscripterr); - shared.slowscripterr = createObject( + "-BUSY %s is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.\r\n", + name_compat))); + + shared.slowscripterr = makeObjectShared(createObject( + OBJ_STRING, + sdscatfmt(sdsempty(), + "-BUSY %s is busy running a script. You can only call FUNCTION KILL or SHUTDOWN NOSAVE.\r\n", name))); + shared.slowscripterr_compat = makeObjectShared(createObject( OBJ_STRING, sdscatfmt(sdsempty(), - "-BUSY %s is busy running a script. You can only call FUNCTION KILL or SHUTDOWN NOSAVE.\r\n", name)); - if (shared.slowmoduleerr) decrRefCount(shared.slowmoduleerr); - shared.slowmoduleerr = - createObject(OBJ_STRING, sdscatfmt(sdsempty(), "-BUSY %s is busy running a module command.\r\n", name)); - if (shared.bgsaveerr) decrRefCount(shared.bgsaveerr); - shared.bgsaveerr = + "-BUSY %s is busy running a script. You can only call FUNCTION KILL or SHUTDOWN NOSAVE.\r\n", + name_compat))); + + shared.slowmoduleerr = makeObjectShared( + createObject(OBJ_STRING, sdscatfmt(sdsempty(), "-BUSY %s is busy running a module command.\r\n", name))); + shared.slowmoduleerr_compat = makeObjectShared( + createObject(OBJ_STRING, sdscatfmt(sdsempty(), "-BUSY %s is busy running a module command.\r\n", name_compat))); + + shared.bgsaveerr = makeObjectShared( + createObject(OBJ_STRING, sdscatfmt(sdsempty(), + "-MISCONF %s is configured to save RDB snapshots, but it's currently" + " unable to persist to disk. Commands that may modify the data set are" + " disabled, because this instance is configured to report errors during" + " writes if RDB snapshotting fails (stop-writes-on-bgsave-error option)." + " Please check the %s logs for details about the RDB error.\r\n", + name, name))); + shared.bgsaveerr_compat = makeObjectShared( createObject(OBJ_STRING, sdscatfmt(sdsempty(), "-MISCONF %s is configured to save RDB snapshots, but it's currently" " unable to persist to disk. Commands that may modify the data set are" " disabled, because this instance is configured to report errors during" " writes if RDB snapshotting fails (stop-writes-on-bgsave-error option)." " Please check the %s logs for details about the RDB error.\r\n", - name, name)); + name, name_compat))); } void createSharedObjects(void) { int j; /* Shared command responses */ - shared.ok = createObject(OBJ_STRING, sdsnew("+OK\r\n")); - shared.emptybulk = createObject(OBJ_STRING, sdsnew("$0\r\n\r\n")); - shared.czero = createObject(OBJ_STRING, sdsnew(":0\r\n")); - shared.cone = createObject(OBJ_STRING, sdsnew(":1\r\n")); - shared.emptyarray = createObject(OBJ_STRING, sdsnew("*0\r\n")); - shared.pong = createObject(OBJ_STRING, sdsnew("+PONG\r\n")); - shared.queued = createObject(OBJ_STRING, sdsnew("+QUEUED\r\n")); - shared.emptyscan = createObject(OBJ_STRING, sdsnew("*2\r\n$1\r\n0\r\n*0\r\n")); - shared.space = createObject(OBJ_STRING, sdsnew(" ")); - shared.plus = createObject(OBJ_STRING, sdsnew("+")); + shared.ok = makeObjectShared(createObject(OBJ_STRING, sdsnew("+OK\r\n"))); + shared.emptybulk = makeObjectShared(createObject(OBJ_STRING, sdsnew("$0\r\n\r\n"))); + shared.czero = makeObjectShared(createObject(OBJ_STRING, sdsnew(":0\r\n"))); + shared.cone = makeObjectShared(createObject(OBJ_STRING, sdsnew(":1\r\n"))); + shared.emptyarray = makeObjectShared(createObject(OBJ_STRING, sdsnew("*0\r\n"))); + shared.pong = makeObjectShared(createObject(OBJ_STRING, sdsnew("+PONG\r\n"))); + shared.queued = makeObjectShared(createObject(OBJ_STRING, sdsnew("+QUEUED\r\n"))); + shared.emptyscan = makeObjectShared(createObject(OBJ_STRING, sdsnew("*2\r\n$1\r\n0\r\n*0\r\n"))); + shared.space = makeObjectShared(createObject(OBJ_STRING, sdsnew(" "))); + shared.plus = makeObjectShared(createObject(OBJ_STRING, sdsnew("+"))); /* Shared command error responses */ - shared.wrongtypeerr = - createObject(OBJ_STRING, sdsnew("-WRONGTYPE Operation against a key holding the wrong kind of value\r\n")); - shared.err = createObject(OBJ_STRING, sdsnew("-ERR\r\n")); - shared.nokeyerr = createObject(OBJ_STRING, sdsnew("-ERR no such key\r\n")); - shared.syntaxerr = createObject(OBJ_STRING, sdsnew("-ERR syntax error\r\n")); - shared.sameobjecterr = createObject(OBJ_STRING, sdsnew("-ERR source and destination objects are the same\r\n")); - shared.outofrangeerr = createObject(OBJ_STRING, sdsnew("-ERR index out of range\r\n")); - shared.noscripterr = createObject(OBJ_STRING, sdsnew("-NOSCRIPT No matching script.\r\n")); + shared.wrongtypeerr = makeObjectShared(createObject( + OBJ_STRING, sdsnew("-WRONGTYPE Operation against a key holding the wrong kind of value\r\n"))); + shared.err = makeObjectShared(createObject(OBJ_STRING, sdsnew("-ERR\r\n"))); + shared.nokeyerr = makeObjectShared(createObject(OBJ_STRING, sdsnew("-ERR no such key\r\n"))); + shared.syntaxerr = makeObjectShared(createObject(OBJ_STRING, sdsnew("-ERR syntax error\r\n"))); + shared.sameobjecterr = makeObjectShared(createObject( + OBJ_STRING, sdsnew("-ERR source and destination objects are the same\r\n"))); + shared.outofrangeerr = makeObjectShared(createObject(OBJ_STRING, sdsnew("-ERR index out of range\r\n"))); + shared.noscripterr = makeObjectShared(createObject(OBJ_STRING, sdsnew("-NOSCRIPT No matching script.\r\n"))); createSharedObjectsWithCompat(); - shared.primarydownerr = createObject( - OBJ_STRING, sdsnew("-MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'.\r\n")); - shared.roreplicaerr = - createObject(OBJ_STRING, sdsnew("-READONLY You can't write against a read only replica.\r\n")); - shared.noautherr = createObject(OBJ_STRING, sdsnew("-NOAUTH Authentication required.\r\n")); - shared.oomerr = createObject(OBJ_STRING, sdsnew("-OOM command not allowed when used memory > 'maxmemory'.\r\n")); - shared.execaborterr = - createObject(OBJ_STRING, sdsnew("-EXECABORT Transaction discarded because of previous errors.\r\n")); - shared.noreplicaserr = createObject(OBJ_STRING, sdsnew("-NOREPLICAS Not enough good replicas to write.\r\n")); - shared.busykeyerr = createObject(OBJ_STRING, sdsnew("-BUSYKEY Target key name already exists.\r\n")); + shared.primarydownerr = makeObjectShared(createObject( + OBJ_STRING, sdsnew("-MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'.\r\n"))); + shared.roreplicaerr = makeObjectShared((createObject( + OBJ_STRING, sdsnew("-READONLY You can't write against a read only replica.\r\n")))); + shared.noautherr = makeObjectShared(createObject( + OBJ_STRING, sdsnew("-NOAUTH Authentication required.\r\n"))); + shared.oomerr = makeObjectShared(createObject( + OBJ_STRING, sdsnew("-OOM command not allowed when used memory > 'maxmemory'.\r\n"))); + shared.execaborterr = makeObjectShared(createObject( + OBJ_STRING, sdsnew("-EXECABORT Transaction discarded because of previous errors.\r\n"))); + shared.noreplicaserr = makeObjectShared(createObject( + OBJ_STRING, sdsnew("-NOREPLICAS Not enough good replicas to write.\r\n"))); + shared.busykeyerr = makeObjectShared(createObject( + OBJ_STRING, sdsnew("-BUSYKEY Target key name already exists.\r\n"))); /* The shared NULL depends on the protocol version. */ shared.null[0] = NULL; shared.null[1] = NULL; - shared.null[2] = createObject(OBJ_STRING, sdsnew("$-1\r\n")); - shared.null[3] = createObject(OBJ_STRING, sdsnew("_\r\n")); + shared.null[2] = makeObjectShared(createObject(OBJ_STRING, sdsnew("$-1\r\n"))); + shared.null[3] = makeObjectShared(createObject(OBJ_STRING, sdsnew("_\r\n"))); shared.nullarray[0] = NULL; shared.nullarray[1] = NULL; - shared.nullarray[2] = createObject(OBJ_STRING, sdsnew("*-1\r\n")); - shared.nullarray[3] = createObject(OBJ_STRING, sdsnew("_\r\n")); + shared.nullarray[2] = makeObjectShared(createObject(OBJ_STRING, sdsnew("*-1\r\n"))); + shared.nullarray[3] = makeObjectShared(createObject(OBJ_STRING, sdsnew("_\r\n"))); shared.emptymap[0] = NULL; shared.emptymap[1] = NULL; - shared.emptymap[2] = createObject(OBJ_STRING, sdsnew("*0\r\n")); - shared.emptymap[3] = createObject(OBJ_STRING, sdsnew("%0\r\n")); + shared.emptymap[2] = makeObjectShared(createObject(OBJ_STRING, sdsnew("*0\r\n"))); + shared.emptymap[3] = makeObjectShared(createObject(OBJ_STRING, sdsnew("%0\r\n"))); shared.emptyset[0] = NULL; shared.emptyset[1] = NULL; - shared.emptyset[2] = createObject(OBJ_STRING, sdsnew("*0\r\n")); - shared.emptyset[3] = createObject(OBJ_STRING, sdsnew("~0\r\n")); + shared.emptyset[2] = makeObjectShared(createObject(OBJ_STRING, sdsnew("*0\r\n"))); + shared.emptyset[3] = makeObjectShared(createObject(OBJ_STRING, sdsnew("~0\r\n"))); for (j = 0; j < PROTO_SHARED_SELECT_CMDS; j++) { char dictid_str[64]; int dictid_len; dictid_len = ll2string(dictid_str, sizeof(dictid_str), j); - shared.select[j] = createObject( - OBJ_STRING, sdscatprintf(sdsempty(), "*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n", dictid_len, dictid_str)); - } - shared.messagebulk = createStringObject("$7\r\nmessage\r\n", 13); - shared.pmessagebulk = createStringObject("$8\r\npmessage\r\n", 14); - shared.subscribebulk = createStringObject("$9\r\nsubscribe\r\n", 15); - shared.unsubscribebulk = createStringObject("$11\r\nunsubscribe\r\n", 18); - shared.ssubscribebulk = createStringObject("$10\r\nssubscribe\r\n", 17); - shared.sunsubscribebulk = createStringObject("$12\r\nsunsubscribe\r\n", 19); - shared.smessagebulk = createStringObject("$8\r\nsmessage\r\n", 14); - shared.psubscribebulk = createStringObject("$10\r\npsubscribe\r\n", 17); - shared.punsubscribebulk = createStringObject("$12\r\npunsubscribe\r\n", 19); + shared.select[j] = makeObjectShared(createObject( + OBJ_STRING, sdscatprintf(sdsempty(), "*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n", dictid_len, dictid_str))); + } + shared.messagebulk = makeObjectShared(createStringObject("$7\r\nmessage\r\n", 13)); + shared.pmessagebulk = makeObjectShared(createStringObject("$8\r\npmessage\r\n", 14)); + shared.subscribebulk = makeObjectShared(createStringObject("$9\r\nsubscribe\r\n", 15)); + shared.unsubscribebulk = makeObjectShared(createStringObject("$11\r\nunsubscribe\r\n", 18)); + shared.ssubscribebulk = makeObjectShared(createStringObject("$10\r\nssubscribe\r\n", 17)); + shared.sunsubscribebulk = makeObjectShared(createStringObject("$12\r\nsunsubscribe\r\n", 19)); + shared.smessagebulk = makeObjectShared(createStringObject("$8\r\nsmessage\r\n", 14)); + shared.psubscribebulk = makeObjectShared(createStringObject("$10\r\npsubscribe\r\n", 17)); + shared.punsubscribebulk = makeObjectShared(createStringObject("$12\r\npunsubscribe\r\n", 19)); /* Shared command names */ - shared.del = createStringObject("DEL", 3); - shared.unlink = createStringObject("UNLINK", 6); - shared.rpop = createStringObject("RPOP", 4); - shared.lpop = createStringObject("LPOP", 4); - shared.lpush = createStringObject("LPUSH", 5); - shared.rpoplpush = createStringObject("RPOPLPUSH", 9); - shared.lmove = createStringObject("LMOVE", 5); - shared.blmove = createStringObject("BLMOVE", 6); - shared.zpopmin = createStringObject("ZPOPMIN", 7); - shared.zpopmax = createStringObject("ZPOPMAX", 7); - shared.multi = createStringObject("MULTI", 5); - shared.exec = createStringObject("EXEC", 4); - shared.hset = createStringObject("HSET", 4); - shared.srem = createStringObject("SREM", 4); - shared.xgroup = createStringObject("XGROUP", 6); - shared.xclaim = createStringObject("XCLAIM", 6); - shared.script = createStringObject("SCRIPT", 6); - shared.replconf = createStringObject("REPLCONF", 8); - shared.pexpireat = createStringObject("PEXPIREAT", 9); - shared.pexpire = createStringObject("PEXPIRE", 7); - shared.persist = createStringObject("PERSIST", 7); - shared.set = createStringObject("SET", 3); - shared.eval = createStringObject("EVAL", 4); + shared.del = makeObjectShared(createStringObject("DEL", 3)); + shared.unlink = makeObjectShared(createStringObject("UNLINK", 6)); + shared.rpop = makeObjectShared(createStringObject("RPOP", 4)); + shared.lpop = makeObjectShared(createStringObject("LPOP", 4)); + shared.lpush = makeObjectShared(createStringObject("LPUSH", 5)); + shared.rpoplpush = makeObjectShared(createStringObject("RPOPLPUSH", 9)); + shared.lmove = makeObjectShared(createStringObject("LMOVE", 5)); + shared.blmove = makeObjectShared(createStringObject("BLMOVE", 6)); + shared.zpopmin = makeObjectShared(createStringObject("ZPOPMIN", 7)); + shared.zpopmax = makeObjectShared(createStringObject("ZPOPMAX", 7)); + shared.multi = makeObjectShared(createStringObject("MULTI", 5)); + shared.exec = makeObjectShared(createStringObject("EXEC", 4)); + shared.hset = makeObjectShared(createStringObject("HSET", 4)); + shared.srem = makeObjectShared(createStringObject("SREM", 4)); + shared.xgroup = makeObjectShared(createStringObject("XGROUP", 6)); + shared.xclaim = makeObjectShared(createStringObject("XCLAIM", 6)); + shared.script = makeObjectShared(createStringObject("SCRIPT", 6)); + shared.replconf = makeObjectShared(createStringObject("REPLCONF", 8)); + shared.pexpireat = makeObjectShared(createStringObject("PEXPIREAT", 9)); + shared.pexpire = makeObjectShared(createStringObject("PEXPIRE", 7)); + shared.persist = makeObjectShared(createStringObject("PERSIST", 7)); + shared.set = makeObjectShared(createStringObject("SET", 3)); + shared.eval = makeObjectShared(createStringObject("EVAL", 4)); /* Shared command argument */ - shared.left = createStringObject("left", 4); - shared.right = createStringObject("right", 5); - shared.pxat = createStringObject("PXAT", 4); - shared.time = createStringObject("TIME", 4); - shared.retrycount = createStringObject("RETRYCOUNT", 10); - shared.force = createStringObject("FORCE", 5); - shared.justid = createStringObject("JUSTID", 6); - shared.entriesread = createStringObject("ENTRIESREAD", 11); - shared.lastid = createStringObject("LASTID", 6); - shared.default_username = createStringObject("default", 7); - shared.ping = createStringObject("ping", 4); - shared.setid = createStringObject("SETID", 5); - shared.keepttl = createStringObject("KEEPTTL", 7); - shared.absttl = createStringObject("ABSTTL", 6); - shared.load = createStringObject("LOAD", 4); - shared.createconsumer = createStringObject("CREATECONSUMER", 14); - shared.getack = createStringObject("GETACK", 6); - shared.special_asterisk = createStringObject("*", 1); - shared.special_equals = createStringObject("=", 1); + shared.left = makeObjectShared(createStringObject("left", 4)); + shared.right = makeObjectShared(createStringObject("right", 5)); + shared.pxat = makeObjectShared(createStringObject("PXAT", 4)); + shared.time = makeObjectShared(createStringObject("TIME", 4)); + shared.retrycount = makeObjectShared(createStringObject("RETRYCOUNT", 10)); + shared.force = makeObjectShared(createStringObject("FORCE", 5)); + shared.justid = makeObjectShared(createStringObject("JUSTID", 6)); + shared.entriesread = makeObjectShared(createStringObject("ENTRIESREAD", 11)); + shared.lastid = makeObjectShared(createStringObject("LASTID", 6)); + shared.default_username = makeObjectShared(createStringObject("default", 7)); + shared.ping = makeObjectShared(createStringObject("ping", 4)); + shared.setid = makeObjectShared(createStringObject("SETID", 5)); + shared.keepttl = makeObjectShared(createStringObject("KEEPTTL", 7)); + shared.absttl = makeObjectShared(createStringObject("ABSTTL", 6)); + shared.load = makeObjectShared(createStringObject("LOAD", 4)); + shared.createconsumer = makeObjectShared(createStringObject("CREATECONSUMER", 14)); + shared.getack = makeObjectShared(createStringObject("GETACK", 6)); + shared.special_asterisk = makeObjectShared(createStringObject("*", 1)); + shared.special_equals = makeObjectShared(createStringObject("=", 1)); shared.redacted = makeObjectShared(createStringObject("(redacted)", 10)); for (j = 0; j < OBJ_SHARED_INTEGERS; j++) { @@ -2119,10 +2147,10 @@ void createSharedObjects(void) { shared.integers[j]->encoding = OBJ_ENCODING_INT; } for (j = 0; j < OBJ_SHARED_BULKHDR_LEN; j++) { - shared.mbulkhdr[j] = createObject(OBJ_STRING, sdscatprintf(sdsempty(), "*%d\r\n", j)); - shared.bulkhdr[j] = createObject(OBJ_STRING, sdscatprintf(sdsempty(), "$%d\r\n", j)); - shared.maphdr[j] = createObject(OBJ_STRING, sdscatprintf(sdsempty(), "%%%d\r\n", j)); - shared.sethdr[j] = createObject(OBJ_STRING, sdscatprintf(sdsempty(), "~%d\r\n", j)); + shared.mbulkhdr[j] = makeObjectShared(createObject(OBJ_STRING, sdscatprintf(sdsempty(), "*%d\r\n", j))); + shared.bulkhdr[j] = makeObjectShared(createObject(OBJ_STRING, sdscatprintf(sdsempty(), "$%d\r\n", j))); + shared.maphdr[j] = makeObjectShared(createObject(OBJ_STRING, sdscatprintf(sdsempty(), "%%%d\r\n", j))); + shared.sethdr[j] = makeObjectShared(createObject(OBJ_STRING, sdscatprintf(sdsempty(), "~%d\r\n", j))); } /* The following two shared objects, minstring and maxstring, are not * actually used for their value but as a special object meaning @@ -4257,13 +4285,13 @@ int processCommand(client *c) { /* Loading DB? Return an error if the command has not the * CMD_LOADING flag. */ if (server.loading && !server.async_loading && is_denyloading_command) { - rejectCommand(c, shared.loadingerr); + rejectCommand(c, server.extended_redis_compat ? shared.loadingerr_compat : shared.loadingerr); return C_OK; } /* During async-loading, block certain commands. */ if (server.async_loading && is_deny_async_loading_command) { - rejectCommand(c, shared.loadingerr); + rejectCommand(c, server.extended_redis_compat ? shared.loadingerr_compat : shared.loadingerr); return C_OK; } @@ -4278,11 +4306,11 @@ int processCommand(client *c) { if (server.busy_module_yield_flags && server.busy_module_yield_reply) { rejectCommandFormat(c, "-BUSY %s", server.busy_module_yield_reply); } else if (server.busy_module_yield_flags) { - rejectCommand(c, shared.slowmoduleerr); + rejectCommand(c, server.extended_redis_compat ? shared.slowmoduleerr_compat : shared.slowmoduleerr); } else if (scriptIsEval()) { - rejectCommand(c, shared.slowevalerr); + rejectCommand(c, server.extended_redis_compat ? shared.slowevalerr_compat : shared.slowevalerr); } else { - rejectCommand(c, shared.slowscripterr); + rejectCommand(c, server.extended_redis_compat ? shared.slowscripterr_compat : shared.slowscripterr); } return C_OK; } @@ -4634,7 +4662,7 @@ int writeCommandsDeniedByDiskError(void) { sds writeCommandsGetDiskErrorMessage(int error_code) { sds ret = NULL; if (error_code == DISK_ERROR_TYPE_RDB) { - ret = sdsdup(shared.bgsaveerr->ptr); + ret = sdsdup(server.extended_redis_compat ? shared.bgsaveerr_compat->ptr : shared.bgsaveerr->ptr); } else { ret = sdscatfmt(sdsempty(), "-MISCONF Errors writing to the AOF file: %s\r\n", strerror(server.aof_last_write_errno)); diff --git a/src/server.h b/src/server.h index d186d16c73..49b1cd8c1a 100644 --- a/src/server.h +++ b/src/server.h @@ -1286,6 +1286,7 @@ struct sharedObjectsStruct { robj *ok, *err, *emptybulk, *czero, *cone, *pong, *space, *queued, *null[4], *nullarray[4], *emptymap[4], *emptyset[4], *emptyarray, *wrongtypeerr, *nokeyerr, *syntaxerr, *sameobjecterr, *outofrangeerr, *noscripterr, *loadingerr, *slowevalerr, *slowscripterr, *slowmoduleerr, *bgsaveerr, *primarydownerr, *roreplicaerr, + *loadingerr_compat, *slowevalerr_compat, *slowscripterr_compat, *slowmoduleerr_compat, *bgsaveerr_compat, *execaborterr, *noautherr, *noreplicaserr, *busykeyerr, *oomerr, *plus, *messagebulk, *pmessagebulk, *subscribebulk, *unsubscribebulk, *psubscribebulk, *punsubscribebulk, *del, *unlink, *rpop, *lpop, *lpush, *rpoplpush, *lmove, *blmove, *zpopmin, *zpopmax, *emptyscan, *multi, *exec, *left, *right, *hset, *srem,