Merge branch 'master' of git@github.com:antirez/redis
This commit is contained in:
commit
48d729a7d9
67
Changelog
67
Changelog
@ -1,3 +1,70 @@
|
||||
2010-04-30 linenoise.c updated, now redis-cli can be used in a pipe (antirez)
|
||||
2010-04-29 redis-cli minor fix (less segfault is better) (antirez)
|
||||
2010-04-29 New MONITOR output format with timestamp, every command in a single line, string representations (antirez)
|
||||
2010-04-29 redis-cli INFO output format is now raw again (antirez)
|
||||
2010-04-29 Added more information about slave election in Redis Cluster alternative doc (antirez)
|
||||
2010-04-29 Redis cluster version 2 (antirez)
|
||||
2010-04-27 Fixed a redis-cli bug, was using free instead of zfree call (antirez)
|
||||
2010-04-27 AOF is now rewritten on slave after SYNC with master. Thanks to @_km for finding this bug and any others' (antirez)
|
||||
2010-04-27 redis-cli is now using only the new protocol (antirez)
|
||||
2010-04-27 Minimal support for subscribe/psubscribe in redis-cli (antirez)
|
||||
2010-04-26 don't output the newline when stdout is not a tty (antirez)
|
||||
2010-04-26 redis-cli now is able to also output the string representation instead of the raw string. Much better for debugging (antirez)
|
||||
2010-04-26 Initial support for quoted strings in redis-cli (antirez)
|
||||
2010-04-23 SETEX implemented (antirez)
|
||||
2010-04-23 Pub/Sub API change: now messages received via pattern matching have a different message type and an additional field representing the original pattern the message matched (antirez)
|
||||
2010-04-22 typo fixed, reloaded (antirez)
|
||||
2010-04-22 typo fixed (antirez)
|
||||
2010-04-22 REDIS-CLUSTER doc updated (antirez)
|
||||
2010-04-22 Virtual memory design document removed, no longer needed as we have a full specification and implementation (antirez)
|
||||
2010-04-22 new units for bytes specification (antirez)
|
||||
2010-04-22 Now in redis.conf it is possible to specify units where appropriate instead of amounts of bytes, like 2Gi or 4M and so forth (antirez)
|
||||
2010-04-21 binary safe keys ready implementation of RANDOMKEYS (antirez)
|
||||
2010-04-21 Now that's the right 1.3.10 (antirez)
|
||||
2010-04-21 Revert "fsync always now uses O_DIRECT on Linux" (antirez)
|
||||
2010-04-21 Revert "define __USE_GNU to get O_DIRECT" (antirez)
|
||||
2010-04-21 Merge branch 'master' of github.com:antirez/redis (antirez)
|
||||
2010-04-21 Revert "version 1.3.10" (antirez)
|
||||
2010-04-21 version 1.3.10 (antirez)
|
||||
2010-04-20 define __USE_GNU to get O_DIRECT (antirez)
|
||||
2010-04-20 fsync always now uses O_DIRECT on Linux (antirez)
|
||||
2010-04-20 More precise memory used guesswork in zmalloc.c (antirez)
|
||||
2010-04-19 Fix for MULTI/EXEC and Replication/AOF: now the block is correctly sent as MULTI/..writing operations../EXEC. Ok for slaves but more work needed for the AOF as it should be a write-all-or-nothing business (antirez)
|
||||
2010-04-19 running the test using tcl8.5 directly instead of tclsh that too often it's a symlink to 8.4 (antirez)
|
||||
2010-04-19 Added package require Tcl 8.5 in redis.tcl so it will show a clear error when the test suit is attempted to run under 8.4 (antirez)
|
||||
2010-04-18 Fix for a SORT bug introduced with commit 16fa22f1, regression test added (antirez)
|
||||
2010-04-18 Guru mediation -> meditation (antirez)
|
||||
2010-04-16 check eptr inline (Pieter Noordhuis)
|
||||
2010-04-16 refactor code that retrieves value from object or replies to client (Pieter Noordhuis)
|
||||
2010-04-17 Merge branch 'hash' of git://github.com/pietern/redis (antirez)
|
||||
2010-04-17 redisAssert(0) => redisPanic("something meaningful") (antirez)
|
||||
2010-04-17 make sure that the resulting value in hincrby is encoded when possible (Pieter Noordhuis)
|
||||
2010-04-17 increment dirty counter after hmset (Pieter Noordhuis)
|
||||
2010-04-17 strip tryObjectEncoding from hashSet, to enable the arguments being encoded in-place (Pieter Noordhuis)
|
||||
2010-04-17 Added support for Guru Mediation, and raising a guru mediation if refCount <= 0 but decrRefCount is called against such an object (antirez)
|
||||
2010-04-16 fix small error and memory leaks in SORT (Pieter Noordhuis)
|
||||
2010-04-16 SORT/GET test added (antirez)
|
||||
2010-04-16 Added tests for GET/BY against hashes fields (antirez)
|
||||
2010-04-16 Merge branch 'hash-refactor' of git://github.com/pietern/redis (antirez)
|
||||
2010-04-16 check object type in lookupKeyByPattern (Pieter Noordhuis)
|
||||
2010-04-16 make sortCommand aware that lookupKeyByPattern always increased the refcount of the returned value (Pieter Noordhuis)
|
||||
2010-04-16 revert 0c390a to stop using tricks with o->refcount (Pieter Noordhuis)
|
||||
2010-04-16 store the hash iterator on the heap instead of the stack (Pieter Noordhuis)
|
||||
2010-04-16 drop inline directive (Pieter Noordhuis)
|
||||
2010-04-16 rename hashReplace to hashSet (Pieter Noordhuis)
|
||||
2010-04-16 added dictFetchValue() to dict.c to make hash table API a bit less verbose in the common cases (antirez)
|
||||
2010-04-03 Don't set expire to keys with ttl=0, remove them immediately. (antirez)
|
||||
2010-04-15 make sure that cmpobj is in decoded form when sorting by ALPHA (this solves edge case from previous commit where (!sortby && alpha) == 1) (Pieter Noordhuis)
|
||||
2010-04-15 enable hash dereference in SORT on BY and GET (Pieter Noordhuis)
|
||||
2010-04-15 use shared replies for hset (Pieter Noordhuis)
|
||||
2010-04-15 set refcount of string objects retrieved from zipmaps to 0, so we don't have to touch the refcount of the objects inside dicts (Pieter Noordhuis)
|
||||
2010-04-15 added HSETNX (Pieter Noordhuis)
|
||||
2010-04-14 refactor of hash commands to use specialized api that abstracts zipmap and dict apis (Pieter Noordhuis)
|
||||
2010-04-13 move retrieval of long up to prevent an empty hash from being created (Pieter Noordhuis)
|
||||
2010-04-15 more advanced leaks detection in test redis (antirez)
|
||||
2010-04-15 ability to select port/host from make test (antirez)
|
||||
2010-04-15 Active rehashing (antirez)
|
||||
2010-04-15 Incrementally rehahsing hash table! Thanks to Derek Collison and Pieter Noordhuis for feedbacks/help (antirez)
|
||||
2010-04-14 Does not allow commands other than Pub/Sub commands when there is at least one pattern (antirez)
|
||||
2010-04-13 Fixed a tiny memory leak when loading the configuration file. (Alex McHale)
|
||||
2010-04-13 Merge branch 'hmget' of git://github.com/pietern/redis (antirez)
|
||||
|
61
linenoise.c
61
linenoise.c
@ -69,7 +69,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "fmacros.h"
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@ -82,6 +81,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#define LINENOISE_MAX_LINE 4096
|
||||
static char *unsupported_term[] = {"dumb","cons25",NULL};
|
||||
|
||||
static struct termios orig_termios; /* in order to restore at exit */
|
||||
static int rawmode = 0; /* for atexit() function to check if restore is needed*/
|
||||
@ -91,7 +91,17 @@ static int history_len = 0;
|
||||
char **history = NULL;
|
||||
|
||||
static void linenoiseAtExit(void);
|
||||
int linenoiseHistoryAdd(char *line);
|
||||
int linenoiseHistoryAdd(const char *line);
|
||||
|
||||
static int isUnsupportedTerm(void) {
|
||||
char *term = getenv("TERM");
|
||||
int j;
|
||||
|
||||
if (term == NULL) return 0;
|
||||
for (j = 0; unsupported_term[j]; j++)
|
||||
if (!strcasecmp(term,unsupported_term[j])) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void freeHistory(void) {
|
||||
if (history) {
|
||||
@ -341,10 +351,19 @@ static int linenoiseRaw(char *buf, size_t buflen, const char *prompt) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (enableRawMode(fd) == -1) return -1;
|
||||
count = linenoisePrompt(fd, buf, buflen, prompt);
|
||||
disableRawMode(fd);
|
||||
printf("\n");
|
||||
if (!isatty(STDIN_FILENO)) {
|
||||
if (fgets(buf, buflen, stdin) == NULL) return -1;
|
||||
count = strlen(buf);
|
||||
if (count && buf[count-1] == '\n') {
|
||||
count--;
|
||||
buf[count] = '\0';
|
||||
}
|
||||
} else {
|
||||
if (enableRawMode(fd) == -1) return -1;
|
||||
count = linenoisePrompt(fd, buf, buflen, prompt);
|
||||
disableRawMode(fd);
|
||||
printf("\n");
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@ -352,26 +371,42 @@ char *linenoise(const char *prompt) {
|
||||
char buf[LINENOISE_MAX_LINE];
|
||||
int count;
|
||||
|
||||
count = linenoiseRaw(buf,LINENOISE_MAX_LINE,prompt);
|
||||
if (count == -1) return NULL;
|
||||
return strdup(buf);
|
||||
if (isUnsupportedTerm()) {
|
||||
size_t len;
|
||||
|
||||
printf("%s",prompt);
|
||||
fflush(stdout);
|
||||
if (fgets(buf,LINENOISE_MAX_LINE,stdin) == NULL) return NULL;
|
||||
len = strlen(buf);
|
||||
while(len && (buf[len-1] == '\n' || buf[len-1] == '\r')) {
|
||||
len--;
|
||||
buf[len] = '\0';
|
||||
}
|
||||
return strdup(buf);
|
||||
} else {
|
||||
count = linenoiseRaw(buf,LINENOISE_MAX_LINE,prompt);
|
||||
if (count == -1) return NULL;
|
||||
return strdup(buf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Using a circular buffer is smarter, but a bit more complex to handle. */
|
||||
int linenoiseHistoryAdd(char *line) {
|
||||
int linenoiseHistoryAdd(const char *line) {
|
||||
char *linecopy;
|
||||
|
||||
if (history_max_len == 0) return 0;
|
||||
if (history == 0) {
|
||||
history = malloc(sizeof(char*)*history_max_len);
|
||||
if (history == NULL) return 0;
|
||||
memset(history,0,(sizeof(char*)*history_max_len));
|
||||
}
|
||||
line = strdup(line);
|
||||
if (!line) return 0;
|
||||
linecopy = strdup(line);
|
||||
if (!linecopy) return 0;
|
||||
if (history_len == history_max_len) {
|
||||
memmove(history,history+1,sizeof(char*)*(history_max_len-1));
|
||||
history_len--;
|
||||
}
|
||||
history[history_len] = line;
|
||||
history[history_len] = linecopy;
|
||||
history_len++;
|
||||
return 1;
|
||||
}
|
||||
|
@ -2171,6 +2171,17 @@ proc main {} {
|
||||
[$r append foo 100] [$r get foo]
|
||||
} {3 bar 6 bar100}
|
||||
|
||||
test {APPEND basics, integer encoded values} {
|
||||
set res {}
|
||||
$r del foo
|
||||
$r append foo 1
|
||||
$r append foo 2
|
||||
lappend res [$r get foo]
|
||||
$r set foo 1
|
||||
$r append foo 2
|
||||
lappend res [$r get foo]
|
||||
} {12 12}
|
||||
|
||||
test {APPEND fuzzing} {
|
||||
set err {}
|
||||
foreach type {binary alpha compr} {
|
||||
@ -2189,6 +2200,42 @@ proc main {} {
|
||||
set _ $err
|
||||
} {}
|
||||
|
||||
test {SUBSTR basics} {
|
||||
set res {}
|
||||
$r set foo "Hello World"
|
||||
lappend res [$r substr foo 0 3]
|
||||
lappend res [$r substr foo 0 -1]
|
||||
lappend res [$r substr foo -4 -1]
|
||||
lappend res [$r substr foo 5 3]
|
||||
lappend res [$r substr foo 5 5000]
|
||||
lappend res [$r substr foo -5000 10000]
|
||||
set _ $res
|
||||
} {Hell {Hello World} orld {} { World} {Hello World}}
|
||||
|
||||
test {SUBSTR against integer encoded values} {
|
||||
$r set foo 123
|
||||
$r substr foo 0 -2
|
||||
} {12}
|
||||
|
||||
test {SUBSTR fuzzing} {
|
||||
set err {}
|
||||
for {set i 0} {$i < 1000} {incr i} {
|
||||
set bin [randstring 0 1024 binary]
|
||||
set _start [set start [randomInt 1500]]
|
||||
set _end [set end [randomInt 1500]]
|
||||
if {$_start < 0} {set _start "end-[abs($_start)-1]"}
|
||||
if {$_end < 0} {set _end "end-[abs($_end)-1]"}
|
||||
set s1 [string range $bin $_start $_end]
|
||||
$r set bin $bin
|
||||
set s2 [$r substr bin $start $end]
|
||||
if {$s1 != $s2} {
|
||||
set err "String mismatch"
|
||||
break
|
||||
}
|
||||
}
|
||||
set _ $err
|
||||
} {}
|
||||
|
||||
# Leave the user with a clean DB before to exit
|
||||
test {FLUSHDB} {
|
||||
set aux {}
|
||||
|
Loading…
Reference in New Issue
Block a user