Commit 4aab50ac authored by rojingeorge's avatar rojingeorge
Browse files

Merge remote-tracking branch 'refs/remotes/antirez/unstable' into unstable

parents 646c958b f60aa4de
...@@ -219,11 +219,11 @@ int setTypeRandomElement(robj *setobj, sds *sdsele, int64_t *llele) { ...@@ -219,11 +219,11 @@ int setTypeRandomElement(robj *setobj, sds *sdsele, int64_t *llele) {
return setobj->encoding; return setobj->encoding;
} }
unsigned long setTypeSize(robj *subject) { unsigned long setTypeSize(const robj *subject) {
if (subject->encoding == OBJ_ENCODING_HT) { if (subject->encoding == OBJ_ENCODING_HT) {
return dictSize((dict*)subject->ptr); return dictSize((const dict*)subject->ptr);
} else if (subject->encoding == OBJ_ENCODING_INTSET) { } else if (subject->encoding == OBJ_ENCODING_INTSET) {
return intsetLen((intset*)subject->ptr); return intsetLen((const intset*)subject->ptr);
} else { } else {
serverPanic("Unknown set encoding"); serverPanic("Unknown set encoding");
} }
...@@ -351,9 +351,6 @@ void smoveCommand(client *c) { ...@@ -351,9 +351,6 @@ void smoveCommand(client *c) {
dbDelete(c->db,c->argv[1]); dbDelete(c->db,c->argv[1]);
notifyKeyspaceEvent(NOTIFY_GENERIC,"del",c->argv[1],c->db->id); notifyKeyspaceEvent(NOTIFY_GENERIC,"del",c->argv[1],c->db->id);
} }
signalModifiedKey(c->db,c->argv[1]);
signalModifiedKey(c->db,c->argv[2]);
server.dirty++;
/* Create the destination set when it doesn't exist */ /* Create the destination set when it doesn't exist */
if (!dstset) { if (!dstset) {
...@@ -361,6 +358,10 @@ void smoveCommand(client *c) { ...@@ -361,6 +358,10 @@ void smoveCommand(client *c) {
dbAdd(c->db,c->argv[2],dstset); dbAdd(c->db,c->argv[2],dstset);
} }
signalModifiedKey(c->db,c->argv[1]);
signalModifiedKey(c->db,c->argv[2]);
server.dirty++;
/* An extra key has changed when ele was successfully added to dstset */ /* An extra key has changed when ele was successfully added to dstset */
if (setTypeAdd(dstset,ele->ptr)) { if (setTypeAdd(dstset,ele->ptr)) {
server.dirty++; server.dirty++;
...@@ -547,6 +548,8 @@ void spopWithCountCommand(client *c) { ...@@ -547,6 +548,8 @@ void spopWithCountCommand(client *c) {
* the alsoPropagate() API. */ * the alsoPropagate() API. */
decrRefCount(propargv[0]); decrRefCount(propargv[0]);
preventCommandPropagation(c); preventCommandPropagation(c);
signalModifiedKey(c->db,c->argv[1]);
server.dirty++;
} }
void spopCommand(client *c) { void spopCommand(client *c) {
......
...@@ -263,6 +263,10 @@ void getrangeCommand(client *c) { ...@@ -263,6 +263,10 @@ void getrangeCommand(client *c) {
} }
/* Convert negative indexes */ /* Convert negative indexes */
if (start < 0 && end < 0 && start > end) {
addReply(c,shared.emptybulk);
return;
}
if (start < 0) start = strlen+start; if (start < 0) start = strlen+start;
if (end < 0) end = strlen+end; if (end < 0) end = strlen+end;
if (start < 0) start = 0; if (start < 0) start = 0;
......
...@@ -1100,12 +1100,12 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig ...@@ -1100,12 +1100,12 @@ unsigned char *zzlDeleteRangeByRank(unsigned char *zl, unsigned int start, unsig
* Common sorted set API * Common sorted set API
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
unsigned int zsetLength(robj *zobj) { unsigned int zsetLength(const robj *zobj) {
int length = -1; int length = -1;
if (zobj->encoding == OBJ_ENCODING_ZIPLIST) { if (zobj->encoding == OBJ_ENCODING_ZIPLIST) {
length = zzlLength(zobj->ptr); length = zzlLength(zobj->ptr);
} else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) { } else if (zobj->encoding == OBJ_ENCODING_SKIPLIST) {
length = ((zset*)zobj->ptr)->zsl->length; length = ((const zset*)zobj->ptr)->zsl->length;
} else { } else {
serverPanic("Unknown sorted set encoding"); serverPanic("Unknown sorted set encoding");
} }
...@@ -2327,16 +2327,13 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) { ...@@ -2327,16 +2327,13 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
serverPanic("Unknown operator"); serverPanic("Unknown operator");
} }
if (dbDelete(c->db,dstkey)) { if (dbDelete(c->db,dstkey))
signalModifiedKey(c->db,dstkey);
touched = 1; touched = 1;
server.dirty++;
}
if (dstzset->zsl->length) { if (dstzset->zsl->length) {
zsetConvertToZiplistIfNeeded(dstobj,maxelelen); zsetConvertToZiplistIfNeeded(dstobj,maxelelen);
dbAdd(c->db,dstkey,dstobj); dbAdd(c->db,dstkey,dstobj);
addReplyLongLong(c,zsetLength(dstobj)); addReplyLongLong(c,zsetLength(dstobj));
if (!touched) signalModifiedKey(c->db,dstkey); signalModifiedKey(c->db,dstkey);
notifyKeyspaceEvent(NOTIFY_ZSET, notifyKeyspaceEvent(NOTIFY_ZSET,
(op == SET_OP_UNION) ? "zunionstore" : "zinterstore", (op == SET_OP_UNION) ? "zunionstore" : "zinterstore",
dstkey,c->db->id); dstkey,c->db->id);
...@@ -2344,8 +2341,11 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) { ...@@ -2344,8 +2341,11 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
} else { } else {
decrRefCount(dstobj); decrRefCount(dstobj);
addReply(c,shared.czero); addReply(c,shared.czero);
if (touched) if (touched) {
signalModifiedKey(c->db,dstkey);
notifyKeyspaceEvent(NOTIFY_GENERIC,"del",dstkey,c->db->id); notifyKeyspaceEvent(NOTIFY_GENERIC,"del",dstkey,c->db->id);
server.dirty++;
}
} }
zfree(src); zfree(src);
} }
......
...@@ -46,10 +46,12 @@ set ::all_tests { ...@@ -46,10 +46,12 @@ set ::all_tests {
unit/scripting unit/scripting
unit/maxmemory unit/maxmemory
unit/introspection unit/introspection
unit/introspection-2
unit/limits unit/limits
unit/obuf-limits unit/obuf-limits
unit/bitops unit/bitops
unit/bitfield unit/bitfield
unit/geo
unit/memefficiency unit/memefficiency
unit/hyperloglog unit/hyperloglog
unit/lazyfree unit/lazyfree
......
...@@ -184,4 +184,9 @@ start_server {tags {"bitops"}} { ...@@ -184,4 +184,9 @@ start_server {tags {"bitops"}} {
} }
} }
} }
test {BITFIELD regression for #3221} {
r set bits 1
r bitfield bits get u1 0
} {0}
} }
...@@ -43,6 +43,16 @@ start_server {tags {"bitops"}} { ...@@ -43,6 +43,16 @@ start_server {tags {"bitops"}} {
r bitcount no-key r bitcount no-key
} 0 } 0
test {BITCOUNT returns 0 with out of range indexes} {
r set str "xxxx"
r bitcount str 4 10
} 0
test {BITCOUNT returns 0 with negative indexes where start > end} {
r set str "xxxx"
r bitcount str -6 -7
} 0
catch {unset num} catch {unset num}
foreach vec [list "" "\xaa" "\x00\x00\xff" "foobar" "123"] { foreach vec [list "" "\xaa" "\x00\x00\xff" "foobar" "123"] {
incr num incr num
......
start_server {tags {"introspection"}} {
test {TTL and TYPYE do not alter the last access time of a key} {
r set foo bar
after 3000
r ttl foo
r type foo
assert {[r object idletime foo] >= 2}
}
test {TOUCH alters the last access time of a key} {
r set foo bar
after 3000
r touch foo
assert {[r object idletime foo] < 2}
}
test {TOUCH returns the number of existing keys specified} {
r flushdb
r set key1 1
r set key2 2
r touch key0 key1 key2 key3
} 2
}
...@@ -142,7 +142,7 @@ start_server {tags {"scripting"}} { ...@@ -142,7 +142,7 @@ start_server {tags {"scripting"}} {
test {EVAL - Scripts can't run certain commands} { test {EVAL - Scripts can't run certain commands} {
set e {} set e {}
catch {r eval {return redis.pcall('spop','x')} 0} e catch {r eval {return redis.pcall('blpop','x',0)} 0} e
set e set e
} {*not allowed*} } {*not allowed*}
......
...@@ -507,7 +507,9 @@ start_server { ...@@ -507,7 +507,9 @@ start_server {
create_list xlist "$large c" create_list xlist "$large c"
assert_equal 3 [r rpushx xlist d] assert_equal 3 [r rpushx xlist d]
assert_equal 4 [r lpushx xlist a] assert_equal 4 [r lpushx xlist a]
assert_equal "a $large c d" [r lrange xlist 0 -1] assert_equal 6 [r rpushx xlist 42 x]
assert_equal 9 [r lpushx xlist y3 y2 y1]
assert_equal "y1 y2 y3 a $large c d 42 x" [r lrange xlist 0 -1]
} }
test "LINSERT - $type" { test "LINSERT - $type" {
......
...@@ -25,9 +25,25 @@ ...@@ -25,9 +25,25 @@
# #
################################################################################ ################################################################################
# #
# Interactive service installer for redis server # Service installer for redis server, runs interactively by default.
# this generates a redis config file and an /etc/init.d script, and installs them #
# this scripts should be run as root # To run this script non-interactively (for automation/provisioning purposes),
# feed the variables into the script. Any missing variables will be prompted!
# Tip: Environment variables also support command substitution (see REDIS_EXECUTABLE)
#
# Example:
#
# sudo REDIS_PORT=1234 \
# REDIS_CONFIG_FILE=/etc/redis/1234.conf \
# REDIS_LOG_FILE=/var/log/redis_1234.log \
# REDIS_DATA_DIR=/var/lib/redis/1234 \
# REDIS_EXECUTABLE=`command -v redis-server` ./utils/install_server.sh
#
# This generates a redis config file and an /etc/init.d script, and installs them.
#
# /!\ This script should be run as root
#
################################################################################
die () { die () {
echo "ERROR: $1. Aborting!" echo "ERROR: $1. Aborting!"
...@@ -42,6 +58,7 @@ SCRIPTPATH=$(dirname $SCRIPT) ...@@ -42,6 +58,7 @@ SCRIPTPATH=$(dirname $SCRIPT)
#Initial defaults #Initial defaults
_REDIS_PORT=6379 _REDIS_PORT=6379
_MANUAL_EXECUTION=false
echo "Welcome to the redis service installer" echo "Welcome to the redis service installer"
echo "This script will help you easily set up a running redis server" echo "This script will help you easily set up a running redis server"
...@@ -53,47 +70,61 @@ if [ "$(id -u)" -ne 0 ] ; then ...@@ -53,47 +70,61 @@ if [ "$(id -u)" -ne 0 ] ; then
exit 1 exit 1
fi fi
#Read the redis port
read -p "Please select the redis port for this instance: [$_REDIS_PORT] " REDIS_PORT
if ! echo $REDIS_PORT | egrep -q '^[0-9]+$' ; then if ! echo $REDIS_PORT | egrep -q '^[0-9]+$' ; then
echo "Selecting default: $_REDIS_PORT" _MANUAL_EXECUTION=true
REDIS_PORT=$_REDIS_PORT #Read the redis port
read -p "Please select the redis port for this instance: [$_REDIS_PORT] " REDIS_PORT
if ! echo $REDIS_PORT | egrep -q '^[0-9]+$' ; then
echo "Selecting default: $_REDIS_PORT"
REDIS_PORT=$_REDIS_PORT
fi
fi fi
#read the redis config file
_REDIS_CONFIG_FILE="/etc/redis/$REDIS_PORT.conf"
read -p "Please select the redis config file name [$_REDIS_CONFIG_FILE] " REDIS_CONFIG_FILE
if [ -z "$REDIS_CONFIG_FILE" ] ; then if [ -z "$REDIS_CONFIG_FILE" ] ; then
REDIS_CONFIG_FILE=$_REDIS_CONFIG_FILE _MANUAL_EXECUTION=true
echo "Selected default - $REDIS_CONFIG_FILE" #read the redis config file
_REDIS_CONFIG_FILE="/etc/redis/$REDIS_PORT.conf"
read -p "Please select the redis config file name [$_REDIS_CONFIG_FILE] " REDIS_CONFIG_FILE
if [ -z "$REDIS_CONFIG_FILE" ] ; then
REDIS_CONFIG_FILE=$_REDIS_CONFIG_FILE
echo "Selected default - $REDIS_CONFIG_FILE"
fi
fi fi
#read the redis log file path
_REDIS_LOG_FILE="/var/log/redis_$REDIS_PORT.log"
read -p "Please select the redis log file name [$_REDIS_LOG_FILE] " REDIS_LOG_FILE
if [ -z "$REDIS_LOG_FILE" ] ; then if [ -z "$REDIS_LOG_FILE" ] ; then
REDIS_LOG_FILE=$_REDIS_LOG_FILE _MANUAL_EXECUTION=true
echo "Selected default - $REDIS_LOG_FILE" #read the redis log file path
_REDIS_LOG_FILE="/var/log/redis_$REDIS_PORT.log"
read -p "Please select the redis log file name [$_REDIS_LOG_FILE] " REDIS_LOG_FILE
if [ -z "$REDIS_LOG_FILE" ] ; then
REDIS_LOG_FILE=$_REDIS_LOG_FILE
echo "Selected default - $REDIS_LOG_FILE"
fi
fi fi
#get the redis data directory
_REDIS_DATA_DIR="/var/lib/redis/$REDIS_PORT"
read -p "Please select the data directory for this instance [$_REDIS_DATA_DIR] " REDIS_DATA_DIR
if [ -z "$REDIS_DATA_DIR" ] ; then if [ -z "$REDIS_DATA_DIR" ] ; then
REDIS_DATA_DIR=$_REDIS_DATA_DIR _MANUAL_EXECUTION=true
echo "Selected default - $REDIS_DATA_DIR" #get the redis data directory
_REDIS_DATA_DIR="/var/lib/redis/$REDIS_PORT"
read -p "Please select the data directory for this instance [$_REDIS_DATA_DIR] " REDIS_DATA_DIR
if [ -z "$REDIS_DATA_DIR" ] ; then
REDIS_DATA_DIR=$_REDIS_DATA_DIR
echo "Selected default - $REDIS_DATA_DIR"
fi
fi fi
#get the redis executable path
_REDIS_EXECUTABLE=`command -v redis-server`
read -p "Please select the redis executable path [$_REDIS_EXECUTABLE] " REDIS_EXECUTABLE
if [ ! -x "$REDIS_EXECUTABLE" ] ; then if [ ! -x "$REDIS_EXECUTABLE" ] ; then
REDIS_EXECUTABLE=$_REDIS_EXECUTABLE _MANUAL_EXECUTION=true
#get the redis executable path
_REDIS_EXECUTABLE=`command -v redis-server`
read -p "Please select the redis executable path [$_REDIS_EXECUTABLE] " REDIS_EXECUTABLE
if [ ! -x "$REDIS_EXECUTABLE" ] ; then if [ ! -x "$REDIS_EXECUTABLE" ] ; then
echo "Mmmmm... it seems like you don't have a redis executable. Did you run make install yet?" REDIS_EXECUTABLE=$_REDIS_EXECUTABLE
exit 1
if [ ! -x "$REDIS_EXECUTABLE" ] ; then
echo "Mmmmm... it seems like you don't have a redis executable. Did you run make install yet?"
exit 1
fi
fi fi
fi fi
...@@ -112,7 +143,9 @@ echo "Data dir : $REDIS_DATA_DIR" ...@@ -112,7 +143,9 @@ echo "Data dir : $REDIS_DATA_DIR"
echo "Executable : $REDIS_EXECUTABLE" echo "Executable : $REDIS_EXECUTABLE"
echo "Cli Executable : $CLI_EXEC" echo "Cli Executable : $CLI_EXEC"
read -p "Is this ok? Then press ENTER to go on or Ctrl-C to abort." _UNUSED_ if $_MANUAL_EXECUTION == true ; then
read -p "Is this ok? Then press ENTER to go on or Ctrl-C to abort." _UNUSED_
fi
mkdir -p `dirname "$REDIS_CONFIG_FILE"` || die "Could not create redis config directory" mkdir -p `dirname "$REDIS_CONFIG_FILE"` || die "Could not create redis config directory"
mkdir -p `dirname "$REDIS_LOG_FILE"` || die "Could not create redis log dir" mkdir -p `dirname "$REDIS_LOG_FILE"` || die "Could not create redis log dir"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment