From: antirez Date: Sat, 31 Mar 2012 15:08:40 +0000 (+0200) Subject: Write RDB magic using a REDIS_RDB_VERSION define that is defined inside rdb.h X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/11dae1711fa799e23eacc4f142c09b425c75a8b8?hp=f08aa2bf48883fa3c00266229f17efe4af201078 Write RDB magic using a REDIS_RDB_VERSION define that is defined inside rdb.h --- diff --git a/src/rdb.c b/src/rdb.c index 1e23fa70..481efe9d 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -602,6 +602,7 @@ int rdbSave(char *filename) { dictIterator *di = NULL; dictEntry *de; char tmpfile[256]; + char magic[10]; int j; long long now = mstime(); FILE *fp; @@ -616,7 +617,8 @@ int rdbSave(char *filename) { } rioInitWithFile(&rdb,fp); - if (rdbWriteRaw(&rdb,"REDIS0004",9) == -1) goto werr; + snprintf(magic,sizeof(magic),"REDIS%04d",REDIS_RDB_VERSION); + if (rdbWriteRaw(&rdb,magic,9) == -1) goto werr; for (j = 0; j < server.dbnum; j++) { redisDb *db = server.db+j; diff --git a/src/rdb.h b/src/rdb.h index 45beaa93..60157ad8 100644 --- a/src/rdb.h +++ b/src/rdb.h @@ -7,6 +7,10 @@ /* TBD: include only necessary headers. */ #include "redis.h" +/* The current RDB version. When the format changes in a way that is no longer + * backward compatible this number gets incremented. */ +#define REDIS_RDB_VERSION 4 + /* Defines related to the dump file format. To store 32 bits lengths for short * keys requires a lot of space, so we check the most significant 2 bits of * the first byte to interpreter the length: