diff --git a/src/cli_common.c b/src/cli_common.c index 368906bcef..c55933418d 100644 --- a/src/cli_common.c +++ b/src/cli_common.c @@ -413,7 +413,7 @@ sds escapeJsonString(sds s, const char *p, size_t len) { } sds cliVersion(void) { - sds version = sdscatprintf(sdsempty(), "%s", REDIS_VERSION); + sds version = sdscatprintf(sdsempty(), "%s", SERVER_VERSION); /* Add git commit and working tree status when available. */ if (strtoll(serverGitSHA1(),NULL,16)) { diff --git a/src/config.c b/src/config.c index 8b193891cf..c009589e15 100644 --- a/src/config.c +++ b/src/config.c @@ -634,8 +634,7 @@ void loadServerConfigFromString(char *config) { loaderr: if (argv) sdsfreesplitres(argv,argc); - fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Redis %s) ***\n", - REDIS_VERSION); + fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", SERVER_VERSION); if (i < totlines) { fprintf(stderr, "Reading the configuration file, at line %d\n", linenum); fprintf(stderr, ">>> '%s'\n", lines[i]); diff --git a/src/debug.c b/src/debug.c index 676a1c32dd..c64fba2b5b 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2252,7 +2252,7 @@ static void sigsegvHandler(int sig, siginfo_t *info, void *secret) { bugReportStart(); serverLog(LL_WARNING, - "Redis %s crashed by signal: %d, si_code: %d", REDIS_VERSION, sig, info->si_code); + SERVER_NAME " %s crashed by signal: %d, si_code: %d", SERVER_VERSION, sig, info->si_code); if (sig == SIGSEGV || sig == SIGBUS) { serverLog(LL_WARNING, "Accessing address: %p", (void*)info->si_addr); diff --git a/src/lolwut.c b/src/lolwut.c index c014840e9a..08c1f58992 100644 --- a/src/lolwut.c +++ b/src/lolwut.c @@ -44,7 +44,7 @@ void lolwut6Command(client *c); * This is what unstable versions of Redis will display. */ void lolwutUnstableCommand(client *c) { sds rendered = sdsnew("Redis ver. "); - rendered = sdscat(rendered,REDIS_VERSION); + rendered = sdscat(rendered,SERVER_VERSION); rendered = sdscatlen(rendered,"\n",1); addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); sdsfree(rendered); @@ -52,7 +52,7 @@ void lolwutUnstableCommand(client *c) { /* LOLWUT [VERSION ] [... version specific arguments ...] */ void lolwutCommand(client *c) { - char *v = REDIS_VERSION; + char *v = SERVER_VERSION; char verstr[64]; if (c->argc >= 3 && !strcasecmp(c->argv[1]->ptr,"version")) { diff --git a/src/lolwut5.c b/src/lolwut5.c index 1240168d0d..dcc7e7ad90 100644 --- a/src/lolwut5.c +++ b/src/lolwut5.c @@ -169,7 +169,7 @@ void lolwut5Command(client *c) { sds rendered = renderCanvas(canvas); rendered = sdscat(rendered, "\nGeorg Nees - schotter, plotter on paper, 1968. Redis ver. "); - rendered = sdscat(rendered,REDIS_VERSION); + rendered = sdscat(rendered,SERVER_VERSION); rendered = sdscatlen(rendered,"\n",1); addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); sdsfree(rendered); diff --git a/src/lolwut6.c b/src/lolwut6.c index 1ba111c2d0..38733505a9 100644 --- a/src/lolwut6.c +++ b/src/lolwut6.c @@ -193,7 +193,7 @@ void lolwut6Command(client *c) { rendered = sdscat(rendered, "\nDedicated to the 8 bit game developers of past and present.\n" "Original 8 bit image from Plaguemon by hikikomori. Redis ver. "); - rendered = sdscat(rendered,REDIS_VERSION); + rendered = sdscat(rendered,SERVER_VERSION); rendered = sdscatlen(rendered,"\n",1); addReplyVerbatim(c,rendered,sdslen(rendered),"txt"); sdsfree(rendered); diff --git a/src/mkreleasehdr.sh b/src/mkreleasehdr.sh index 04bc45a169..b1371fcc09 100755 --- a/src/mkreleasehdr.sh +++ b/src/mkreleasehdr.sh @@ -12,5 +12,5 @@ echo "#define REDIS_GIT_SHA1 \"$GIT_SHA1\"" > release.h echo "#define REDIS_GIT_DIRTY \"$GIT_DIRTY\"" >> release.h echo "#define REDIS_BUILD_ID \"$BUILD_ID\"" >> release.h echo "#include \"version.h\"" >> release.h -echo "#define REDIS_BUILD_ID_RAW REDIS_VERSION REDIS_BUILD_ID REDIS_GIT_DIRTY REDIS_GIT_SHA1" >> release.h +echo "#define REDIS_BUILD_ID_RAW SERVER_NAME SERVER_VERSION REDIS_BUILD_ID REDIS_GIT_DIRTY REDIS_GIT_SHA1" >> release.h touch release.c # Force recompile of release.c diff --git a/src/module.c b/src/module.c index 44c983f2e3..eecb45fb48 100644 --- a/src/module.c +++ b/src/module.c @@ -13295,7 +13295,7 @@ int RM_GetKeyspaceNotificationFlagsAll(void) { * Example for 6.0.7 the return value will be 0x00060007. */ int RM_GetServerVersion(void) { - return REDIS_VERSION_NUM; + return SERVER_VERSION_NUM; } /** diff --git a/src/networking.c b/src/networking.c index 5bb7706e7d..0adbfeb452 100644 --- a/src/networking.c +++ b/src/networking.c @@ -3650,7 +3650,7 @@ void helloCommand(client *c) { addReplyBulkCString(c,"redis"); addReplyBulkCString(c,"version"); - addReplyBulkCString(c,REDIS_VERSION); + addReplyBulkCString(c,SERVER_VERSION); addReplyBulkCString(c,"proto"); addReplyLongLong(c,c->resp); diff --git a/src/rdb.c b/src/rdb.c index 1039340493..052d780d02 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -1195,6 +1195,8 @@ int rdbSaveInfoAuxFields(rio *rdb, int rdbflags, rdbSaveInfo *rsi) { int aof_base = (rdbflags & RDBFLAGS_AOF_PREAMBLE) != 0; /* Add a few fields about the state when the RDB was created. */ + if (rdbSaveAuxFieldStrStr(rdb,"server-ver",SERVER_VERSION) == -1) return -1; + /* Print Redis version for backwards compatibility with redis. */ if (rdbSaveAuxFieldStrStr(rdb,"redis-ver",REDIS_VERSION) == -1) return -1; if (rdbSaveAuxFieldStrInt(rdb,"redis-bits",redis_bits) == -1) return -1; if (rdbSaveAuxFieldStrInt(rdb,"ctime",time(NULL)) == -1) return -1; @@ -3162,7 +3164,10 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin } else if (!strcasecmp(auxkey->ptr,"lua")) { /* Won't load the script back in memory anymore. */ } else if (!strcasecmp(auxkey->ptr,"redis-ver")) { - serverLog(LL_NOTICE,"Loading RDB produced by version %s", + serverLog(LL_NOTICE,"Loading RDB produced by Redis version %s", + (char*)auxval->ptr); + } else if (!strcasecmp(auxkey->ptr,"server-ver")) { + serverLog(LL_NOTICE,"Loading RDB produced by server version %s", (char*)auxval->ptr); } else if (!strcasecmp(auxkey->ptr,"ctime")) { time_t age = time(NULL)-strtol(auxval->ptr,NULL,10); diff --git a/src/script_lua.c b/src/script_lua.c index 1126422582..fbbd6e82fa 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -1383,6 +1383,7 @@ void luaSetTableProtectionRecursively(lua_State *lua) { } void luaRegisterVersion(lua_State* lua) { + /* For legacy compatibility reasons include Redis versions. */ lua_pushstring(lua,"REDIS_VERSION_NUM"); lua_pushnumber(lua,REDIS_VERSION_NUM); lua_settable(lua,-3); @@ -1390,6 +1391,19 @@ void luaRegisterVersion(lua_State* lua) { lua_pushstring(lua,"REDIS_VERSION"); lua_pushstring(lua,REDIS_VERSION); lua_settable(lua,-3); + + /* Now push the Valkey version information. */ + lua_pushstring(lua,"SERVER_VERSION_NUM"); + lua_pushnumber(lua,SERVER_VERSION_NUM); + lua_settable(lua,-3); + + lua_pushstring(lua,"SERVER_VERSION"); + lua_pushstring(lua,SERVER_VERSION); + lua_settable(lua,-3); + + lua_pushstring(lua,"SERVER_NAME"); + lua_pushstring(lua,SERVER_NAME); + lua_settable(lua,-3); } void luaRegisterLogFunction(lua_State* lua) { diff --git a/src/sentinel.c b/src/sentinel.c index cce5cc3b99..af27ee9c3b 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1846,8 +1846,7 @@ void loadSentinelConfigFromQueue(void) { return; loaderr: - fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Redis %s) ***\n", - REDIS_VERSION); + fprintf(stderr, "\n*** FATAL CONFIG FILE ERROR (Version %s) ***\n", SERVER_VERSION); fprintf(stderr, "Reading the configuration file, at line %d\n", linenum); fprintf(stderr, ">>> '%s'\n", line); fprintf(stderr, "%s\n", err); diff --git a/src/server.c b/src/server.c index d6d4d22b81..5e35e93631 100644 --- a/src/server.c +++ b/src/server.c @@ -5585,6 +5585,8 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) { info = sdscatfmt(info, "# Server\r\n" FMTARGS( "redis_version:%s\r\n", REDIS_VERSION, + "server_name:%s\r\n", SERVER_NAME, + "server_version:%s\r\n", SERVER_VERSION, "redis_git_sha1:%s\r\n", serverGitSHA1(), "redis_git_dirty:%i\r\n", strtol(serverGitDirty(),NULL,10) > 0, "redis_build_id:%s\r\n", serverBuildIdString(), @@ -6265,7 +6267,7 @@ void daemonize(void) { sds getVersion(void) { sds version = sdscatprintf(sdsempty(), "v=%s sha=%s:%d malloc=%s bits=%d build=%llx", - REDIS_VERSION, + SERVER_VERSION, serverGitSHA1(), atoi(serverGitDirty()) > 0, ZMALLOC_LIB, @@ -6319,7 +6321,7 @@ void redisAsciiArt(void) { ); } else { snprintf(buf,1024*16,ascii_logo, - REDIS_VERSION, + SERVER_VERSION, serverGitSHA1(), strtol(serverGitDirty(),NULL,10) > 0, (sizeof(long) == 8) ? "64" : "32", @@ -7153,9 +7155,8 @@ int main(int argc, char **argv) { if (background) daemonize(); serverLog(LL_NOTICE, "oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo"); - serverLog(LL_NOTICE, - "Redis version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started", - REDIS_VERSION, + serverLog(LL_NOTICE, SERVER_NAME " version=%s, bits=%d, commit=%s, modified=%d, pid=%d, just started", + SERVER_VERSION, (sizeof(long) == 8) ? 64 : 32, serverGitSHA1(), strtol(serverGitDirty(),NULL,10) > 0, diff --git a/src/version.h b/src/version.h index 89aef53fcb..af46071dac 100644 --- a/src/version.h +++ b/src/version.h @@ -1,2 +1,8 @@ -#define REDIS_VERSION "255.255.255" -#define REDIS_VERSION_NUM 0x00ffffff +#define SERVER_NAME "valkey" +#define SERVER_VERSION "255.255.255" +#define SERVER_VERSION_NUM 0x00ffffff + +/* Redis compatibility version, should never + * exceed 7.2.x. */ +#define REDIS_VERSION "7.2.4" +#define REDIS_VERSION_NUM 0x00070204 diff --git a/tests/unit/moduleapi/misc.tcl b/tests/unit/moduleapi/misc.tcl index 41f9dd3fa1..ffcf9bd615 100644 --- a/tests/unit/moduleapi/misc.tcl +++ b/tests/unit/moduleapi/misc.tcl @@ -21,8 +21,7 @@ start_server {overrides {save {900 1}} tags {"modules"}} { } test {test redis version} { - set version [s redis_version] - assert_equal $version [r test.redisversion] + assert_equal [s server_version] [r test.redisversion] } test {test long double conversions} {