Merge pull request #5452 from soloestoy/xsetid-lastid

Streams: rewrite empty streams with certain lastid
This commit is contained in:
Salvatore Sanfilippo 2018-10-16 18:56:55 +02:00 committed by GitHub
commit 2f8f29aa0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -1167,7 +1167,7 @@ int rewriteStreamObject(rio *r, robj *key, robj *o) {
if (rioWriteBulkObject(r,key) == 0) return 0; if (rioWriteBulkObject(r,key) == 0) return 0;
if (rioWriteBulkString(r,"MAXLEN",6) == 0) return 0; if (rioWriteBulkString(r,"MAXLEN",6) == 0) return 0;
if (rioWriteBulkString(r,"0",1) == 0) return 0; if (rioWriteBulkString(r,"0",1) == 0) return 0;
if (rioWriteBulkString(r,"*",1) == 0) return 0; if (rioWriteBulkStreamID(r,&s->last_id) == 0) return 0;
if (rioWriteBulkString(r,"x",1) == 0) return 0; if (rioWriteBulkString(r,"x",1) == 0) return 0;
if (rioWriteBulkString(r,"y",1) == 0) return 0; if (rioWriteBulkString(r,"y",1) == 0) return 0;
} }

View File

@ -375,14 +375,14 @@ start_server {tags {"xsetid"}} {
assert {[dict get [r xinfo stream mystream] last-generated-id] == "200-0"} assert {[dict get [r xinfo stream mystream] last-generated-id] == "200-0"}
} }
test {XSTREAM cannot SETID with smaller ID} { test {XSETID cannot SETID with smaller ID} {
r XADD mystream * a b r XADD mystream * a b
catch {r XSETID mystream "1-1"} err catch {r XSETID mystream "1-1"} err
r XADD mystream MAXLEN 0 * a b r XADD mystream MAXLEN 0 * a b
set err set err
} {ERR*smaller*} } {ERR*smaller*}
test {XSTREAM cannot SETID on non-existent key} { test {XSETID cannot SETID on non-existent key} {
catch {r XSETID stream 1-1} err catch {r XSETID stream 1-1} err
set _ $err set _ $err
} {ERR no such key} } {ERR no such key}