Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
f424d5f3
Commit
f424d5f3
authored
May 06, 2010
by
antirez
Browse files
Merge branch 'master' into aof-speedup
parents
28ed1f33
4132ad8d
Changes
2
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
f424d5f3
...
@@ -3227,7 +3227,7 @@ static int getDoubleFromObject(robj *o, double *target) {
...
@@ -3227,7 +3227,7 @@ static int getDoubleFromObject(robj *o, double *target) {
} else if (o->encoding == REDIS_ENCODING_INT) {
} else if (o->encoding == REDIS_ENCODING_INT) {
value = (long)o->ptr;
value = (long)o->ptr;
} else {
} else {
redis
Assert(1 != 1
);
redis
Panic("Unknown string encoding"
);
}
}
}
}
...
@@ -3264,7 +3264,7 @@ static int getLongLongFromObject(robj *o, long long *target) {
...
@@ -3264,7 +3264,7 @@ static int getLongLongFromObject(robj *o, long long *target) {
} else if (o->encoding == REDIS_ENCODING_INT) {
} else if (o->encoding == REDIS_ENCODING_INT) {
value = (long)o->ptr;
value = (long)o->ptr;
} else {
} else {
redis
Assert(1 != 1
);
redis
Panic("Unknown string encoding"
);
}
}
}
}
...
@@ -6468,12 +6468,11 @@ static void hincrbyCommand(redisClient *c) {
...
@@ -6468,12 +6468,11 @@ static void hincrbyCommand(redisClient *c) {
if (getLongLongFromObjectOrReply(c,c->argv[3],&incr,NULL) != REDIS_OK) return;
if (getLongLongFromObjectOrReply(c,c->argv[3],&incr,NULL) != REDIS_OK) return;
if ((o = hashLookupWriteOrCreate(c,c->argv[1])) == NULL) return;
if ((o = hashLookupWriteOrCreate(c,c->argv[1])) == NULL) return;
if ((current = hashGet(o,c->argv[2])) != NULL) {
if ((current = hashGet(o,c->argv[2])) != NULL) {
if (current->encoding == REDIS_ENCODING_RAW)
if (getLongLongFromObjectOrReply(c,current,&value,
value = strtoll(current->ptr,NULL,10);
"hash value is not an integer") != REDIS_OK) {
else if (current->encoding == REDIS_ENCODING_INT)
decrRefCount(current);
value = (long)current->ptr;
return;
else
}
redisAssert(1 != 1);
decrRefCount(current);
decrRefCount(current);
} else {
} else {
value = 0;
value = 0;
...
@@ -8140,12 +8139,14 @@ static struct redisClient *createFakeClient(void) {
...
@@ -8140,12 +8139,14 @@ static struct redisClient *createFakeClient(void) {
c->reply = listCreate();
c->reply = listCreate();
listSetFreeMethod(c->reply,decrRefCount);
listSetFreeMethod(c->reply,decrRefCount);
listSetDupMethod(c->reply,dupClientReplyValue);
listSetDupMethod(c->reply,dupClientReplyValue);
initClientMultiState(c);
return c;
return c;
}
}
static void freeFakeClient(struct redisClient *c) {
static void freeFakeClient(struct redisClient *c) {
sdsfree(c->querybuf);
sdsfree(c->querybuf);
listRelease(c->reply);
listRelease(c->reply);
freeClientMultiState(c);
zfree(c);
zfree(c);
}
}
...
@@ -8157,6 +8158,7 @@ int loadAppendOnlyFile(char *filename) {
...
@@ -8157,6 +8158,7 @@ int loadAppendOnlyFile(char *filename) {
FILE *fp = fopen(filename,"r");
FILE *fp = fopen(filename,"r");
struct redis_stat sb;
struct redis_stat sb;
unsigned long long loadedkeys = 0;
unsigned long long loadedkeys = 0;
int appendonly = server.appendonly;
if (redis_fstat(fileno(fp),&sb) != -1 && sb.st_size == 0)
if (redis_fstat(fileno(fp),&sb) != -1 && sb.st_size == 0)
return REDIS_ERR;
return REDIS_ERR;
...
@@ -8166,6 +8168,10 @@ int loadAppendOnlyFile(char *filename) {
...
@@ -8166,6 +8168,10 @@ int loadAppendOnlyFile(char *filename) {
exit(1);
exit(1);
}
}
/* Temporarily disable AOF, to prevent EXEC from feeding a MULTI
* to the same file we're about to read. */
server.appendonly = 0;
fakeClient = createFakeClient();
fakeClient = createFakeClient();
while(1) {
while(1) {
int argc, j;
int argc, j;
...
@@ -8221,8 +8227,14 @@ int loadAppendOnlyFile(char *filename) {
...
@@ -8221,8 +8227,14 @@ int loadAppendOnlyFile(char *filename) {
}
}
}
}
}
}
/* This point can only be reached when EOF is reached without errors.
* If the client is in the middle of a MULTI/EXEC, log error and quit. */
if (fakeClient->flags & REDIS_MULTI) goto readerr;
fclose(fp);
fclose(fp);
freeFakeClient(fakeClient);
freeFakeClient(fakeClient);
server.appendonly = appendonly;
return REDIS_OK;
return REDIS_OK;
readerr:
readerr:
...
...
test-redis.tcl
View file @
f424d5f3
...
@@ -1898,11 +1898,15 @@ proc main {} {
...
@@ -1898,11 +1898,15 @@ proc main {} {
list
[
$r
hincrby smallhash tmp 17179869184
]
[
$r
hincrby bighash tmp 17179869184
]
list
[
$r
hincrby smallhash tmp 17179869184
]
[
$r
hincrby bighash tmp 17179869184
]
}
{
34359738368 34359738368
}
}
{
34359738368 34359738368
}
test
{
HINCRBY against key with spaces
(
no integer encoded
)}
{
test
{
HINCRBY fails against hash value with spaces
}
{
$r hset smallhash tmp
" 11 "
$r hset smallhash str
" 11 "
$r hset bighash tmp
" 11 "
$r hset bighash str
" 11 "
list
[
$r
hincrby smallhash tmp 1
]
[
$r
hincrby bighash tmp 1
]
catch
{
$r
hincrby smallhash str 1
}
smallerr
}
{
12 12
}
catch
{
$r
hincrby smallhash str 1
}
bigerr
set rv
{}
lappend rv
[
string match
"ERR*not an integer*"
$smallerr
]
lappend rv
[
string match
"ERR*not an integer*"
$bigerr
]
}
{
1 1
}
# TODO:
# TODO:
# Randomized test, small and big
# Randomized test, small and big
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment