diff options
author | Salvatore Sanfilippo <antirez@gmail.com> | 2014-12-11 15:54:39 +0100 |
---|---|---|
committer | Salvatore Sanfilippo <antirez@gmail.com> | 2014-12-11 15:54:39 +0100 |
commit | c50693d40fa4f950a21f48513edefd40714ff5e4 (patch) | |
tree | 778a6fb2b6bf1e57ea5697092c85f4d0e82706b4 /src/sort.c | |
parent | 81772ce0e38c386579567c7ccd21cc473b13ea42 (diff) | |
parent | 6c0abc4a0ee1450a7fc13076f5d04a6549286cf3 (diff) | |
download | redis-c50693d40fa4f950a21f48513edefd40714ff5e4.tar.gz |
Merge pull request #2094 from mattsta/nosort
Fix zero-ordering SORT when called against lists
Diffstat (limited to 'src/sort.c')
-rw-r--r-- | src/sort.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/sort.c b/src/sort.c index fedf0cf3a..d3521e663 100644 --- a/src/sort.c +++ b/src/sort.c @@ -285,16 +285,13 @@ void sortCommand(redisClient *c) { return; } - /* For the STORE option, or when SORT is called from a Lua script, - * we want to force a specific ordering even when no explicit ordering - * was asked (SORT BY nosort). This guarantees that replication / AOF - * is deterministic. + /* When sorting a set with no sort specified, we must sort the output + * so the result is consistent across scripting and replication. * - * However in the case 'dontsort' is true, but the type to sort is a - * sorted set, we don't need to do anything as ordering is guaranteed - * in this special case. */ - if ((storekey || c->flags & REDIS_LUA_CLIENT) && - (dontsort && sortval->type != REDIS_ZSET)) + * The other types (list, sorted set) will retain their native order + * even if no sort order is requested, so they remain stable across + * scripting and replication. */ + if ((dontsort && sortval->type == REDIS_SET)) { /* Force ALPHA sorting */ dontsort = 0; |