mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
Rename symbols, part one
This commit is contained in:
parent
3fe17f47ba
commit
4680b58962
2
src/.gitignore
vendored
2
src/.gitignore
vendored
@ -1,5 +1,5 @@
|
|||||||
*.gcda
|
*.gcda
|
||||||
*.gcno
|
*.gcno
|
||||||
*.gcov
|
*.gcov
|
||||||
redis.info
|
redict.info
|
||||||
lcov-html
|
lcov-html
|
||||||
|
32
src/acl.c
32
src/acl.c
@ -627,7 +627,7 @@ void ACLUpdateCommandRules(aclSelector *selector, const char *rule, int allow) {
|
|||||||
|
|
||||||
/* This function is used to allow/block a specific command.
|
/* This function is used to allow/block a specific command.
|
||||||
* Allowing/blocking a container command also applies for its subcommands */
|
* Allowing/blocking a container command also applies for its subcommands */
|
||||||
void ACLChangeSelectorPerm(aclSelector *selector, struct redisCommand *cmd, int allow) {
|
void ACLChangeSelectorPerm(aclSelector *selector, struct redictCommand *cmd, int allow) {
|
||||||
unsigned long id = cmd->id;
|
unsigned long id = cmd->id;
|
||||||
ACLSetSelectorCommandBit(selector,id,allow);
|
ACLSetSelectorCommandBit(selector,id,allow);
|
||||||
ACLResetFirstArgsForCommand(selector,id);
|
ACLResetFirstArgsForCommand(selector,id);
|
||||||
@ -635,7 +635,7 @@ void ACLChangeSelectorPerm(aclSelector *selector, struct redisCommand *cmd, int
|
|||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict);
|
dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict);
|
||||||
while((de = dictNext(di)) != NULL) {
|
while((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *sub = (struct redisCommand *)dictGetVal(de);
|
struct redictCommand *sub = (struct redictCommand *)dictGetVal(de);
|
||||||
ACLSetSelectorCommandBit(selector,sub->id,allow);
|
ACLSetSelectorCommandBit(selector,sub->id,allow);
|
||||||
}
|
}
|
||||||
dictReleaseIterator(di);
|
dictReleaseIterator(di);
|
||||||
@ -652,7 +652,7 @@ void ACLSetSelectorCommandBitsForCategory(dict *commands, aclSelector *selector,
|
|||||||
dictIterator *di = dictGetIterator(commands);
|
dictIterator *di = dictGetIterator(commands);
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
while ((de = dictNext(di)) != NULL) {
|
while ((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *cmd = dictGetVal(de);
|
struct redictCommand *cmd = dictGetVal(de);
|
||||||
if (cmd->acl_categories & cflag) {
|
if (cmd->acl_categories & cflag) {
|
||||||
ACLChangeSelectorPerm(selector,cmd,value);
|
ACLChangeSelectorPerm(selector,cmd,value);
|
||||||
}
|
}
|
||||||
@ -716,7 +716,7 @@ void ACLCountCategoryBitsForCommands(dict *commands, aclSelector *selector, unsi
|
|||||||
dictIterator *di = dictGetIterator(commands);
|
dictIterator *di = dictGetIterator(commands);
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
while ((de = dictNext(di)) != NULL) {
|
while ((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *cmd = dictGetVal(de);
|
struct redictCommand *cmd = dictGetVal(de);
|
||||||
if (cmd->acl_categories & cflag) {
|
if (cmd->acl_categories & cflag) {
|
||||||
if (ACLGetSelectorCommandBit(selector,cmd->id))
|
if (ACLGetSelectorCommandBit(selector,cmd->id))
|
||||||
(*on)++;
|
(*on)++;
|
||||||
@ -900,8 +900,8 @@ robj *ACLDescribeUser(user *u) {
|
|||||||
/* Get a command from the original command table, that is not affected
|
/* Get a command from the original command table, that is not affected
|
||||||
* by the command renaming operations: we base all the ACL work from that
|
* by the command renaming operations: we base all the ACL work from that
|
||||||
* table, so that ACLs are valid regardless of command renaming. */
|
* table, so that ACLs are valid regardless of command renaming. */
|
||||||
struct redisCommand *ACLLookupCommand(const char *name) {
|
struct redictCommand *ACLLookupCommand(const char *name) {
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
sds sdsname = sdsnew(name);
|
sds sdsname = sdsnew(name);
|
||||||
cmd = lookupCommandBySdsLogic(server.orig_commands,sdsname);
|
cmd = lookupCommandBySdsLogic(server.orig_commands,sdsname);
|
||||||
sdsfree(sdsname);
|
sdsfree(sdsname);
|
||||||
@ -1118,7 +1118,7 @@ int ACLSetSelector(aclSelector *selector, const char* op, size_t oplen) {
|
|||||||
selector->flags &= ~SELECTOR_FLAG_ALLCHANNELS;
|
selector->flags &= ~SELECTOR_FLAG_ALLCHANNELS;
|
||||||
} else if (op[0] == '+' && op[1] != '@') {
|
} else if (op[0] == '+' && op[1] != '@') {
|
||||||
if (strrchr(op,'|') == NULL) {
|
if (strrchr(op,'|') == NULL) {
|
||||||
struct redisCommand *cmd = ACLLookupCommand(op+1);
|
struct redictCommand *cmd = ACLLookupCommand(op+1);
|
||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
@ -1132,7 +1132,7 @@ int ACLSetSelector(aclSelector *selector, const char* op, size_t oplen) {
|
|||||||
sub[0] = '\0';
|
sub[0] = '\0';
|
||||||
sub++;
|
sub++;
|
||||||
|
|
||||||
struct redisCommand *cmd = ACLLookupCommand(copy);
|
struct redictCommand *cmd = ACLLookupCommand(copy);
|
||||||
|
|
||||||
/* Check if the command exists. We can't check the
|
/* Check if the command exists. We can't check the
|
||||||
* first-arg to see if it is valid. */
|
* first-arg to see if it is valid. */
|
||||||
@ -1181,7 +1181,7 @@ int ACLSetSelector(aclSelector *selector, const char* op, size_t oplen) {
|
|||||||
zfree(copy);
|
zfree(copy);
|
||||||
}
|
}
|
||||||
} else if (op[0] == '-' && op[1] != '@') {
|
} else if (op[0] == '-' && op[1] != '@') {
|
||||||
struct redisCommand *cmd = ACLLookupCommand(op+1);
|
struct redictCommand *cmd = ACLLookupCommand(op+1);
|
||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
@ -1677,7 +1677,7 @@ void cleanupACLKeyResultCache(aclKeyResultCache *cache) {
|
|||||||
* command cannot be executed because the selector is not allowed to run such
|
* command cannot be executed because the selector is not allowed to run such
|
||||||
* command, the second and third if the command is denied because the selector is trying
|
* command, the second and third if the command is denied because the selector is trying
|
||||||
* to access a key or channel that are not among the specified patterns. */
|
* to access a key or channel that are not among the specified patterns. */
|
||||||
static int ACLSelectorCheckCmd(aclSelector *selector, struct redisCommand *cmd, robj **argv, int argc, int *keyidxptr, aclKeyResultCache *cache) {
|
static int ACLSelectorCheckCmd(aclSelector *selector, struct redictCommand *cmd, robj **argv, int argc, int *keyidxptr, aclKeyResultCache *cache) {
|
||||||
uint64_t id = cmd->id;
|
uint64_t id = cmd->id;
|
||||||
int ret;
|
int ret;
|
||||||
if (!(selector->flags & SELECTOR_FLAG_ALLCOMMANDS) && !(cmd->flags & CMD_NO_AUTH)) {
|
if (!(selector->flags & SELECTOR_FLAG_ALLCOMMANDS) && !(cmd->flags & CMD_NO_AUTH)) {
|
||||||
@ -1777,7 +1777,7 @@ int ACLUserCheckKeyPerm(user *u, const char *key, int keylen, int flags) {
|
|||||||
* granted in addition to the access required by the command. Returns 1
|
* granted in addition to the access required by the command. Returns 1
|
||||||
* if the user has access or 0 otherwise.
|
* if the user has access or 0 otherwise.
|
||||||
*/
|
*/
|
||||||
int ACLUserCheckCmdWithUnrestrictedKeyAccess(user *u, struct redisCommand *cmd, robj **argv, int argc, int flags) {
|
int ACLUserCheckCmdWithUnrestrictedKeyAccess(user *u, struct redictCommand *cmd, robj **argv, int argc, int flags) {
|
||||||
listIter li;
|
listIter li;
|
||||||
listNode *ln;
|
listNode *ln;
|
||||||
int local_idxptr;
|
int local_idxptr;
|
||||||
@ -1836,7 +1836,7 @@ int ACLUserCheckChannelPerm(user *u, sds channel, int is_pattern) {
|
|||||||
* If the command fails an ACL check, idxptr will be to set to the first argv entry that
|
* If the command fails an ACL check, idxptr will be to set to the first argv entry that
|
||||||
* causes the failure, either 0 if the command itself fails or the idx of the key/channel
|
* causes the failure, either 0 if the command itself fails or the idx of the key/channel
|
||||||
* that causes the failure */
|
* that causes the failure */
|
||||||
int ACLCheckAllUserCommandPerm(user *u, struct redisCommand *cmd, robj **argv, int argc, int *idxptr) {
|
int ACLCheckAllUserCommandPerm(user *u, struct redictCommand *cmd, robj **argv, int argc, int *idxptr) {
|
||||||
listIter li;
|
listIter li;
|
||||||
listNode *ln;
|
listNode *ln;
|
||||||
|
|
||||||
@ -2732,7 +2732,7 @@ void addACLLogEntry(client *c, int reason, int context, int argpos, sds username
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sds getAclErrorMessage(int acl_res, user *user, struct redisCommand *cmd, sds errored_val, int verbose) {
|
sds getAclErrorMessage(int acl_res, user *user, struct redictCommand *cmd, sds errored_val, int verbose) {
|
||||||
switch (acl_res) {
|
switch (acl_res) {
|
||||||
case ACL_DENIED_CMD:
|
case ACL_DENIED_CMD:
|
||||||
return sdscatfmt(sdsempty(), "User %S has no permissions to run "
|
return sdscatfmt(sdsempty(), "User %S has no permissions to run "
|
||||||
@ -2765,7 +2765,7 @@ void aclCatWithFlags(client *c, dict *commands, uint64_t cflag, int *arraylen) {
|
|||||||
dictIterator *di = dictGetIterator(commands);
|
dictIterator *di = dictGetIterator(commands);
|
||||||
|
|
||||||
while ((de = dictNext(di)) != NULL) {
|
while ((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *cmd = dictGetVal(de);
|
struct redictCommand *cmd = dictGetVal(de);
|
||||||
if (cmd->flags & CMD_MODULE) continue;
|
if (cmd->flags & CMD_MODULE) continue;
|
||||||
if (cmd->acl_categories & cflag) {
|
if (cmd->acl_categories & cflag) {
|
||||||
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
||||||
@ -3105,7 +3105,7 @@ void aclCommand(client *c) {
|
|||||||
addReplyLongLong(c, le->ctime);
|
addReplyLongLong(c, le->ctime);
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(sub,"dryrun") && c->argc >= 4) {
|
} else if (!strcasecmp(sub,"dryrun") && c->argc >= 4) {
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
user *u = ACLGetUserByName(c->argv[2]->ptr,sdslen(c->argv[2]->ptr));
|
user *u = ACLGetUserByName(c->argv[2]->ptr,sdslen(c->argv[2]->ptr));
|
||||||
if (u == NULL) {
|
if (u == NULL) {
|
||||||
addReplyErrorFormat(c, "User '%s' not found", (char *)c->argv[2]->ptr);
|
addReplyErrorFormat(c, "User '%s' not found", (char *)c->argv[2]->ptr);
|
||||||
@ -3169,7 +3169,7 @@ NULL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addReplyCommandCategories(client *c, struct redisCommand *cmd) {
|
void addReplyCommandCategories(client *c, struct redictCommand *cmd) {
|
||||||
int flagcount = 0;
|
int flagcount = 0;
|
||||||
void *flaglen = addReplyDeferredLen(c);
|
void *flaglen = addReplyDeferredLen(c);
|
||||||
for (int j = 0; ACLCommandCategories[j].flag != 0; j++) {
|
for (int j = 0; ACLCommandCategories[j].flag != 0; j++) {
|
||||||
|
@ -1459,7 +1459,7 @@ int loadSingleAppendOnlyFile(char *filename) {
|
|||||||
robj **argv;
|
robj **argv;
|
||||||
char buf[AOF_ANNOTATION_LINE_MAX_LEN];
|
char buf[AOF_ANNOTATION_LINE_MAX_LEN];
|
||||||
sds argsds;
|
sds argsds;
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
|
|
||||||
/* Serve the clients from time to time */
|
/* Serve the clients from time to time */
|
||||||
if (!(loops++ % 1024)) {
|
if (!(loops++ % 1024)) {
|
||||||
|
@ -47,6 +47,6 @@ struct commandDocs {
|
|||||||
char *params; /* A string describing the syntax of the command arguments. */
|
char *params; /* A string describing the syntax of the command arguments. */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct commandDocs redisCommandTable[];
|
extern struct commandDocs redictCommandTable[];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -968,7 +968,7 @@ void clusterCommand(client *c) {
|
|||||||
*
|
*
|
||||||
* CLUSTER_REDIR_DOWN_STATE and CLUSTER_REDIR_DOWN_RO_STATE if the cluster is
|
* CLUSTER_REDIR_DOWN_STATE and CLUSTER_REDIR_DOWN_RO_STATE if the cluster is
|
||||||
* down but the user attempts to execute a command that addresses one or more keys. */
|
* down but the user attempts to execute a command that addresses one or more keys. */
|
||||||
clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *error_code) {
|
clusterNode *getNodeByQuery(client *c, struct redictCommand *cmd, robj **argv, int argc, int *hashslot, int *error_code) {
|
||||||
clusterNode *myself = getMyClusterNode();
|
clusterNode *myself = getMyClusterNode();
|
||||||
clusterNode *n = NULL;
|
clusterNode *n = NULL;
|
||||||
robj *firstkey = NULL;
|
robj *firstkey = NULL;
|
||||||
@ -1015,7 +1015,7 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
|
|||||||
/* Check that all the keys are in the same hash slot, and obtain this
|
/* Check that all the keys are in the same hash slot, and obtain this
|
||||||
* slot and the node associated. */
|
* slot and the node associated. */
|
||||||
for (i = 0; i < ms->count; i++) {
|
for (i = 0; i < ms->count; i++) {
|
||||||
struct redisCommand *mcmd;
|
struct redictCommand *mcmd;
|
||||||
robj **margv;
|
robj **margv;
|
||||||
int margc, numkeys, j;
|
int margc, numkeys, j;
|
||||||
keyReference *keyindex;
|
keyReference *keyindex;
|
||||||
|
@ -111,7 +111,7 @@ long long clusterNodeReplOffset(clusterNode *node);
|
|||||||
clusterNode *clusterLookupNode(const char *name, int length);
|
clusterNode *clusterLookupNode(const char *name, int length);
|
||||||
|
|
||||||
/* functions with shared implementations */
|
/* functions with shared implementations */
|
||||||
clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
|
clusterNode *getNodeByQuery(client *c, struct redictCommand *cmd, robj **argv, int argc, int *hashslot, int *ask);
|
||||||
int clusterRedirectBlockedClientIfNeeded(client *c);
|
int clusterRedirectBlockedClientIfNeeded(client *c);
|
||||||
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code);
|
void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_code);
|
||||||
void migrateCloseTimedoutSockets(void);
|
void migrateCloseTimedoutSockets(void);
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
#define MAKE_CMD(name,summary,complexity,since,doc_flags,replaced,deprecated,group,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs) name,summary,complexity,since,doc_flags,replaced,deprecated,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs
|
#define MAKE_CMD(name,summary,complexity,since,doc_flags,replaced,deprecated,group,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs) name,summary,complexity,since,doc_flags,replaced,deprecated,group_enum,history,num_history,tips,num_tips,function,arity,flags,acl,key_specs,key_specs_num,get_keys,numargs
|
||||||
#define MAKE_ARG(name,type,key_spec_index,token,summary,since,flags,numsubargs,deprecated_since) name,type,key_spec_index,token,summary,since,flags,deprecated_since,numsubargs
|
#define MAKE_ARG(name,type,key_spec_index,token,summary,since,flags,numsubargs,deprecated_since) name,type,key_spec_index,token,summary,since,flags,deprecated_since,numsubargs
|
||||||
#define COMMAND_STRUCT redisCommand
|
#define COMMAND_STRUCT redictCommand
|
||||||
#define COMMAND_ARG redisCommandArg
|
#define COMMAND_ARG redictCommandArg
|
||||||
|
|
||||||
#ifdef LOG_REQ_RES
|
#ifdef LOG_REQ_RES
|
||||||
#include "commands_with_reply_schema.def"
|
#include "commands_with_reply_schema.def"
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
/* We have fabulous commands from
|
/* We have fabulous commands from
|
||||||
* the fantastic
|
* the fantastic
|
||||||
* Redis Command Table! */
|
* Redict Command Table! */
|
||||||
|
|
||||||
/* Must match redisCommandGroup */
|
/* Must match redictCommandGroup */
|
||||||
const char *COMMAND_GROUP_STR[] = {
|
const char *COMMAND_GROUP_STR[] = {
|
||||||
"generic",
|
"generic",
|
||||||
"string",
|
"string",
|
||||||
@ -10643,7 +10643,7 @@ struct COMMAND_ARG WATCH_Args[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Main command table */
|
/* Main command table */
|
||||||
struct COMMAND_STRUCT redisCommandTable[] = {
|
struct COMMAND_STRUCT redictCommandTable[] = {
|
||||||
/* bitmap */
|
/* bitmap */
|
||||||
{MAKE_CMD("bitcount","Counts the number of set bits (population counting) in a string.","O(N)","2.6.0",CMD_DOC_NONE,NULL,NULL,"bitmap",COMMAND_GROUP_BITMAP,BITCOUNT_History,1,BITCOUNT_Tips,0,bitcountCommand,-2,CMD_READONLY,ACL_CATEGORY_BITMAP,BITCOUNT_Keyspecs,1,NULL,2),.args=BITCOUNT_Args},
|
{MAKE_CMD("bitcount","Counts the number of set bits (population counting) in a string.","O(N)","2.6.0",CMD_DOC_NONE,NULL,NULL,"bitmap",COMMAND_GROUP_BITMAP,BITCOUNT_History,1,BITCOUNT_Tips,0,bitcountCommand,-2,CMD_READONLY,ACL_CATEGORY_BITMAP,BITCOUNT_Keyspecs,1,NULL,2),.args=BITCOUNT_Args},
|
||||||
{MAKE_CMD("bitfield","Performs arbitrary bitfield integer operations on strings.","O(1) for each subcommand specified","3.2.0",CMD_DOC_NONE,NULL,NULL,"bitmap",COMMAND_GROUP_BITMAP,BITFIELD_History,0,BITFIELD_Tips,0,bitfieldCommand,-2,CMD_WRITE|CMD_DENYOOM,ACL_CATEGORY_BITMAP,BITFIELD_Keyspecs,1,bitfieldGetKeys,2),.args=BITFIELD_Args},
|
{MAKE_CMD("bitfield","Performs arbitrary bitfield integer operations on strings.","O(1) for each subcommand specified","3.2.0",CMD_DOC_NONE,NULL,NULL,"bitmap",COMMAND_GROUP_BITMAP,BITFIELD_History,0,BITFIELD_Tips,0,bitfieldCommand,-2,CMD_WRITE|CMD_DENYOOM,ACL_CATEGORY_BITMAP,BITFIELD_Keyspecs,1,bitfieldGetKeys,2),.args=BITFIELD_Args},
|
||||||
|
@ -26,7 +26,7 @@ typedef enum {
|
|||||||
#define CMD_ARG_MULTIPLE_TOKEN (1<<2)
|
#define CMD_ARG_MULTIPLE_TOKEN (1<<2)
|
||||||
|
|
||||||
/* Must be compatible with RedisModuleCommandArg. See moduleCopyCommandArgs. */
|
/* Must be compatible with RedisModuleCommandArg. See moduleCopyCommandArgs. */
|
||||||
typedef struct redisCommandArg {
|
typedef struct redictCommandArg {
|
||||||
const char *name;
|
const char *name;
|
||||||
redisCommandArgType type;
|
redisCommandArgType type;
|
||||||
int key_spec_index;
|
int key_spec_index;
|
||||||
@ -36,7 +36,7 @@ typedef struct redisCommandArg {
|
|||||||
int flags;
|
int flags;
|
||||||
const char *deprecated_since;
|
const char *deprecated_since;
|
||||||
int num_args;
|
int num_args;
|
||||||
struct redisCommandArg *subargs;
|
struct redictCommandArg *subargs;
|
||||||
const char *display_text;
|
const char *display_text;
|
||||||
} redisCommandArg;
|
} redisCommandArg;
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ void loadServerConfigFromString(char *config) {
|
|||||||
if (!strcasecmp(argv[0],"include") && argc == 2) {
|
if (!strcasecmp(argv[0],"include") && argc == 2) {
|
||||||
loadServerConfig(argv[1], 0, NULL);
|
loadServerConfig(argv[1], 0, NULL);
|
||||||
} else if (!strcasecmp(argv[0],"rename-command") && argc == 3) {
|
} else if (!strcasecmp(argv[0],"rename-command") && argc == 3) {
|
||||||
struct redisCommand *cmd = lookupCommandBySds(argv[1]);
|
struct redictCommand *cmd = lookupCommandBySds(argv[1]);
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
if (!cmd) {
|
if (!cmd) {
|
||||||
|
50
src/db.c
50
src/db.c
@ -1947,7 +1947,7 @@ keyReference *getKeysPrepareResult(getKeysResult *result, int numkeys) {
|
|||||||
|
|
||||||
/* Returns a bitmask with all the flags found in any of the key specs of the command.
|
/* Returns a bitmask with all the flags found in any of the key specs of the command.
|
||||||
* The 'inv' argument means we'll return a mask with all flags that are missing in at least one spec. */
|
* The 'inv' argument means we'll return a mask with all flags that are missing in at least one spec. */
|
||||||
int64_t getAllKeySpecsFlags(struct redisCommand *cmd, int inv) {
|
int64_t getAllKeySpecsFlags(struct redictCommand *cmd, int inv) {
|
||||||
int64_t flags = 0;
|
int64_t flags = 0;
|
||||||
for (int j = 0; j < cmd->key_specs_num; j++) {
|
for (int j = 0; j < cmd->key_specs_num; j++) {
|
||||||
keySpec *spec = cmd->key_specs + j;
|
keySpec *spec = cmd->key_specs + j;
|
||||||
@ -1963,7 +1963,7 @@ int64_t getAllKeySpecsFlags(struct redisCommand *cmd, int inv) {
|
|||||||
* GET_KEYSPEC_RETURN_PARTIAL: Skips invalid and incomplete keyspecs but returns the keys
|
* GET_KEYSPEC_RETURN_PARTIAL: Skips invalid and incomplete keyspecs but returns the keys
|
||||||
* found in other valid keyspecs.
|
* found in other valid keyspecs.
|
||||||
*/
|
*/
|
||||||
int getKeysUsingKeySpecs(struct redisCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) {
|
int getKeysUsingKeySpecs(struct redictCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) {
|
||||||
int j, i, last, first, step;
|
int j, i, last, first, step;
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
serverAssert(result->numkeys == 0); /* caller should initialize or reset it */
|
serverAssert(result->numkeys == 0); /* caller should initialize or reset it */
|
||||||
@ -2090,7 +2090,7 @@ invalid_spec:
|
|||||||
*
|
*
|
||||||
* 'cmd' must be point to the corresponding entry into the redisCommand
|
* 'cmd' must be point to the corresponding entry into the redisCommand
|
||||||
* table, according to the command name in argv[0]. */
|
* table, according to the command name in argv[0]. */
|
||||||
int getKeysFromCommandWithSpecs(struct redisCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) {
|
int getKeysFromCommandWithSpecs(struct redictCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result) {
|
||||||
/* The command has at least one key-spec not marked as NOT_KEY */
|
/* The command has at least one key-spec not marked as NOT_KEY */
|
||||||
int has_keyspec = (getAllKeySpecsFlags(cmd, 1) & CMD_KEY_NOT_KEY);
|
int has_keyspec = (getAllKeySpecsFlags(cmd, 1) & CMD_KEY_NOT_KEY);
|
||||||
/* The command has at least one key-spec marked as VARIABLE_FLAGS */
|
/* The command has at least one key-spec marked as VARIABLE_FLAGS */
|
||||||
@ -2117,7 +2117,7 @@ int getKeysFromCommandWithSpecs(struct redisCommand *cmd, robj **argv, int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This function returns a sanity check if the command may have keys. */
|
/* This function returns a sanity check if the command may have keys. */
|
||||||
int doesCommandHaveKeys(struct redisCommand *cmd) {
|
int doesCommandHaveKeys(struct redictCommand *cmd) {
|
||||||
return cmd->getkeys_proc || /* has getkeys_proc (non modules) */
|
return cmd->getkeys_proc || /* has getkeys_proc (non modules) */
|
||||||
(cmd->flags & CMD_MODULE_GETKEYS) || /* module with GETKEYS */
|
(cmd->flags & CMD_MODULE_GETKEYS) || /* module with GETKEYS */
|
||||||
(getAllKeySpecsFlags(cmd, 1) & CMD_KEY_NOT_KEY); /* has at least one key-spec not marked as NOT_KEY */
|
(getAllKeySpecsFlags(cmd, 1) & CMD_KEY_NOT_KEY); /* has at least one key-spec not marked as NOT_KEY */
|
||||||
@ -2126,7 +2126,7 @@ int doesCommandHaveKeys(struct redisCommand *cmd) {
|
|||||||
/* A simplified channel spec table that contains all of the redis commands
|
/* A simplified channel spec table that contains all of the redis commands
|
||||||
* and which channels they have and how they are accessed. */
|
* and which channels they have and how they are accessed. */
|
||||||
typedef struct ChannelSpecs {
|
typedef struct ChannelSpecs {
|
||||||
redisCommandProc *proc; /* Command procedure to match against */
|
redictCommandProc *proc; /* Command procedure to match against */
|
||||||
uint64_t flags; /* CMD_CHANNEL_* flags for this command */
|
uint64_t flags; /* CMD_CHANNEL_* flags for this command */
|
||||||
int start; /* The initial position of the first channel */
|
int start; /* The initial position of the first channel */
|
||||||
int count; /* The number of channels, or -1 if all remaining
|
int count; /* The number of channels, or -1 if all remaining
|
||||||
@ -2147,7 +2147,7 @@ ChannelSpecs commands_with_channels[] = {
|
|||||||
|
|
||||||
/* Returns 1 if the command may access any channels matched by the flags
|
/* Returns 1 if the command may access any channels matched by the flags
|
||||||
* argument. */
|
* argument. */
|
||||||
int doesCommandHaveChannelsWithFlags(struct redisCommand *cmd, int flags) {
|
int doesCommandHaveChannelsWithFlags(struct redictCommand *cmd, int flags) {
|
||||||
/* If a module declares get channels, we are just going to assume
|
/* If a module declares get channels, we are just going to assume
|
||||||
* has channels. This API is allowed to return false positives. */
|
* has channels. This API is allowed to return false positives. */
|
||||||
if (cmd->flags & CMD_MODULE_GETCHANNELS) {
|
if (cmd->flags & CMD_MODULE_GETCHANNELS) {
|
||||||
@ -2174,7 +2174,7 @@ int doesCommandHaveChannelsWithFlags(struct redisCommand *cmd, int flags) {
|
|||||||
*
|
*
|
||||||
* 'cmd' must be point to the corresponding entry into the redisCommand
|
* 'cmd' must be point to the corresponding entry into the redisCommand
|
||||||
* table, according to the command name in argv[0]. */
|
* table, according to the command name in argv[0]. */
|
||||||
int getChannelsFromCommand(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int getChannelsFromCommand(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
/* If a module declares get channels, use that. */
|
/* If a module declares get channels, use that. */
|
||||||
if (cmd->flags & CMD_MODULE_GETCHANNELS) {
|
if (cmd->flags & CMD_MODULE_GETCHANNELS) {
|
||||||
@ -2209,7 +2209,7 @@ int getChannelsFromCommand(struct redisCommand *cmd, robj **argv, int argc, getK
|
|||||||
*
|
*
|
||||||
* NOTE: This function does not guarantee populating the flags for
|
* NOTE: This function does not guarantee populating the flags for
|
||||||
* the keys, in order to get flags you should use getKeysUsingKeySpecs. */
|
* the keys, in order to get flags you should use getKeysUsingKeySpecs. */
|
||||||
int getKeysUsingLegacyRangeSpec(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int getKeysUsingLegacyRangeSpec(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
int j, i = 0, last, first, step;
|
int j, i = 0, last, first, step;
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
UNUSED(argv);
|
UNUSED(argv);
|
||||||
@ -2264,7 +2264,7 @@ int getKeysUsingLegacyRangeSpec(struct redisCommand *cmd, robj **argv, int argc,
|
|||||||
*
|
*
|
||||||
* This function uses the command table if a command-specific helper function
|
* This function uses the command table if a command-specific helper function
|
||||||
* is not required, otherwise it calls the command-specific function. */
|
* is not required, otherwise it calls the command-specific function. */
|
||||||
int getKeysFromCommand(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int getKeysFromCommand(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
if (cmd->flags & CMD_MODULE_GETKEYS) {
|
if (cmd->flags & CMD_MODULE_GETKEYS) {
|
||||||
return moduleGetCommandKeysViaAPI(cmd,argv,argc,result);
|
return moduleGetCommandKeysViaAPI(cmd,argv,argc,result);
|
||||||
} else if (cmd->getkeys_proc) {
|
} else if (cmd->getkeys_proc) {
|
||||||
@ -2323,47 +2323,47 @@ int genericGetKeys(int storeKeyOfs, int keyCountOfs, int firstKeyOfs, int keySte
|
|||||||
return result->numkeys;
|
return result->numkeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sintercardGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int sintercardGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
|
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zunionInterDiffStoreGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int zunionInterDiffStoreGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
return genericGetKeys(1, 2, 3, 1, argv, argc, result);
|
return genericGetKeys(1, 2, 3, 1, argv, argc, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zunionInterDiffGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int zunionInterDiffGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
|
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int evalGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int evalGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
return genericGetKeys(0, 2, 3, 1, argv, argc, result);
|
return genericGetKeys(0, 2, 3, 1, argv, argc, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int functionGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int functionGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
return genericGetKeys(0, 2, 3, 1, argv, argc, result);
|
return genericGetKeys(0, 2, 3, 1, argv, argc, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int lmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int lmpopGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
|
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int blmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int blmpopGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
return genericGetKeys(0, 2, 3, 1, argv, argc, result);
|
return genericGetKeys(0, 2, 3, 1, argv, argc, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int zmpopGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
|
return genericGetKeys(0, 1, 2, 1, argv, argc, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bzmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int bzmpopGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
return genericGetKeys(0, 2, 3, 1, argv, argc, result);
|
return genericGetKeys(0, 2, 3, 1, argv, argc, result);
|
||||||
}
|
}
|
||||||
@ -2378,7 +2378,7 @@ int bzmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult
|
|||||||
* implementation to fetch the keys.
|
* implementation to fetch the keys.
|
||||||
*
|
*
|
||||||
* This command declares incomplete keys, so the flags are correctly set for this function */
|
* This command declares incomplete keys, so the flags are correctly set for this function */
|
||||||
int sortROGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int sortROGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
UNUSED(argv);
|
UNUSED(argv);
|
||||||
@ -2400,7 +2400,7 @@ int sortROGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult
|
|||||||
* correctly identify keys in the "STORE" option.
|
* correctly identify keys in the "STORE" option.
|
||||||
*
|
*
|
||||||
* This command declares incomplete keys, so the flags are correctly set for this function */
|
* This command declares incomplete keys, so the flags are correctly set for this function */
|
||||||
int sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int sortGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
int i, j, num, found_store = 0;
|
int i, j, num, found_store = 0;
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
@ -2445,7 +2445,7 @@ int sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This command declares incomplete keys, so the flags are correctly set for this function */
|
/* This command declares incomplete keys, so the flags are correctly set for this function */
|
||||||
int migrateGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int migrateGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
int i, j, num, first;
|
int i, j, num, first;
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
@ -2502,7 +2502,7 @@ int migrateGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResul
|
|||||||
* GEORADIUSBYMEMBER key member radius unit ... options ...
|
* GEORADIUSBYMEMBER key member radius unit ... options ...
|
||||||
*
|
*
|
||||||
* This command has a fully defined keyspec, so returning flags isn't needed. */
|
* This command has a fully defined keyspec, so returning flags isn't needed. */
|
||||||
int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int georadiusGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
int i, num;
|
int i, num;
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
@ -2543,7 +2543,7 @@ int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysRes
|
|||||||
* STREAMS key_1 key_2 ... key_N ID_1 ID_2 ... ID_N
|
* STREAMS key_1 key_2 ... key_N ID_1 ID_2 ... ID_N
|
||||||
*
|
*
|
||||||
* This command has a fully defined keyspec, so returning flags isn't needed. */
|
* This command has a fully defined keyspec, so returning flags isn't needed. */
|
||||||
int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int xreadGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
int i, num = 0;
|
int i, num = 0;
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
@ -2591,7 +2591,7 @@ int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult
|
|||||||
|
|
||||||
/* Helper function to extract keys from the SET command, which may have
|
/* Helper function to extract keys from the SET command, which may have
|
||||||
* a read flag if the GET argument is passed in. */
|
* a read flag if the GET argument is passed in. */
|
||||||
int setGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int setGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
|
|
||||||
@ -2616,7 +2616,7 @@ int setGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *r
|
|||||||
|
|
||||||
/* Helper function to extract keys from the BITFIELD command, which may be
|
/* Helper function to extract keys from the BITFIELD command, which may be
|
||||||
* read-only if the BITFIELD GET subcommand is used. */
|
* read-only if the BITFIELD GET subcommand is used. */
|
||||||
int bitfieldGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int bitfieldGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
keyReference *keys;
|
keyReference *keys;
|
||||||
int readonly = 1;
|
int readonly = 1;
|
||||||
UNUSED(cmd);
|
UNUSED(cmd);
|
||||||
|
@ -465,10 +465,10 @@ void fillCommandCDF(client *c, struct hdr_histogram* histogram) {
|
|||||||
void latencyAllCommandsFillCDF(client *c, dict *commands, int *command_with_data) {
|
void latencyAllCommandsFillCDF(client *c, dict *commands, int *command_with_data) {
|
||||||
dictIterator *di = dictGetSafeIterator(commands);
|
dictIterator *di = dictGetSafeIterator(commands);
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
|
|
||||||
while((de = dictNext(di)) != NULL) {
|
while((de = dictNext(di)) != NULL) {
|
||||||
cmd = (struct redisCommand *) dictGetVal(de);
|
cmd = (struct redictCommand *) dictGetVal(de);
|
||||||
if (cmd->latency_histogram) {
|
if (cmd->latency_histogram) {
|
||||||
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
||||||
fillCommandCDF(c, cmd->latency_histogram);
|
fillCommandCDF(c, cmd->latency_histogram);
|
||||||
@ -488,7 +488,7 @@ void latencySpecificCommandsFillCDF(client *c) {
|
|||||||
void *replylen = addReplyDeferredLen(c);
|
void *replylen = addReplyDeferredLen(c);
|
||||||
int command_with_data = 0;
|
int command_with_data = 0;
|
||||||
for (int j = 2; j < c->argc; j++){
|
for (int j = 2; j < c->argc; j++){
|
||||||
struct redisCommand *cmd = lookupCommandBySds(c->argv[j]->ptr);
|
struct redictCommand *cmd = lookupCommandBySds(c->argv[j]->ptr);
|
||||||
/* If the command does not exist we skip the reply */
|
/* If the command does not exist we skip the reply */
|
||||||
if (cmd == NULL) {
|
if (cmd == NULL) {
|
||||||
continue;
|
continue;
|
||||||
@ -505,7 +505,7 @@ void latencySpecificCommandsFillCDF(client *c) {
|
|||||||
dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict);
|
dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict);
|
||||||
|
|
||||||
while ((de = dictNext(di)) != NULL) {
|
while ((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *sub = dictGetVal(de);
|
struct redictCommand *sub = dictGetVal(de);
|
||||||
if (sub->latency_histogram) {
|
if (sub->latency_histogram) {
|
||||||
addReplyBulkCBuffer(c, sub->fullname, sdslen(sub->fullname));
|
addReplyBulkCBuffer(c, sub->fullname, sdslen(sub->fullname));
|
||||||
fillCommandCDF(c, sub->latency_histogram);
|
fillCommandCDF(c, sub->latency_histogram);
|
||||||
|
52
src/module.c
52
src/module.c
@ -213,12 +213,12 @@ typedef int (*RedisModuleAuthCallback)(RedisModuleCtx *ctx, void *username, void
|
|||||||
typedef void (*RedisModuleDisconnectFunc) (RedisModuleCtx *ctx, struct RedisModuleBlockedClient *bc);
|
typedef void (*RedisModuleDisconnectFunc) (RedisModuleCtx *ctx, struct RedisModuleBlockedClient *bc);
|
||||||
|
|
||||||
/* This struct holds the information about a command registered by a module.*/
|
/* This struct holds the information about a command registered by a module.*/
|
||||||
struct RedisModuleCommand {
|
struct RedictModuleCommand {
|
||||||
struct RedisModule *module;
|
struct RedisModule *module;
|
||||||
RedisModuleCmdFunc func;
|
RedisModuleCmdFunc func;
|
||||||
struct redisCommand *rediscmd;
|
struct redictCommand *rediscmd;
|
||||||
};
|
};
|
||||||
typedef struct RedisModuleCommand RedisModuleCommand;
|
typedef struct RedictModuleCommand RedisModuleCommand;
|
||||||
|
|
||||||
#define REDISMODULE_REPLYFLAG_NONE 0
|
#define REDISMODULE_REPLYFLAG_NONE 0
|
||||||
#define REDISMODULE_REPLYFLAG_TOPARSE (1<<0) /* Protocol must be parsed. */
|
#define REDISMODULE_REPLYFLAG_TOPARSE (1<<0) /* Protocol must be parsed. */
|
||||||
@ -478,7 +478,7 @@ static int moduleValidateCommandInfo(const RedisModuleCommandInfo *info);
|
|||||||
static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api);
|
static int64_t moduleConvertKeySpecsFlags(int64_t flags, int from_api);
|
||||||
static int moduleValidateCommandArgs(RedisModuleCommandArg *args,
|
static int moduleValidateCommandArgs(RedisModuleCommandArg *args,
|
||||||
const RedisModuleCommandInfoVersion *version);
|
const RedisModuleCommandInfoVersion *version);
|
||||||
static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args,
|
static struct redictCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args,
|
||||||
const RedisModuleCommandInfoVersion *version);
|
const RedisModuleCommandInfoVersion *version);
|
||||||
static redisCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error);
|
static redisCommandArgType moduleConvertArgType(RedisModuleCommandArgType type, int *error);
|
||||||
static int moduleConvertArgFlags(int flags);
|
static int moduleConvertArgFlags(int flags);
|
||||||
@ -937,7 +937,7 @@ void RedisModuleCommandDispatcher(client *c) {
|
|||||||
* In order to accomplish its work, the module command is called, flagging
|
* In order to accomplish its work, the module command is called, flagging
|
||||||
* the context in a way that the command can recognize this is a special
|
* the context in a way that the command can recognize this is a special
|
||||||
* "get keys" call by calling RedisModule_IsKeysPositionRequest(ctx). */
|
* "get keys" call by calling RedisModule_IsKeysPositionRequest(ctx). */
|
||||||
int moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int moduleGetCommandKeysViaAPI(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
RedisModuleCommand *cp = cmd->module_cmd;
|
RedisModuleCommand *cp = cmd->module_cmd;
|
||||||
RedisModuleCtx ctx;
|
RedisModuleCtx ctx;
|
||||||
moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_KEYS_POS_REQUEST);
|
moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_KEYS_POS_REQUEST);
|
||||||
@ -957,7 +957,7 @@ int moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc,
|
|||||||
/* This function returns the list of channels, with the same interface as
|
/* This function returns the list of channels, with the same interface as
|
||||||
* moduleGetCommandKeysViaAPI, for modules that declare "getchannels-api"
|
* moduleGetCommandKeysViaAPI, for modules that declare "getchannels-api"
|
||||||
* during registration. Unlike keys, this is the only way to declare channels. */
|
* during registration. Unlike keys, this is the only way to declare channels. */
|
||||||
int moduleGetCommandChannelsViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
int moduleGetCommandChannelsViaAPI(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result) {
|
||||||
RedisModuleCommand *cp = cmd->module_cmd;
|
RedisModuleCommand *cp = cmd->module_cmd;
|
||||||
RedisModuleCtx ctx;
|
RedisModuleCtx ctx;
|
||||||
moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_CHANNELS_POS_REQUEST);
|
moduleCreateContext(&ctx, cp->module, REDISMODULE_CTX_CHANNELS_POS_REQUEST);
|
||||||
@ -1279,7 +1279,7 @@ int RM_CreateCommand(RedisModuleCtx *ctx, const char *name, RedisModuleCmdFunc c
|
|||||||
* Function will take the ownership of both 'declared_name' and 'fullname' SDS.
|
* Function will take the ownership of both 'declared_name' and 'fullname' SDS.
|
||||||
*/
|
*/
|
||||||
RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds declared_name, sds fullname, RedisModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep) {
|
RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds declared_name, sds fullname, RedisModuleCmdFunc cmdfunc, int64_t flags, int firstkey, int lastkey, int keystep) {
|
||||||
struct redisCommand *rediscmd;
|
struct redictCommand *rediscmd;
|
||||||
RedisModuleCommand *cp;
|
RedisModuleCommand *cp;
|
||||||
|
|
||||||
/* Create a command "proxy", which is a structure that is referenced
|
/* Create a command "proxy", which is a structure that is referenced
|
||||||
@ -1330,7 +1330,7 @@ RedisModuleCommand *moduleCreateCommandProxy(struct RedisModule *module, sds dec
|
|||||||
* * The command doesn't belong to the calling module
|
* * The command doesn't belong to the calling module
|
||||||
*/
|
*/
|
||||||
RedisModuleCommand *RM_GetCommand(RedisModuleCtx *ctx, const char *name) {
|
RedisModuleCommand *RM_GetCommand(RedisModuleCtx *ctx, const char *name) {
|
||||||
struct redisCommand *cmd = lookupCommandByCString(name);
|
struct redictCommand *cmd = lookupCommandByCString(name);
|
||||||
|
|
||||||
if (!cmd || !(cmd->flags & CMD_MODULE))
|
if (!cmd || !(cmd->flags & CMD_MODULE))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1377,7 +1377,7 @@ int RM_CreateSubcommand(RedisModuleCommand *parent, const char *name, RedisModul
|
|||||||
if ((flags & CMD_MODULE_NO_CLUSTER) && server.cluster_enabled)
|
if ((flags & CMD_MODULE_NO_CLUSTER) && server.cluster_enabled)
|
||||||
return REDISMODULE_ERR;
|
return REDISMODULE_ERR;
|
||||||
|
|
||||||
struct redisCommand *parent_cmd = parent->rediscmd;
|
struct redictCommand *parent_cmd = parent->rediscmd;
|
||||||
|
|
||||||
if (parent_cmd->parent)
|
if (parent_cmd->parent)
|
||||||
return REDISMODULE_ERR; /* We don't allow more than one level of subcommands */
|
return REDISMODULE_ERR; /* We don't allow more than one level of subcommands */
|
||||||
@ -1428,7 +1428,7 @@ moduleCmdArgAt(const RedisModuleCommandInfoVersion *version,
|
|||||||
|
|
||||||
/* Recursively populate the args structure (setting num_args to the number of
|
/* Recursively populate the args structure (setting num_args to the number of
|
||||||
* subargs) and return the number of args. */
|
* subargs) and return the number of args. */
|
||||||
int populateArgsStructure(struct redisCommandArg *args) {
|
int populateArgsStructure(struct redictCommandArg *args) {
|
||||||
if (!args)
|
if (!args)
|
||||||
return 0;
|
return 0;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -1531,7 +1531,7 @@ int RM_SetCommandACLCategories(RedisModuleCommand *command, const char *aclflags
|
|||||||
if (!command || !command->module || !command->module->onload) return REDISMODULE_ERR;
|
if (!command || !command->module || !command->module->onload) return REDISMODULE_ERR;
|
||||||
int64_t categories_flags = aclflags ? categoryFlagsFromString((char*)aclflags) : 0;
|
int64_t categories_flags = aclflags ? categoryFlagsFromString((char*)aclflags) : 0;
|
||||||
if (categories_flags == -1) return REDISMODULE_ERR;
|
if (categories_flags == -1) return REDISMODULE_ERR;
|
||||||
struct redisCommand *rcmd = command->rediscmd;
|
struct redictCommand *rcmd = command->rediscmd;
|
||||||
rcmd->acl_categories = categories_flags; /* ACL categories flags for module command */
|
rcmd->acl_categories = categories_flags; /* ACL categories flags for module command */
|
||||||
command->module->num_commands_with_acl_categories++;
|
command->module->num_commands_with_acl_categories++;
|
||||||
return REDISMODULE_OK;
|
return REDISMODULE_OK;
|
||||||
@ -1844,7 +1844,7 @@ int RM_SetCommandInfo(RedisModuleCommand *command, const RedisModuleCommandInfo
|
|||||||
return REDISMODULE_ERR;
|
return REDISMODULE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct redisCommand *cmd = command->rediscmd;
|
struct redictCommand *cmd = command->rediscmd;
|
||||||
|
|
||||||
/* Check if any info has already been set. Overwriting info involves freeing
|
/* Check if any info has already been set. Overwriting info involves freeing
|
||||||
* the old info, which is not implemented. */
|
* the old info, which is not implemented. */
|
||||||
@ -2175,13 +2175,13 @@ static int moduleValidateCommandArgs(RedisModuleCommandArg *args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Converts an array of RedisModuleCommandArg into a freshly allocated array of
|
/* Converts an array of RedisModuleCommandArg into a freshly allocated array of
|
||||||
* struct redisCommandArg. */
|
* struct redictCommandArg. */
|
||||||
static struct redisCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args,
|
static struct redictCommandArg *moduleCopyCommandArgs(RedisModuleCommandArg *args,
|
||||||
const RedisModuleCommandInfoVersion *version) {
|
const RedisModuleCommandInfoVersion *version) {
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
while (moduleCmdArgAt(version, args, count)->name) count++;
|
while (moduleCmdArgAt(version, args, count)->name) count++;
|
||||||
serverAssert(count < SIZE_MAX / sizeof(struct redisCommandArg));
|
serverAssert(count < SIZE_MAX / sizeof(struct redictCommandArg));
|
||||||
struct redisCommandArg *realargs = zcalloc((count+1) * sizeof(redisCommandArg));
|
struct redictCommandArg *realargs = zcalloc((count+1) * sizeof(redisCommandArg));
|
||||||
|
|
||||||
for (size_t j = 0; j < count; j++) {
|
for (size_t j = 0; j < count; j++) {
|
||||||
RedisModuleCommandArg *arg = moduleCmdArgAt(version, args, j);
|
RedisModuleCommandArg *arg = moduleCmdArgAt(version, args, j);
|
||||||
@ -2234,7 +2234,7 @@ void *moduleGetHandleByName(char *modulename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Returns 1 if `cmd` is a command of the module `modulename`. 0 otherwise. */
|
/* Returns 1 if `cmd` is a command of the module `modulename`. 0 otherwise. */
|
||||||
int moduleIsModuleCommand(void *module_handle, struct redisCommand *cmd) {
|
int moduleIsModuleCommand(void *module_handle, struct redictCommand *cmd) {
|
||||||
if (cmd->proc != RedisModuleCommandDispatcher)
|
if (cmd->proc != RedisModuleCommandDispatcher)
|
||||||
return 0;
|
return 0;
|
||||||
if (module_handle == NULL)
|
if (module_handle == NULL)
|
||||||
@ -3556,7 +3556,7 @@ int RM_ReplyWithLongDouble(RedisModuleCtx *ctx, long double ld) {
|
|||||||
* The command returns REDISMODULE_ERR if the format specifiers are invalid
|
* The command returns REDISMODULE_ERR if the format specifiers are invalid
|
||||||
* or the command name does not belong to a known command. */
|
* or the command name does not belong to a known command. */
|
||||||
int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) {
|
int RM_Replicate(RedisModuleCtx *ctx, const char *cmdname, const char *fmt, ...) {
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
robj **argv = NULL;
|
robj **argv = NULL;
|
||||||
int argc = 0, flags = 0, j;
|
int argc = 0, flags = 0, j;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -6751,7 +6751,7 @@ const char *moduleTypeModuleName(moduleType *mt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return the module name from a module command */
|
/* Return the module name from a module command */
|
||||||
const char *moduleNameFromCommand(struct redisCommand *cmd) {
|
const char *moduleNameFromCommand(struct redictCommand *cmd) {
|
||||||
serverAssert(cmd->proc == RedisModuleCommandDispatcher);
|
serverAssert(cmd->proc == RedisModuleCommandDispatcher);
|
||||||
|
|
||||||
RedisModuleCommand *cp = cmd->module_cmd;
|
RedisModuleCommand *cp = cmd->module_cmd;
|
||||||
@ -7506,7 +7506,7 @@ int RM_GetDbIdFromDigest(RedisModuleDigest *dig) {
|
|||||||
* handling is performed by Redis itself. */
|
* handling is performed by Redis itself. */
|
||||||
void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) {
|
void RM_EmitAOF(RedisModuleIO *io, const char *cmdname, const char *fmt, ...) {
|
||||||
if (io->error) return;
|
if (io->error) return;
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
robj **argv = NULL;
|
robj **argv = NULL;
|
||||||
int argc = 0, flags = 0, j;
|
int argc = 0, flags = 0, j;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -9700,7 +9700,7 @@ RedisModuleUser *RM_GetModuleUserFromUserName(RedisModuleString *name) {
|
|||||||
*/
|
*/
|
||||||
int RM_ACLCheckCommandPermissions(RedisModuleUser *user, RedisModuleString **argv, int argc) {
|
int RM_ACLCheckCommandPermissions(RedisModuleUser *user, RedisModuleString **argv, int argc) {
|
||||||
int keyidxptr;
|
int keyidxptr;
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
|
|
||||||
/* Find command */
|
/* Find command */
|
||||||
if ((cmd = lookupCommand(argv, argc)) == NULL) {
|
if ((cmd = lookupCommand(argv, argc)) == NULL) {
|
||||||
@ -12103,7 +12103,7 @@ void moduleFreeModuleStructure(struct RedisModule *module) {
|
|||||||
zfree(module);
|
zfree(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
void moduleFreeArgs(struct redisCommandArg *args, int num_args) {
|
void moduleFreeArgs(struct redictCommandArg *args, int num_args) {
|
||||||
for (int j = 0; j < num_args; j++) {
|
for (int j = 0; j < num_args; j++) {
|
||||||
zfree((char *)args[j].name);
|
zfree((char *)args[j].name);
|
||||||
zfree((char *)args[j].token);
|
zfree((char *)args[j].token);
|
||||||
@ -12125,7 +12125,7 @@ void moduleFreeArgs(struct redisCommandArg *args, int num_args) {
|
|||||||
* Note that caller needs to handle the deletion of the command table dict,
|
* Note that caller needs to handle the deletion of the command table dict,
|
||||||
* and after that needs to free the command->fullname and the command itself.
|
* and after that needs to free the command->fullname and the command itself.
|
||||||
*/
|
*/
|
||||||
int moduleFreeCommand(struct RedisModule *module, struct redisCommand *cmd) {
|
int moduleFreeCommand(struct RedisModule *module, struct redictCommand *cmd) {
|
||||||
if (cmd->proc != RedisModuleCommandDispatcher)
|
if (cmd->proc != RedisModuleCommandDispatcher)
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
|
|
||||||
@ -12164,7 +12164,7 @@ int moduleFreeCommand(struct RedisModule *module, struct redisCommand *cmd) {
|
|||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict);
|
dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict);
|
||||||
while ((de = dictNext(di)) != NULL) {
|
while ((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *sub = dictGetVal(de);
|
struct redictCommand *sub = dictGetVal(de);
|
||||||
if (moduleFreeCommand(module, sub) != C_OK) continue;
|
if (moduleFreeCommand(module, sub) != C_OK) continue;
|
||||||
|
|
||||||
serverAssert(dictDelete(cmd->subcommands_dict, sub->declared_name) == DICT_OK);
|
serverAssert(dictDelete(cmd->subcommands_dict, sub->declared_name) == DICT_OK);
|
||||||
@ -12184,7 +12184,7 @@ void moduleUnregisterCommands(struct RedisModule *module) {
|
|||||||
dictIterator *di = dictGetSafeIterator(server.commands);
|
dictIterator *di = dictGetSafeIterator(server.commands);
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
while ((de = dictNext(di)) != NULL) {
|
while ((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *cmd = dictGetVal(de);
|
struct redictCommand *cmd = dictGetVal(de);
|
||||||
if (moduleFreeCommand(module, cmd) != C_OK) continue;
|
if (moduleFreeCommand(module, cmd) != C_OK) continue;
|
||||||
|
|
||||||
serverAssert(dictDelete(server.commands, cmd->fullname) == DICT_OK);
|
serverAssert(dictDelete(server.commands, cmd->fullname) == DICT_OK);
|
||||||
@ -13334,7 +13334,7 @@ int RM_ModuleTypeReplaceValue(RedisModuleKey *key, moduleType *mt, void *new_val
|
|||||||
*/
|
*/
|
||||||
int *RM_GetCommandKeysWithFlags(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys, int **out_flags) {
|
int *RM_GetCommandKeysWithFlags(RedisModuleCtx *ctx, RedisModuleString **argv, int argc, int *num_keys, int **out_flags) {
|
||||||
UNUSED(ctx);
|
UNUSED(ctx);
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
int *res = NULL;
|
int *res = NULL;
|
||||||
|
|
||||||
/* Find command */
|
/* Find command */
|
||||||
|
@ -127,7 +127,7 @@ void execCommand(client *c) {
|
|||||||
int j;
|
int j;
|
||||||
robj **orig_argv;
|
robj **orig_argv;
|
||||||
int orig_argc, orig_argv_len;
|
int orig_argc, orig_argv_len;
|
||||||
struct redisCommand *orig_cmd;
|
struct redictCommand *orig_cmd;
|
||||||
|
|
||||||
if (!(c->flags & CLIENT_MULTI)) {
|
if (!(c->flags & CLIENT_MULTI)) {
|
||||||
addReplyError(c,"EXEC without MULTI");
|
addReplyError(c,"EXEC without MULTI");
|
||||||
|
@ -363,7 +363,7 @@ void _addReplyProtoToList(client *c, list *reply_list, const char *s, size_t len
|
|||||||
/* The subscribe / unsubscribe command family has a push as a reply,
|
/* The subscribe / unsubscribe command family has a push as a reply,
|
||||||
* or in other words, it responds with a push (or several of them
|
* or in other words, it responds with a push (or several of them
|
||||||
* depending on how many arguments it got), and has no reply. */
|
* depending on how many arguments it got), and has no reply. */
|
||||||
int cmdHasPushAsReply(struct redisCommand *cmd) {
|
int cmdHasPushAsReply(struct redictCommand *cmd) {
|
||||||
if (!cmd) return 0;
|
if (!cmd) return 0;
|
||||||
return cmd->proc == subscribeCommand || cmd->proc == unsubscribeCommand ||
|
return cmd->proc == subscribeCommand || cmd->proc == unsubscribeCommand ||
|
||||||
cmd->proc == psubscribeCommand || cmd->proc == punsubscribeCommand ||
|
cmd->proc == psubscribeCommand || cmd->proc == punsubscribeCommand ||
|
||||||
@ -2053,7 +2053,7 @@ int handleClientsWithPendingWrites(void) {
|
|||||||
|
|
||||||
/* resetClient prepare the client to process the next command */
|
/* resetClient prepare the client to process the next command */
|
||||||
void resetClient(client *c) {
|
void resetClient(client *c) {
|
||||||
redisCommandProc *prevcmd = c->cmd ? c->cmd->proc : NULL;
|
redictCommandProc *prevcmd = c->cmd ? c->cmd->proc : NULL;
|
||||||
|
|
||||||
freeClientArgv(c);
|
freeClientArgv(c);
|
||||||
c->cur_script = NULL;
|
c->cur_script = NULL;
|
||||||
|
@ -855,10 +855,10 @@ static void cliLegacyInitHelp(dict *groups) {
|
|||||||
sds serverVersion = cliGetServerVersion();
|
sds serverVersion = cliGetServerVersion();
|
||||||
|
|
||||||
/* Scan the commandDocs array and fill in the entries */
|
/* Scan the commandDocs array and fill in the entries */
|
||||||
helpEntriesLen = cliLegacyCountCommands(redisCommandTable, serverVersion);
|
helpEntriesLen = cliLegacyCountCommands(redictCommandTable, serverVersion);
|
||||||
helpEntries = zmalloc(sizeof(helpEntry)*helpEntriesLen);
|
helpEntries = zmalloc(sizeof(helpEntry)*helpEntriesLen);
|
||||||
|
|
||||||
helpEntriesLen = cliLegacyInitCommandHelpEntries(redisCommandTable, groups, serverVersion);
|
helpEntriesLen = cliLegacyInitCommandHelpEntries(redictCommandTable, groups, serverVersion);
|
||||||
cliInitGroupHelpEntries(groups);
|
cliInitGroupHelpEntries(groups);
|
||||||
|
|
||||||
qsort(helpEntries, helpEntriesLen, sizeof(helpEntry), helpEntryCompare);
|
qsort(helpEntries, helpEntriesLen, sizeof(helpEntry), helpEntryCompare);
|
||||||
|
@ -297,7 +297,7 @@ void scriptKill(client *c, int is_eval) {
|
|||||||
addReply(c, shared.ok);
|
addReply(c, shared.ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int scriptVerifyCommandArity(struct redisCommand *cmd, int argc, sds *err) {
|
static int scriptVerifyCommandArity(struct redictCommand *cmd, int argc, sds *err) {
|
||||||
if (!cmd || ((cmd->arity > 0 && cmd->arity != argc) || (argc < -cmd->arity))) {
|
if (!cmd || ((cmd->arity > 0 && cmd->arity != argc) || (argc < -cmd->arity))) {
|
||||||
if (cmd)
|
if (cmd)
|
||||||
*err = sdsnew("Wrong number of args calling Redict command from script");
|
*err = sdsnew("Wrong number of args calling Redict command from script");
|
||||||
@ -519,7 +519,7 @@ void scriptCall(scriptRunCtx *run_ctx, sds *err) {
|
|||||||
/* Process module hooks */
|
/* Process module hooks */
|
||||||
moduleCallCommandFilters(c);
|
moduleCallCommandFilters(c);
|
||||||
|
|
||||||
struct redisCommand *cmd = lookupCommand(c->argv, c->argc);
|
struct redictCommand *cmd = lookupCommand(c->argv, c->argc);
|
||||||
c->cmd = c->lastcmd = c->realcmd = cmd;
|
c->cmd = c->lastcmd = c->realcmd = cmd;
|
||||||
if (scriptVerifyCommandArity(cmd, c->argc, err) != C_OK) {
|
if (scriptVerifyCommandArity(cmd, c->argc, err) != C_OK) {
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -1121,7 +1121,7 @@ static int luaRedisAclCheckCmdPermissionsCommand(lua_State *lua) {
|
|||||||
if (argv == NULL) return luaError(lua);
|
if (argv == NULL) return luaError(lua);
|
||||||
|
|
||||||
/* Find command */
|
/* Find command */
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
if ((cmd = lookupCommand(argv, argc)) == NULL) {
|
if ((cmd = lookupCommand(argv, argc)) == NULL) {
|
||||||
luaPushError(lua, "Invalid command passed to redis.acl_check_cmd()");
|
luaPushError(lua, "Invalid command passed to redis.acl_check_cmd()");
|
||||||
raise_error = 1;
|
raise_error = 1;
|
||||||
|
102
src/server.c
102
src/server.c
@ -67,7 +67,7 @@ double R_Zero, R_PosInf, R_NegInf, R_Nan;
|
|||||||
/*================================= Globals ================================= */
|
/*================================= Globals ================================= */
|
||||||
|
|
||||||
/* Global vars */
|
/* Global vars */
|
||||||
struct redisServer server; /* Server global state */
|
struct redictServer server; /* Server global state */
|
||||||
|
|
||||||
/*============================ Internal prototypes ========================== */
|
/*============================ Internal prototypes ========================== */
|
||||||
|
|
||||||
@ -2884,7 +2884,7 @@ void InitServerLast(void) {
|
|||||||
* because anyway the legacy (first,last,step) spec is to be deprecated
|
* because anyway the legacy (first,last,step) spec is to be deprecated
|
||||||
* and one should use the new key specs scheme.
|
* and one should use the new key specs scheme.
|
||||||
*/
|
*/
|
||||||
void populateCommandLegacyRangeSpec(struct redisCommand *c) {
|
void populateCommandLegacyRangeSpec(struct redictCommand *c) {
|
||||||
memset(&c->legacy_range_key_spec, 0, sizeof(c->legacy_range_key_spec));
|
memset(&c->legacy_range_key_spec, 0, sizeof(c->legacy_range_key_spec));
|
||||||
|
|
||||||
/* Set the movablekeys flag if we have a GETKEYS flag for modules.
|
/* Set the movablekeys flag if we have a GETKEYS flag for modules.
|
||||||
@ -2963,7 +2963,7 @@ sds catSubCommandFullname(const char *parent_name, const char *sub_name) {
|
|||||||
return sdscatfmt(sdsempty(), "%s|%s", parent_name, sub_name);
|
return sdscatfmt(sdsempty(), "%s|%s", parent_name, sub_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void commandAddSubcommand(struct redisCommand *parent, struct redisCommand *subcommand, const char *declared_name) {
|
void commandAddSubcommand(struct redictCommand *parent, struct redictCommand *subcommand, const char *declared_name) {
|
||||||
if (!parent->subcommands_dict)
|
if (!parent->subcommands_dict)
|
||||||
parent->subcommands_dict = dictCreate(&commandTableDictType);
|
parent->subcommands_dict = dictCreate(&commandTableDictType);
|
||||||
|
|
||||||
@ -2975,7 +2975,7 @@ void commandAddSubcommand(struct redisCommand *parent, struct redisCommand *subc
|
|||||||
|
|
||||||
/* Set implicit ACl categories (see comment above the definition of
|
/* Set implicit ACl categories (see comment above the definition of
|
||||||
* struct redisCommand). */
|
* struct redisCommand). */
|
||||||
void setImplicitACLCategories(struct redisCommand *c) {
|
void setImplicitACLCategories(struct redictCommand *c) {
|
||||||
if (c->flags & CMD_WRITE)
|
if (c->flags & CMD_WRITE)
|
||||||
c->acl_categories |= ACL_CATEGORY_WRITE;
|
c->acl_categories |= ACL_CATEGORY_WRITE;
|
||||||
/* Exclude scripting commands from the RO category. */
|
/* Exclude scripting commands from the RO category. */
|
||||||
@ -2999,7 +2999,7 @@ void setImplicitACLCategories(struct redisCommand *c) {
|
|||||||
*
|
*
|
||||||
* On success, the function return C_OK. Otherwise C_ERR is returned and we won't
|
* On success, the function return C_OK. Otherwise C_ERR is returned and we won't
|
||||||
* add this command in the commands dict. */
|
* add this command in the commands dict. */
|
||||||
int populateCommandStructure(struct redisCommand *c) {
|
int populateCommandStructure(struct redictCommand *c) {
|
||||||
/* If the command marks with CMD_SENTINEL, it exists in sentinel. */
|
/* If the command marks with CMD_SENTINEL, it exists in sentinel. */
|
||||||
if (!(c->flags & CMD_SENTINEL) && server.sentinel_mode)
|
if (!(c->flags & CMD_SENTINEL) && server.sentinel_mode)
|
||||||
return C_ERR;
|
return C_ERR;
|
||||||
@ -3025,7 +3025,7 @@ int populateCommandStructure(struct redisCommand *c) {
|
|||||||
/* Handle subcommands */
|
/* Handle subcommands */
|
||||||
if (c->subcommands) {
|
if (c->subcommands) {
|
||||||
for (int j = 0; c->subcommands[j].declared_name; j++) {
|
for (int j = 0; c->subcommands[j].declared_name; j++) {
|
||||||
struct redisCommand *sub = c->subcommands+j;
|
struct redictCommand *sub = c->subcommands+j;
|
||||||
|
|
||||||
sub->fullname = catSubCommandFullname(c->declared_name, sub->declared_name);
|
sub->fullname = catSubCommandFullname(c->declared_name, sub->declared_name);
|
||||||
if (populateCommandStructure(sub) == C_ERR)
|
if (populateCommandStructure(sub) == C_ERR)
|
||||||
@ -3038,16 +3038,16 @@ int populateCommandStructure(struct redisCommand *c) {
|
|||||||
return C_OK;
|
return C_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern struct redisCommand redisCommandTable[];
|
extern struct redictCommand redictCommandTable[];
|
||||||
|
|
||||||
/* Populates the Redict Command Table dict from the static table in commands.c
|
/* Populates the Redict Command Table dict from the static table in commands.c
|
||||||
* which is auto generated from the json files in the commands folder. */
|
* which is auto generated from the json files in the commands folder. */
|
||||||
void populateCommandTable(void) {
|
void populateCommandTable(void) {
|
||||||
int j;
|
int j;
|
||||||
struct redisCommand *c;
|
struct redictCommand *c;
|
||||||
|
|
||||||
for (j = 0;; j++) {
|
for (j = 0;; j++) {
|
||||||
c = redisCommandTable + j;
|
c = redictCommandTable + j;
|
||||||
if (c->declared_name == NULL)
|
if (c->declared_name == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -3066,13 +3066,13 @@ void populateCommandTable(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void resetCommandTableStats(dict* commands) {
|
void resetCommandTableStats(dict* commands) {
|
||||||
struct redisCommand *c;
|
struct redictCommand *c;
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
dictIterator *di;
|
dictIterator *di;
|
||||||
|
|
||||||
di = dictGetSafeIterator(commands);
|
di = dictGetSafeIterator(commands);
|
||||||
while((de = dictNext(di)) != NULL) {
|
while((de = dictNext(di)) != NULL) {
|
||||||
c = (struct redisCommand *) dictGetVal(de);
|
c = (struct redictCommand *) dictGetVal(de);
|
||||||
c->microseconds = 0;
|
c->microseconds = 0;
|
||||||
c->calls = 0;
|
c->calls = 0;
|
||||||
c->rejected_calls = 0;
|
c->rejected_calls = 0;
|
||||||
@ -3134,12 +3134,12 @@ void redisOpArrayFree(redisOpArray *oa) {
|
|||||||
/* ====================== Commands lookup and execution ===================== */
|
/* ====================== Commands lookup and execution ===================== */
|
||||||
|
|
||||||
int isContainerCommandBySds(sds s) {
|
int isContainerCommandBySds(sds s) {
|
||||||
struct redisCommand *base_cmd = dictFetchValue(server.commands, s);
|
struct redictCommand *base_cmd = dictFetchValue(server.commands, s);
|
||||||
int has_subcommands = base_cmd && base_cmd->subcommands_dict;
|
int has_subcommands = base_cmd && base_cmd->subcommands_dict;
|
||||||
return has_subcommands;
|
return has_subcommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct redisCommand *lookupSubcommand(struct redisCommand *container, sds sub_name) {
|
struct redictCommand *lookupSubcommand(struct redictCommand *container, sds sub_name) {
|
||||||
return dictFetchValue(container->subcommands_dict, sub_name);
|
return dictFetchValue(container->subcommands_dict, sub_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3151,8 +3151,8 @@ struct redisCommand *lookupSubcommand(struct redisCommand *container, sds sub_na
|
|||||||
* name (e.g. in COMMAND INFO) rather than to find the command
|
* name (e.g. in COMMAND INFO) rather than to find the command
|
||||||
* a user requested to execute (in processCommand).
|
* a user requested to execute (in processCommand).
|
||||||
*/
|
*/
|
||||||
struct redisCommand *lookupCommandLogic(dict *commands, robj **argv, int argc, int strict) {
|
struct redictCommand *lookupCommandLogic(dict *commands, robj **argv, int argc, int strict) {
|
||||||
struct redisCommand *base_cmd = dictFetchValue(commands, argv[0]->ptr);
|
struct redictCommand *base_cmd = dictFetchValue(commands, argv[0]->ptr);
|
||||||
int has_subcommands = base_cmd && base_cmd->subcommands_dict;
|
int has_subcommands = base_cmd && base_cmd->subcommands_dict;
|
||||||
if (argc == 1 || !has_subcommands) {
|
if (argc == 1 || !has_subcommands) {
|
||||||
if (strict && argc != 1)
|
if (strict && argc != 1)
|
||||||
@ -3167,11 +3167,11 @@ struct redisCommand *lookupCommandLogic(dict *commands, robj **argv, int argc, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct redisCommand *lookupCommand(robj **argv, int argc) {
|
struct redictCommand *lookupCommand(robj **argv, int argc) {
|
||||||
return lookupCommandLogic(server.commands,argv,argc,0);
|
return lookupCommandLogic(server.commands,argv,argc,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct redisCommand *lookupCommandBySdsLogic(dict *commands, sds s) {
|
struct redictCommand *lookupCommandBySdsLogic(dict *commands, sds s) {
|
||||||
int argc, j;
|
int argc, j;
|
||||||
sds *strings = sdssplitlen(s,sdslen(s),"|",1,&argc);
|
sds *strings = sdssplitlen(s,sdslen(s),"|",1,&argc);
|
||||||
if (strings == NULL)
|
if (strings == NULL)
|
||||||
@ -3190,17 +3190,17 @@ struct redisCommand *lookupCommandBySdsLogic(dict *commands, sds s) {
|
|||||||
argv[j] = &objects[j];
|
argv[j] = &objects[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
struct redisCommand *cmd = lookupCommandLogic(commands,argv,argc,1);
|
struct redictCommand *cmd = lookupCommandLogic(commands,argv,argc,1);
|
||||||
sdsfreesplitres(strings,argc);
|
sdsfreesplitres(strings,argc);
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct redisCommand *lookupCommandBySds(sds s) {
|
struct redictCommand *lookupCommandBySds(sds s) {
|
||||||
return lookupCommandBySdsLogic(server.commands,s);
|
return lookupCommandBySdsLogic(server.commands,s);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct redisCommand *lookupCommandByCStringLogic(dict *commands, const char *s) {
|
struct redictCommand *lookupCommandByCStringLogic(dict *commands, const char *s) {
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
sds name = sdsnew(s);
|
sds name = sdsnew(s);
|
||||||
|
|
||||||
cmd = lookupCommandBySdsLogic(commands,name);
|
cmd = lookupCommandBySdsLogic(commands,name);
|
||||||
@ -3208,7 +3208,7 @@ struct redisCommand *lookupCommandByCStringLogic(dict *commands, const char *s)
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct redisCommand *lookupCommandByCString(const char *s) {
|
struct redictCommand *lookupCommandByCString(const char *s) {
|
||||||
return lookupCommandByCStringLogic(server.commands,s);
|
return lookupCommandByCStringLogic(server.commands,s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3219,8 +3219,8 @@ struct redisCommand *lookupCommandByCString(const char *s) {
|
|||||||
* This is used by functions rewriting the argument vector such as
|
* This is used by functions rewriting the argument vector such as
|
||||||
* rewriteClientCommandVector() in order to set client->cmd pointer
|
* rewriteClientCommandVector() in order to set client->cmd pointer
|
||||||
* correctly even if the command was renamed. */
|
* correctly even if the command was renamed. */
|
||||||
struct redisCommand *lookupCommandOrOriginal(robj **argv ,int argc) {
|
struct redictCommand *lookupCommandOrOriginal(robj **argv ,int argc) {
|
||||||
struct redisCommand *cmd = lookupCommandLogic(server.commands, argv, argc, 0);
|
struct redictCommand *cmd = lookupCommandLogic(server.commands, argv, argc, 0);
|
||||||
|
|
||||||
if (!cmd) cmd = lookupCommandLogic(server.orig_commands, argv, argc, 0);
|
if (!cmd) cmd = lookupCommandLogic(server.orig_commands, argv, argc, 0);
|
||||||
return cmd;
|
return cmd;
|
||||||
@ -3330,7 +3330,7 @@ void preventCommandReplication(client *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Log the last command a client executed into the slowlog. */
|
/* Log the last command a client executed into the slowlog. */
|
||||||
void slowlogPushCurrentCommand(client *c, struct redisCommand *cmd, ustime_t duration) {
|
void slowlogPushCurrentCommand(client *c, struct redictCommand *cmd, ustime_t duration) {
|
||||||
/* Some commands may contain sensitive data that should not be available in the slowlog. */
|
/* Some commands may contain sensitive data that should not be available in the slowlog. */
|
||||||
if (cmd->flags & CMD_SKIP_SLOWLOG)
|
if (cmd->flags & CMD_SKIP_SLOWLOG)
|
||||||
return;
|
return;
|
||||||
@ -3437,7 +3437,7 @@ void postExecutionUnitOperations(void) {
|
|||||||
* twice, its possible to pass a NULL cmd value to indicate that the error was counted elsewhere.
|
* twice, its possible to pass a NULL cmd value to indicate that the error was counted elsewhere.
|
||||||
*
|
*
|
||||||
* The function returns true if stats was updated and false if not. */
|
* The function returns true if stats was updated and false if not. */
|
||||||
int incrCommandStatsOnError(struct redisCommand *cmd, int flags) {
|
int incrCommandStatsOnError(struct redictCommand *cmd, int flags) {
|
||||||
/* hold the prev error count captured on the last command execution */
|
/* hold the prev error count captured on the last command execution */
|
||||||
static long long prev_err_count = 0;
|
static long long prev_err_count = 0;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
@ -3494,7 +3494,7 @@ int incrCommandStatsOnError(struct redisCommand *cmd, int flags) {
|
|||||||
void call(client *c, int flags) {
|
void call(client *c, int flags) {
|
||||||
long long dirty;
|
long long dirty;
|
||||||
uint64_t client_old_flags = c->flags;
|
uint64_t client_old_flags = c->flags;
|
||||||
struct redisCommand *real_cmd = c->realcmd;
|
struct redictCommand *real_cmd = c->realcmd;
|
||||||
client *prev_client = server.executing_client;
|
client *prev_client = server.executing_client;
|
||||||
server.executing_client = c;
|
server.executing_client = c;
|
||||||
|
|
||||||
@ -4224,11 +4224,11 @@ void incrementErrorCount(const char *fullerr, size_t namelen) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct redisError *error = zmalloc(sizeof(*error));
|
struct redictError *error = zmalloc(sizeof(*error));
|
||||||
error->count = 1;
|
error->count = 1;
|
||||||
raxInsert(server.errors,(unsigned char*)fullerr,namelen,error,NULL);
|
raxInsert(server.errors,(unsigned char*)fullerr,namelen,error,NULL);
|
||||||
} else {
|
} else {
|
||||||
struct redisError *error = result;
|
struct redictError *error = result;
|
||||||
error->count++;
|
error->count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4618,7 +4618,7 @@ void addReplyCommandFlags(client *c, uint64_t flags, replyFlagNames *replyFlags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addReplyFlagsForCommand(client *c, struct redisCommand *cmd) {
|
void addReplyFlagsForCommand(client *c, struct redictCommand *cmd) {
|
||||||
replyFlagNames flagNames[] = {
|
replyFlagNames flagNames[] = {
|
||||||
{CMD_WRITE, "write"},
|
{CMD_WRITE, "write"},
|
||||||
{CMD_READONLY, "readonly"},
|
{CMD_READONLY, "readonly"},
|
||||||
@ -4650,7 +4650,7 @@ void addReplyFlagsForCommand(client *c, struct redisCommand *cmd) {
|
|||||||
addReplyCommandFlags(c, cmd->flags, flagNames);
|
addReplyCommandFlags(c, cmd->flags, flagNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addReplyDocFlagsForCommand(client *c, struct redisCommand *cmd) {
|
void addReplyDocFlagsForCommand(client *c, struct redictCommand *cmd) {
|
||||||
replyFlagNames docFlagNames[] = {
|
replyFlagNames docFlagNames[] = {
|
||||||
{CMD_DOC_DEPRECATED, "deprecated"},
|
{CMD_DOC_DEPRECATED, "deprecated"},
|
||||||
{CMD_DOC_SYSCMD, "syscmd"},
|
{CMD_DOC_SYSCMD, "syscmd"},
|
||||||
@ -4700,7 +4700,7 @@ void addReplyFlagsForArg(client *c, uint64_t flags) {
|
|||||||
addReplyCommandFlags(c, flags, argFlagNames);
|
addReplyCommandFlags(c, flags, argFlagNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addReplyCommandArgList(client *c, struct redisCommandArg *args, int num_args) {
|
void addReplyCommandArgList(client *c, struct redictCommandArg *args, int num_args) {
|
||||||
addReplyArrayLen(c, num_args);
|
addReplyArrayLen(c, num_args);
|
||||||
for (int j = 0; j<num_args; j++) {
|
for (int j = 0; j<num_args; j++) {
|
||||||
/* Count our reply len so we don't have to use deferred reply. */
|
/* Count our reply len so we don't have to use deferred reply. */
|
||||||
@ -4796,7 +4796,7 @@ void addReplyJson(client *c, struct jsonObject *rs) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void addReplyCommandHistory(client *c, struct redisCommand *cmd) {
|
void addReplyCommandHistory(client *c, struct redictCommand *cmd) {
|
||||||
addReplySetLen(c, cmd->num_history);
|
addReplySetLen(c, cmd->num_history);
|
||||||
for (int j = 0; j<cmd->num_history; j++) {
|
for (int j = 0; j<cmd->num_history; j++) {
|
||||||
addReplyArrayLen(c, 2);
|
addReplyArrayLen(c, 2);
|
||||||
@ -4805,14 +4805,14 @@ void addReplyCommandHistory(client *c, struct redisCommand *cmd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addReplyCommandTips(client *c, struct redisCommand *cmd) {
|
void addReplyCommandTips(client *c, struct redictCommand *cmd) {
|
||||||
addReplySetLen(c, cmd->num_tips);
|
addReplySetLen(c, cmd->num_tips);
|
||||||
for (int j = 0; j<cmd->num_tips; j++) {
|
for (int j = 0; j<cmd->num_tips; j++) {
|
||||||
addReplyBulkCString(c, cmd->tips[j]);
|
addReplyBulkCString(c, cmd->tips[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addReplyCommandKeySpecs(client *c, struct redisCommand *cmd) {
|
void addReplyCommandKeySpecs(client *c, struct redictCommand *cmd) {
|
||||||
addReplySetLen(c, cmd->key_specs_num);
|
addReplySetLen(c, cmd->key_specs_num);
|
||||||
for (int i = 0; i < cmd->key_specs_num; i++) {
|
for (int i = 0; i < cmd->key_specs_num; i++) {
|
||||||
int maplen = 3;
|
int maplen = 3;
|
||||||
@ -4909,7 +4909,7 @@ void addReplyCommandKeySpecs(client *c, struct redisCommand *cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Reply with an array of sub-command using the provided reply callback. */
|
/* Reply with an array of sub-command using the provided reply callback. */
|
||||||
void addReplyCommandSubCommands(client *c, struct redisCommand *cmd, void (*reply_function)(client*, struct redisCommand*), int use_map) {
|
void addReplyCommandSubCommands(client *c, struct redictCommand *cmd, void (*reply_function)(client*, struct redictCommand*), int use_map) {
|
||||||
if (!cmd->subcommands_dict) {
|
if (!cmd->subcommands_dict) {
|
||||||
addReplySetLen(c, 0);
|
addReplySetLen(c, 0);
|
||||||
return;
|
return;
|
||||||
@ -4922,7 +4922,7 @@ void addReplyCommandSubCommands(client *c, struct redisCommand *cmd, void (*repl
|
|||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict);
|
dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict);
|
||||||
while((de = dictNext(di)) != NULL) {
|
while((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *sub = (struct redisCommand *)dictGetVal(de);
|
struct redictCommand *sub = (struct redictCommand *)dictGetVal(de);
|
||||||
if (use_map)
|
if (use_map)
|
||||||
addReplyBulkCBuffer(c, sub->fullname, sdslen(sub->fullname));
|
addReplyBulkCBuffer(c, sub->fullname, sdslen(sub->fullname));
|
||||||
reply_function(c, sub);
|
reply_function(c, sub);
|
||||||
@ -4931,7 +4931,7 @@ void addReplyCommandSubCommands(client *c, struct redisCommand *cmd, void (*repl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output the representation of a Redict command. Used by the COMMAND command and COMMAND INFO. */
|
/* Output the representation of a Redict command. Used by the COMMAND command and COMMAND INFO. */
|
||||||
void addReplyCommandInfo(client *c, struct redisCommand *cmd) {
|
void addReplyCommandInfo(client *c, struct redictCommand *cmd) {
|
||||||
if (!cmd) {
|
if (!cmd) {
|
||||||
addReplyNull(c);
|
addReplyNull(c);
|
||||||
} else {
|
} else {
|
||||||
@ -4959,7 +4959,7 @@ void addReplyCommandInfo(client *c, struct redisCommand *cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Output the representation of a Redict command. Used by the COMMAND DOCS. */
|
/* Output the representation of a Redict command. Used by the COMMAND DOCS. */
|
||||||
void addReplyCommandDocs(client *c, struct redisCommand *cmd) {
|
void addReplyCommandDocs(client *c, struct redictCommand *cmd) {
|
||||||
/* Count our reply len so we don't have to use deferred reply. */
|
/* Count our reply len so we don't have to use deferred reply. */
|
||||||
long maplen = 1;
|
long maplen = 1;
|
||||||
if (cmd->summary) maplen++;
|
if (cmd->summary) maplen++;
|
||||||
@ -5032,7 +5032,7 @@ void addReplyCommandDocs(client *c, struct redisCommand *cmd) {
|
|||||||
|
|
||||||
/* Helper for COMMAND GETKEYS and GETKEYSANDFLAGS */
|
/* Helper for COMMAND GETKEYS and GETKEYSANDFLAGS */
|
||||||
void getKeysSubcommandImpl(client *c, int with_flags) {
|
void getKeysSubcommandImpl(client *c, int with_flags) {
|
||||||
struct redisCommand *cmd = lookupCommand(c->argv+2,c->argc-2);
|
struct redictCommand *cmd = lookupCommand(c->argv+2,c->argc-2);
|
||||||
getKeysResult result = GETKEYS_RESULT_INIT;
|
getKeysResult result = GETKEYS_RESULT_INIT;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
@ -5116,7 +5116,7 @@ typedef struct {
|
|||||||
} cache;
|
} cache;
|
||||||
} commandListFilter;
|
} commandListFilter;
|
||||||
|
|
||||||
int shouldFilterFromCommandList(struct redisCommand *cmd, commandListFilter *filter) {
|
int shouldFilterFromCommandList(struct redictCommand *cmd, commandListFilter *filter) {
|
||||||
switch (filter->type) {
|
switch (filter->type) {
|
||||||
case (COMMAND_LIST_FILTER_MODULE):
|
case (COMMAND_LIST_FILTER_MODULE):
|
||||||
if (!filter->cache.valid) {
|
if (!filter->cache.valid) {
|
||||||
@ -5148,7 +5148,7 @@ void commandListWithFilter(client *c, dict *commands, commandListFilter filter,
|
|||||||
dictIterator *di = dictGetIterator(commands);
|
dictIterator *di = dictGetIterator(commands);
|
||||||
|
|
||||||
while ((de = dictNext(di)) != NULL) {
|
while ((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *cmd = dictGetVal(de);
|
struct redictCommand *cmd = dictGetVal(de);
|
||||||
if (!shouldFilterFromCommandList(cmd,&filter)) {
|
if (!shouldFilterFromCommandList(cmd,&filter)) {
|
||||||
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
||||||
(*numcmds)++;
|
(*numcmds)++;
|
||||||
@ -5167,7 +5167,7 @@ void commandListWithoutFilter(client *c, dict *commands, int *numcmds) {
|
|||||||
dictIterator *di = dictGetIterator(commands);
|
dictIterator *di = dictGetIterator(commands);
|
||||||
|
|
||||||
while ((de = dictNext(di)) != NULL) {
|
while ((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *cmd = dictGetVal(de);
|
struct redictCommand *cmd = dictGetVal(de);
|
||||||
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
||||||
(*numcmds)++;
|
(*numcmds)++;
|
||||||
|
|
||||||
@ -5251,7 +5251,7 @@ void commandDocsCommand(client *c) {
|
|||||||
addReplyMapLen(c, dictSize(server.commands));
|
addReplyMapLen(c, dictSize(server.commands));
|
||||||
di = dictGetIterator(server.commands);
|
di = dictGetIterator(server.commands);
|
||||||
while ((de = dictNext(di)) != NULL) {
|
while ((de = dictNext(di)) != NULL) {
|
||||||
struct redisCommand *cmd = dictGetVal(de);
|
struct redictCommand *cmd = dictGetVal(de);
|
||||||
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
||||||
addReplyCommandDocs(c, cmd);
|
addReplyCommandDocs(c, cmd);
|
||||||
}
|
}
|
||||||
@ -5261,7 +5261,7 @@ void commandDocsCommand(client *c) {
|
|||||||
int numcmds = 0;
|
int numcmds = 0;
|
||||||
void *replylen = addReplyDeferredLen(c);
|
void *replylen = addReplyDeferredLen(c);
|
||||||
for (i = 2; i < c->argc; i++) {
|
for (i = 2; i < c->argc; i++) {
|
||||||
struct redisCommand *cmd = lookupCommandBySds(c->argv[i]->ptr);
|
struct redictCommand *cmd = lookupCommandBySds(c->argv[i]->ptr);
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
continue;
|
continue;
|
||||||
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
|
||||||
@ -5383,13 +5383,13 @@ const char *getSafeInfoString(const char *s, size_t len, char **tmp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sds genRedisInfoStringCommandStats(sds info, dict *commands) {
|
sds genRedisInfoStringCommandStats(sds info, dict *commands) {
|
||||||
struct redisCommand *c;
|
struct redictCommand *c;
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
dictIterator *di;
|
dictIterator *di;
|
||||||
di = dictGetSafeIterator(commands);
|
di = dictGetSafeIterator(commands);
|
||||||
while((de = dictNext(di)) != NULL) {
|
while((de = dictNext(di)) != NULL) {
|
||||||
char *tmpsafe;
|
char *tmpsafe;
|
||||||
c = (struct redisCommand *) dictGetVal(de);
|
c = (struct redictCommand *) dictGetVal(de);
|
||||||
if (c->calls || c->failed_calls || c->rejected_calls) {
|
if (c->calls || c->failed_calls || c->rejected_calls) {
|
||||||
info = sdscatprintf(info,
|
info = sdscatprintf(info,
|
||||||
"cmdstat_%s:calls=%lld,usec=%lld,usec_per_call=%.2f"
|
"cmdstat_%s:calls=%lld,usec=%lld,usec_per_call=%.2f"
|
||||||
@ -5423,13 +5423,13 @@ sds genRedisInfoStringACLStats(sds info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sds genRedisInfoStringLatencyStats(sds info, dict *commands) {
|
sds genRedisInfoStringLatencyStats(sds info, dict *commands) {
|
||||||
struct redisCommand *c;
|
struct redictCommand *c;
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
dictIterator *di;
|
dictIterator *di;
|
||||||
di = dictGetSafeIterator(commands);
|
di = dictGetSafeIterator(commands);
|
||||||
while((de = dictNext(di)) != NULL) {
|
while((de = dictNext(di)) != NULL) {
|
||||||
char *tmpsafe;
|
char *tmpsafe;
|
||||||
c = (struct redisCommand *) dictGetVal(de);
|
c = (struct redictCommand *) dictGetVal(de);
|
||||||
if (c->latency_histogram) {
|
if (c->latency_histogram) {
|
||||||
info = fillPercentileDistributionLatencies(info,
|
info = fillPercentileDistributionLatencies(info,
|
||||||
getSafeInfoString(c->fullname, sdslen(c->fullname), &tmpsafe),
|
getSafeInfoString(c->fullname, sdslen(c->fullname), &tmpsafe),
|
||||||
@ -6049,10 +6049,10 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
|
|||||||
raxIterator ri;
|
raxIterator ri;
|
||||||
raxStart(&ri,server.errors);
|
raxStart(&ri,server.errors);
|
||||||
raxSeek(&ri,"^",NULL,0);
|
raxSeek(&ri,"^",NULL,0);
|
||||||
struct redisError *e;
|
struct redictError *e;
|
||||||
while(raxNext(&ri)) {
|
while(raxNext(&ri)) {
|
||||||
char *tmpsafe;
|
char *tmpsafe;
|
||||||
e = (struct redisError *) ri.data;
|
e = (struct redictError *) ri.data;
|
||||||
info = sdscatprintf(info,
|
info = sdscatprintf(info,
|
||||||
"errorstat_%.*s:count=%lld\r\n",
|
"errorstat_%.*s:count=%lld\r\n",
|
||||||
(int)ri.key_len, getSafeInfoString((char *) ri.key, ri.key_len, &tmpsafe), e->count);
|
(int)ri.key_len, getSafeInfoString((char *) ri.key, ri.key_len, &tmpsafe), e->count);
|
||||||
|
126
src/server.h
126
src/server.h
@ -717,7 +717,7 @@ struct RedisModuleDigest;
|
|||||||
struct RedisModuleCtx;
|
struct RedisModuleCtx;
|
||||||
struct moduleLoadQueueEntry;
|
struct moduleLoadQueueEntry;
|
||||||
struct RedisModuleKeyOptCtx;
|
struct RedisModuleKeyOptCtx;
|
||||||
struct RedisModuleCommand;
|
struct RedictModuleCommand;
|
||||||
struct clusterState;
|
struct clusterState;
|
||||||
|
|
||||||
/* Each module type implementation should export a set of methods in order
|
/* Each module type implementation should export a set of methods in order
|
||||||
@ -985,7 +985,7 @@ typedef struct multiCmd {
|
|||||||
robj **argv;
|
robj **argv;
|
||||||
int argv_len;
|
int argv_len;
|
||||||
int argc;
|
int argc;
|
||||||
struct redisCommand *cmd;
|
struct redictCommand *cmd;
|
||||||
} multiCmd;
|
} multiCmd;
|
||||||
|
|
||||||
typedef struct multiState {
|
typedef struct multiState {
|
||||||
@ -1155,8 +1155,8 @@ typedef struct client {
|
|||||||
int original_argc; /* Num of arguments of original command if arguments were rewritten. */
|
int original_argc; /* Num of arguments of original command if arguments were rewritten. */
|
||||||
robj **original_argv; /* Arguments of original command if arguments were rewritten. */
|
robj **original_argv; /* Arguments of original command if arguments were rewritten. */
|
||||||
size_t argv_len_sum; /* Sum of lengths of objects in argv list. */
|
size_t argv_len_sum; /* Sum of lengths of objects in argv list. */
|
||||||
struct redisCommand *cmd, *lastcmd; /* Last command executed. */
|
struct redictCommand *cmd, *lastcmd; /* Last command executed. */
|
||||||
struct redisCommand *realcmd; /* The original command that was executed by the client,
|
struct redictCommand *realcmd; /* The original command that was executed by the client,
|
||||||
Used to update error stats in case the c->cmd was modified
|
Used to update error stats in case the c->cmd was modified
|
||||||
during the command invocation (like on GEOADD for example). */
|
during the command invocation (like on GEOADD for example). */
|
||||||
user *user; /* User associated with this connection. If the
|
user *user; /* User associated with this connection. If the
|
||||||
@ -1522,7 +1522,7 @@ typedef enum childInfoType {
|
|||||||
CHILD_INFO_TYPE_MODULE_COW_SIZE
|
CHILD_INFO_TYPE_MODULE_COW_SIZE
|
||||||
} childInfoType;
|
} childInfoType;
|
||||||
|
|
||||||
struct redisServer {
|
struct redictServer {
|
||||||
/* General */
|
/* General */
|
||||||
pid_t pid; /* Main process pid. */
|
pid_t pid; /* Main process pid. */
|
||||||
pthread_t main_thread_id; /* Main thread id */
|
pthread_t main_thread_id; /* Main thread id */
|
||||||
@ -2213,10 +2213,10 @@ typedef enum {
|
|||||||
COMMAND_GROUP_STREAM,
|
COMMAND_GROUP_STREAM,
|
||||||
COMMAND_GROUP_BITMAP,
|
COMMAND_GROUP_BITMAP,
|
||||||
COMMAND_GROUP_MODULE,
|
COMMAND_GROUP_MODULE,
|
||||||
} redisCommandGroup;
|
} redictCommandGroup;
|
||||||
|
|
||||||
typedef void redisCommandProc(client *c);
|
typedef void redictCommandProc(client *c);
|
||||||
typedef int redisGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
typedef int redictGetKeysProc(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
|
|
||||||
/* Redis command structure.
|
/* Redis command structure.
|
||||||
*
|
*
|
||||||
@ -2311,7 +2311,7 @@ typedef int redisGetKeysProc(struct redisCommand *cmd, robj **argv, int argc, ge
|
|||||||
* specific data structures, such as: DEL, RENAME, MOVE, SELECT,
|
* specific data structures, such as: DEL, RENAME, MOVE, SELECT,
|
||||||
* TYPE, EXPIRE*, PEXPIRE*, TTL, PTTL, ...
|
* TYPE, EXPIRE*, PEXPIRE*, TTL, PTTL, ...
|
||||||
*/
|
*/
|
||||||
struct redisCommand {
|
struct redictCommand {
|
||||||
/* Declarative data */
|
/* Declarative data */
|
||||||
const char *declared_name; /* A string representing the command declared_name.
|
const char *declared_name; /* A string representing the command declared_name.
|
||||||
* It is a const char * for native commands and SDS for module commands. */
|
* It is a const char * for native commands and SDS for module commands. */
|
||||||
@ -2321,12 +2321,12 @@ struct redisCommand {
|
|||||||
int doc_flags; /* Flags for documentation (see CMD_DOC_*). */
|
int doc_flags; /* Flags for documentation (see CMD_DOC_*). */
|
||||||
const char *replaced_by; /* In case the command is deprecated, this is the successor command. */
|
const char *replaced_by; /* In case the command is deprecated, this is the successor command. */
|
||||||
const char *deprecated_since; /* In case the command is deprecated, when did it happen? */
|
const char *deprecated_since; /* In case the command is deprecated, when did it happen? */
|
||||||
redisCommandGroup group; /* Command group */
|
redictCommandGroup group; /* Command group */
|
||||||
commandHistory *history; /* History of the command */
|
commandHistory *history; /* History of the command */
|
||||||
int num_history;
|
int num_history;
|
||||||
const char **tips; /* An array of strings that are meant to be tips for clients/proxies regarding this command */
|
const char **tips; /* An array of strings that are meant to be tips for clients/proxies regarding this command */
|
||||||
int num_tips;
|
int num_tips;
|
||||||
redisCommandProc *proc; /* Command implementation */
|
redictCommandProc *proc; /* Command implementation */
|
||||||
int arity; /* Number of arguments, it is possible to use -N to say >= N */
|
int arity; /* Number of arguments, it is possible to use -N to say >= N */
|
||||||
uint64_t flags; /* Command flags, see CMD_*. */
|
uint64_t flags; /* Command flags, see CMD_*. */
|
||||||
uint64_t acl_categories; /* ACl categories, see ACL_CATEGORY_*. */
|
uint64_t acl_categories; /* ACl categories, see ACL_CATEGORY_*. */
|
||||||
@ -2334,12 +2334,12 @@ struct redisCommand {
|
|||||||
int key_specs_num;
|
int key_specs_num;
|
||||||
/* Use a function to determine keys arguments in a command line.
|
/* Use a function to determine keys arguments in a command line.
|
||||||
* Used for Redis Cluster redirect (may be NULL) */
|
* Used for Redis Cluster redirect (may be NULL) */
|
||||||
redisGetKeysProc *getkeys_proc;
|
redictGetKeysProc *getkeys_proc;
|
||||||
int num_args; /* Length of args array. */
|
int num_args; /* Length of args array. */
|
||||||
/* Array of subcommands (may be NULL) */
|
/* Array of subcommands (may be NULL) */
|
||||||
struct redisCommand *subcommands;
|
struct redictCommand *subcommands;
|
||||||
/* Array of arguments (may be NULL) */
|
/* Array of arguments (may be NULL) */
|
||||||
struct redisCommandArg *args;
|
struct redictCommandArg *args;
|
||||||
#ifdef LOG_REQ_RES
|
#ifdef LOG_REQ_RES
|
||||||
/* Reply schema */
|
/* Reply schema */
|
||||||
struct jsonObject *reply_schema;
|
struct jsonObject *reply_schema;
|
||||||
@ -2360,31 +2360,31 @@ struct redisCommand {
|
|||||||
* COMMAND INFO and COMMAND GETKEYS */
|
* COMMAND INFO and COMMAND GETKEYS */
|
||||||
dict *subcommands_dict; /* A dictionary that holds the subcommands, the key is the subcommand sds name
|
dict *subcommands_dict; /* A dictionary that holds the subcommands, the key is the subcommand sds name
|
||||||
* (not the fullname), and the value is the redisCommand structure pointer. */
|
* (not the fullname), and the value is the redisCommand structure pointer. */
|
||||||
struct redisCommand *parent;
|
struct redictCommand *parent;
|
||||||
struct RedisModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */
|
struct RedictModuleCommand *module_cmd; /* A pointer to the module command data (NULL if native command) */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct redisError {
|
struct redictError {
|
||||||
long long count;
|
long long count;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct redisFunctionSym {
|
struct redictFunctionSym {
|
||||||
char *name;
|
char *name;
|
||||||
unsigned long pointer;
|
unsigned long pointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _redisSortObject {
|
typedef struct _redictSortObject {
|
||||||
robj *obj;
|
robj *obj;
|
||||||
union {
|
union {
|
||||||
double score;
|
double score;
|
||||||
robj *cmpobj;
|
robj *cmpobj;
|
||||||
} u;
|
} u;
|
||||||
} redisSortObject;
|
} redictSortObject;
|
||||||
|
|
||||||
typedef struct _redisSortOperation {
|
typedef struct _redictSortOperation {
|
||||||
int type;
|
int type;
|
||||||
robj *pattern;
|
robj *pattern;
|
||||||
} redisSortOperation;
|
} redictSortOperation;
|
||||||
|
|
||||||
/* Structure to hold list iteration abstraction. */
|
/* Structure to hold list iteration abstraction. */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -2440,7 +2440,7 @@ extern int io_threads_op;
|
|||||||
* Extern declarations
|
* Extern declarations
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
extern struct redisServer server;
|
extern struct redictServer server;
|
||||||
extern struct sharedObjectsStruct shared;
|
extern struct sharedObjectsStruct shared;
|
||||||
extern dictType objectKeyPointerValueDictType;
|
extern dictType objectKeyPointerValueDictType;
|
||||||
extern dictType objectKeyHeapPointerValueDictType;
|
extern dictType objectKeyHeapPointerValueDictType;
|
||||||
@ -2466,7 +2466,7 @@ extern dict *modules;
|
|||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Command metadata */
|
/* Command metadata */
|
||||||
void populateCommandLegacyRangeSpec(struct redisCommand *c);
|
void populateCommandLegacyRangeSpec(struct redictCommand *c);
|
||||||
|
|
||||||
/* Modules */
|
/* Modules */
|
||||||
void moduleInitModulesSystem(void);
|
void moduleInitModulesSystem(void);
|
||||||
@ -2475,14 +2475,14 @@ void modulesCron(void);
|
|||||||
int moduleLoad(const char *path, void **argv, int argc, int is_loadex);
|
int moduleLoad(const char *path, void **argv, int argc, int is_loadex);
|
||||||
int moduleUnload(sds name, const char **errmsg);
|
int moduleUnload(sds name, const char **errmsg);
|
||||||
void moduleLoadFromQueue(void);
|
void moduleLoadFromQueue(void);
|
||||||
int moduleGetCommandKeysViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int moduleGetCommandKeysViaAPI(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int moduleGetCommandChannelsViaAPI(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int moduleGetCommandChannelsViaAPI(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
moduleType *moduleTypeLookupModuleByID(uint64_t id);
|
moduleType *moduleTypeLookupModuleByID(uint64_t id);
|
||||||
moduleType *moduleTypeLookupModuleByName(const char *name);
|
moduleType *moduleTypeLookupModuleByName(const char *name);
|
||||||
moduleType *moduleTypeLookupModuleByNameIgnoreCase(const char *name);
|
moduleType *moduleTypeLookupModuleByNameIgnoreCase(const char *name);
|
||||||
void moduleTypeNameByID(char *name, uint64_t moduleid);
|
void moduleTypeNameByID(char *name, uint64_t moduleid);
|
||||||
const char *moduleTypeModuleName(moduleType *mt);
|
const char *moduleTypeModuleName(moduleType *mt);
|
||||||
const char *moduleNameFromCommand(struct redisCommand *cmd);
|
const char *moduleNameFromCommand(struct redictCommand *cmd);
|
||||||
void moduleFreeContext(struct RedisModuleCtx *ctx);
|
void moduleFreeContext(struct RedisModuleCtx *ctx);
|
||||||
void moduleCallCommandUnblockedHandler(client *c);
|
void moduleCallCommandUnblockedHandler(client *c);
|
||||||
int isModuleClientUnblocked(client *c);
|
int isModuleClientUnblocked(client *c);
|
||||||
@ -2519,7 +2519,7 @@ int moduleDefragValue(robj *key, robj *obj, int dbid);
|
|||||||
int moduleLateDefrag(robj *key, robj *value, unsigned long *cursor, long long endtime, int dbid);
|
int moduleLateDefrag(robj *key, robj *value, unsigned long *cursor, long long endtime, int dbid);
|
||||||
void moduleDefragGlobals(void);
|
void moduleDefragGlobals(void);
|
||||||
void *moduleGetHandleByName(char *modulename);
|
void *moduleGetHandleByName(char *modulename);
|
||||||
int moduleIsModuleCommand(void *module_handle, struct redisCommand *cmd);
|
int moduleIsModuleCommand(void *module_handle, struct redictCommand *cmd);
|
||||||
|
|
||||||
/* Utils */
|
/* Utils */
|
||||||
long long ustime(void);
|
long long ustime(void);
|
||||||
@ -2928,8 +2928,8 @@ void ACLClearCommandID(void);
|
|||||||
user *ACLGetUserByName(const char *name, size_t namelen);
|
user *ACLGetUserByName(const char *name, size_t namelen);
|
||||||
int ACLUserCheckKeyPerm(user *u, const char *key, int keylen, int flags);
|
int ACLUserCheckKeyPerm(user *u, const char *key, int keylen, int flags);
|
||||||
int ACLUserCheckChannelPerm(user *u, sds channel, int literal);
|
int ACLUserCheckChannelPerm(user *u, sds channel, int literal);
|
||||||
int ACLCheckAllUserCommandPerm(user *u, struct redisCommand *cmd, robj **argv, int argc, int *idxptr);
|
int ACLCheckAllUserCommandPerm(user *u, struct redictCommand *cmd, robj **argv, int argc, int *idxptr);
|
||||||
int ACLUserCheckCmdWithUnrestrictedKeyAccess(user *u, struct redisCommand *cmd, robj **argv, int argc, int flags);
|
int ACLUserCheckCmdWithUnrestrictedKeyAccess(user *u, struct redictCommand *cmd, robj **argv, int argc, int flags);
|
||||||
int ACLCheckAllPerm(client *c, int *idxptr);
|
int ACLCheckAllPerm(client *c, int *idxptr);
|
||||||
int ACLSetUser(user *u, const char *op, ssize_t oplen);
|
int ACLSetUser(user *u, const char *op, ssize_t oplen);
|
||||||
sds ACLStringSetUser(user *u, sds username, sds *argv, int argc);
|
sds ACLStringSetUser(user *u, sds username, sds *argv, int argc);
|
||||||
@ -2941,11 +2941,11 @@ const char *ACLSetUserStringError(void);
|
|||||||
int ACLLoadConfiguredUsers(void);
|
int ACLLoadConfiguredUsers(void);
|
||||||
robj *ACLDescribeUser(user *u);
|
robj *ACLDescribeUser(user *u);
|
||||||
void ACLLoadUsersAtStartup(void);
|
void ACLLoadUsersAtStartup(void);
|
||||||
void addReplyCommandCategories(client *c, struct redisCommand *cmd);
|
void addReplyCommandCategories(client *c, struct redictCommand *cmd);
|
||||||
user *ACLCreateUnlinkedUser(void);
|
user *ACLCreateUnlinkedUser(void);
|
||||||
void ACLFreeUserAndKillClients(user *u);
|
void ACLFreeUserAndKillClients(user *u);
|
||||||
void addACLLogEntry(client *c, int reason, int context, int argpos, sds username, sds object);
|
void addACLLogEntry(client *c, int reason, int context, int argpos, sds username, sds object);
|
||||||
sds getAclErrorMessage(int acl_res, user *user, struct redisCommand *cmd, sds errored_val, int verbose);
|
sds getAclErrorMessage(int acl_res, user *user, struct redictCommand *cmd, sds errored_val, int verbose);
|
||||||
void ACLUpdateDefaultUserPassword(sds password);
|
void ACLUpdateDefaultUserPassword(sds password);
|
||||||
sds genRedisInfoStringACLStats(sds info);
|
sds genRedisInfoStringACLStats(sds info);
|
||||||
void ACLRecomputeCommandBitsFromCommandRulesAllUsers(void);
|
void ACLRecomputeCommandBitsFromCommandRulesAllUsers(void);
|
||||||
@ -3029,17 +3029,17 @@ int createSocketAcceptHandler(connListener *sfd, aeFileProc *accept_handler);
|
|||||||
connListener *listenerByType(const char *typename);
|
connListener *listenerByType(const char *typename);
|
||||||
int changeListener(connListener *listener);
|
int changeListener(connListener *listener);
|
||||||
void closeListener(connListener *listener);
|
void closeListener(connListener *listener);
|
||||||
struct redisCommand *lookupSubcommand(struct redisCommand *container, sds sub_name);
|
struct redictCommand *lookupSubcommand(struct redictCommand *container, sds sub_name);
|
||||||
struct redisCommand *lookupCommand(robj **argv, int argc);
|
struct redictCommand *lookupCommand(robj **argv, int argc);
|
||||||
struct redisCommand *lookupCommandBySdsLogic(dict *commands, sds s);
|
struct redictCommand *lookupCommandBySdsLogic(dict *commands, sds s);
|
||||||
struct redisCommand *lookupCommandBySds(sds s);
|
struct redictCommand *lookupCommandBySds(sds s);
|
||||||
struct redisCommand *lookupCommandByCStringLogic(dict *commands, const char *s);
|
struct redictCommand *lookupCommandByCStringLogic(dict *commands, const char *s);
|
||||||
struct redisCommand *lookupCommandByCString(const char *s);
|
struct redictCommand *lookupCommandByCString(const char *s);
|
||||||
struct redisCommand *lookupCommandOrOriginal(robj **argv, int argc);
|
struct redictCommand *lookupCommandOrOriginal(robj **argv, int argc);
|
||||||
int commandCheckExistence(client *c, sds *err);
|
int commandCheckExistence(client *c, sds *err);
|
||||||
int commandCheckArity(client *c, sds *err);
|
int commandCheckArity(client *c, sds *err);
|
||||||
void startCommandExecution(void);
|
void startCommandExecution(void);
|
||||||
int incrCommandStatsOnError(struct redisCommand *cmd, int flags);
|
int incrCommandStatsOnError(struct redictCommand *cmd, int flags);
|
||||||
void call(client *c, int flags);
|
void call(client *c, int flags);
|
||||||
void alsoPropagate(int dbid, robj **argv, int argc, int target);
|
void alsoPropagate(int dbid, robj **argv, int argc, int target);
|
||||||
void postExecutionUnitOperations(void);
|
void postExecutionUnitOperations(void);
|
||||||
@ -3048,7 +3048,7 @@ void forceCommandPropagation(client *c, int flags);
|
|||||||
void preventCommandPropagation(client *c);
|
void preventCommandPropagation(client *c);
|
||||||
void preventCommandAOF(client *c);
|
void preventCommandAOF(client *c);
|
||||||
void preventCommandReplication(client *c);
|
void preventCommandReplication(client *c);
|
||||||
void slowlogPushCurrentCommand(client *c, struct redisCommand *cmd, ustime_t duration);
|
void slowlogPushCurrentCommand(client *c, struct redictCommand *cmd, ustime_t duration);
|
||||||
void updateCommandLatencyHistogram(struct hdr_histogram** latency_histogram, int64_t duration_hist);
|
void updateCommandLatencyHistogram(struct hdr_histogram** latency_histogram, int64_t duration_hist);
|
||||||
int prepareForShutdown(int flags);
|
int prepareForShutdown(int flags);
|
||||||
void replyToClientsBlockedOnShutdown(void);
|
void replyToClientsBlockedOnShutdown(void);
|
||||||
@ -3315,29 +3315,29 @@ void freeReplicationBacklogRefMemAsync(list *blocks, rax *index);
|
|||||||
#define GET_KEYSPEC_INCLUDE_NOT_KEYS (1<<0) /* Consider 'fake' keys as keys */
|
#define GET_KEYSPEC_INCLUDE_NOT_KEYS (1<<0) /* Consider 'fake' keys as keys */
|
||||||
#define GET_KEYSPEC_RETURN_PARTIAL (1<<1) /* Return all keys that can be found */
|
#define GET_KEYSPEC_RETURN_PARTIAL (1<<1) /* Return all keys that can be found */
|
||||||
|
|
||||||
int getKeysFromCommandWithSpecs(struct redisCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result);
|
int getKeysFromCommandWithSpecs(struct redictCommand *cmd, robj **argv, int argc, int search_flags, getKeysResult *result);
|
||||||
keyReference *getKeysPrepareResult(getKeysResult *result, int numkeys);
|
keyReference *getKeysPrepareResult(getKeysResult *result, int numkeys);
|
||||||
int getKeysFromCommand(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int getKeysFromCommand(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int doesCommandHaveKeys(struct redisCommand *cmd);
|
int doesCommandHaveKeys(struct redictCommand *cmd);
|
||||||
int getChannelsFromCommand(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int getChannelsFromCommand(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int doesCommandHaveChannelsWithFlags(struct redisCommand *cmd, int flags);
|
int doesCommandHaveChannelsWithFlags(struct redictCommand *cmd, int flags);
|
||||||
void getKeysFreeResult(getKeysResult *result);
|
void getKeysFreeResult(getKeysResult *result);
|
||||||
int sintercardGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result);
|
int sintercardGetKeys(struct redictCommand *cmd,robj **argv, int argc, getKeysResult *result);
|
||||||
int zunionInterDiffGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result);
|
int zunionInterDiffGetKeys(struct redictCommand *cmd,robj **argv, int argc, getKeysResult *result);
|
||||||
int zunionInterDiffStoreGetKeys(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result);
|
int zunionInterDiffStoreGetKeys(struct redictCommand *cmd,robj **argv, int argc, getKeysResult *result);
|
||||||
int evalGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int evalGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int functionGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int functionGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int sortGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int sortROGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int sortROGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int migrateGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int migrateGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int georadiusGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int georadiusGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int xreadGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int xreadGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int lmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int lmpopGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int blmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int blmpopGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int zmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int zmpopGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int bzmpopGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int bzmpopGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int setGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int setGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
int bitfieldGetKeys(struct redisCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
int bitfieldGetKeys(struct redictCommand *cmd, robj **argv, int argc, getKeysResult *result);
|
||||||
|
|
||||||
unsigned short crc16(const char *buf, int len);
|
unsigned short crc16(const char *buf, int len);
|
||||||
|
|
||||||
@ -3744,7 +3744,7 @@ int memtest_preserving_test(unsigned long *m, size_t bytes, int passes);
|
|||||||
void mixDigest(unsigned char *digest, const void *ptr, size_t len);
|
void mixDigest(unsigned char *digest, const void *ptr, size_t len);
|
||||||
void xorDigest(unsigned char *digest, const void *ptr, size_t len);
|
void xorDigest(unsigned char *digest, const void *ptr, size_t len);
|
||||||
sds catSubCommandFullname(const char *parent_name, const char *sub_name);
|
sds catSubCommandFullname(const char *parent_name, const char *sub_name);
|
||||||
void commandAddSubcommand(struct redisCommand *parent, struct redisCommand *subcommand, const char *declared_name);
|
void commandAddSubcommand(struct redictCommand *parent, struct redictCommand *subcommand, const char *declared_name);
|
||||||
void debugDelay(int usec);
|
void debugDelay(int usec);
|
||||||
void killIOThreads(void);
|
void killIOThreads(void);
|
||||||
void killThreads(void);
|
void killThreads(void);
|
||||||
|
18
src/sort.c
18
src/sort.c
@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
zskiplistNode* zslGetElementByRank(zskiplist *zsl, unsigned long rank);
|
zskiplistNode* zslGetElementByRank(zskiplist *zsl, unsigned long rank);
|
||||||
|
|
||||||
redisSortOperation *createSortOperation(int type, robj *pattern) {
|
redictSortOperation *createSortOperation(int type, robj *pattern) {
|
||||||
redisSortOperation *so = zmalloc(sizeof(*so));
|
redictSortOperation *so = zmalloc(sizeof(*so));
|
||||||
so->type = type;
|
so->type = type;
|
||||||
so->pattern = pattern;
|
so->pattern = pattern;
|
||||||
return so;
|
return so;
|
||||||
@ -113,7 +113,7 @@ noobj:
|
|||||||
* the additional parameter is not standard but a BSD-specific we have to
|
* the additional parameter is not standard but a BSD-specific we have to
|
||||||
* pass sorting parameters via the global 'server' structure */
|
* pass sorting parameters via the global 'server' structure */
|
||||||
int sortCompare(const void *s1, const void *s2) {
|
int sortCompare(const void *s1, const void *s2) {
|
||||||
const redisSortObject *so1 = s1, *so2 = s2;
|
const redictSortObject *so1 = s1, *so2 = s2;
|
||||||
int cmp;
|
int cmp;
|
||||||
|
|
||||||
if (!server.sort_alpha) {
|
if (!server.sort_alpha) {
|
||||||
@ -173,7 +173,7 @@ void sortCommandGeneric(client *c, int readonly) {
|
|||||||
int int_conversion_error = 0;
|
int int_conversion_error = 0;
|
||||||
int syntax_error = 0;
|
int syntax_error = 0;
|
||||||
robj *sortval, *sortby = NULL, *storekey = NULL;
|
robj *sortval, *sortby = NULL, *storekey = NULL;
|
||||||
redisSortObject *vector; /* Resulting vector to sort */
|
redictSortObject *vector; /* Resulting vector to sort */
|
||||||
int user_has_full_key_access = 0; /* ACL - used in order to verify 'get' and 'by' options can be used */
|
int user_has_full_key_access = 0; /* ACL - used in order to verify 'get' and 'by' options can be used */
|
||||||
/* Create a list of operations to perform for every sorted element.
|
/* Create a list of operations to perform for every sorted element.
|
||||||
* Operations can be GET */
|
* Operations can be GET */
|
||||||
@ -339,7 +339,7 @@ void sortCommandGeneric(client *c, int readonly) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Load the sorting vector with all the objects to sort */
|
/* Load the sorting vector with all the objects to sort */
|
||||||
vector = zmalloc(sizeof(redisSortObject)*vectorlen);
|
vector = zmalloc(sizeof(redictSortObject)*vectorlen);
|
||||||
j = 0;
|
j = 0;
|
||||||
|
|
||||||
if (sortval->type == OBJ_LIST && dontsort) {
|
if (sortval->type == OBJ_LIST && dontsort) {
|
||||||
@ -492,9 +492,9 @@ void sortCommandGeneric(client *c, int readonly) {
|
|||||||
server.sort_bypattern = sortby ? 1 : 0;
|
server.sort_bypattern = sortby ? 1 : 0;
|
||||||
server.sort_store = storekey ? 1 : 0;
|
server.sort_store = storekey ? 1 : 0;
|
||||||
if (sortby && (start != 0 || end != vectorlen-1))
|
if (sortby && (start != 0 || end != vectorlen-1))
|
||||||
pqsort(vector,vectorlen,sizeof(redisSortObject),sortCompare, start,end);
|
pqsort(vector,vectorlen,sizeof(redictSortObject),sortCompare, start,end);
|
||||||
else
|
else
|
||||||
qsort(vector,vectorlen,sizeof(redisSortObject),sortCompare);
|
qsort(vector,vectorlen,sizeof(redictSortObject),sortCompare);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send command output to the output buffer, performing the specified
|
/* Send command output to the output buffer, performing the specified
|
||||||
@ -512,7 +512,7 @@ void sortCommandGeneric(client *c, int readonly) {
|
|||||||
if (!getop) addReplyBulk(c,vector[j].obj);
|
if (!getop) addReplyBulk(c,vector[j].obj);
|
||||||
listRewind(operations,&li);
|
listRewind(operations,&li);
|
||||||
while((ln = listNext(&li))) {
|
while((ln = listNext(&li))) {
|
||||||
redisSortOperation *sop = ln->value;
|
redictSortOperation *sop = ln->value;
|
||||||
robj *val = lookupKeyByPattern(c->db,sop->pattern,
|
robj *val = lookupKeyByPattern(c->db,sop->pattern,
|
||||||
vector[j].obj);
|
vector[j].obj);
|
||||||
|
|
||||||
@ -544,7 +544,7 @@ void sortCommandGeneric(client *c, int readonly) {
|
|||||||
} else {
|
} else {
|
||||||
listRewind(operations,&li);
|
listRewind(operations,&li);
|
||||||
while((ln = listNext(&li))) {
|
while((ln = listNext(&li))) {
|
||||||
redisSortOperation *sop = ln->value;
|
redictSortOperation *sop = ln->value;
|
||||||
robj *val = lookupKeyByPattern(c->db,sop->pattern,
|
robj *val = lookupKeyByPattern(c->db,sop->pattern,
|
||||||
vector[j].obj);
|
vector[j].obj);
|
||||||
|
|
||||||
|
@ -583,9 +583,9 @@ with open("%s/%s.def" % (srcdir, commands_filename), "w") as f:
|
|||||||
"""
|
"""
|
||||||
/* We have fabulous commands from
|
/* We have fabulous commands from
|
||||||
* the fantastic
|
* the fantastic
|
||||||
* Redis Command Table! */
|
* Redict Command Table! */
|
||||||
|
|
||||||
/* Must match redisCommandGroup */
|
/* Must match redictCommandGroup */
|
||||||
const char *COMMAND_GROUP_STR[] = {
|
const char *COMMAND_GROUP_STR[] = {
|
||||||
"generic",
|
"generic",
|
||||||
"string",
|
"string",
|
||||||
@ -618,7 +618,7 @@ const char *commandGroupStr(int index) {
|
|||||||
command.write_internal_structs(f)
|
command.write_internal_structs(f)
|
||||||
|
|
||||||
f.write("/* Main command table */\n")
|
f.write("/* Main command table */\n")
|
||||||
f.write("struct COMMAND_STRUCT redisCommandTable[] = {\n")
|
f.write("struct COMMAND_STRUCT redictCommandTable[] = {\n")
|
||||||
curr_group = None
|
curr_group = None
|
||||||
for command in command_list:
|
for command in command_list:
|
||||||
if curr_group != command.group:
|
if curr_group != command.group:
|
||||||
|
Loading…
Reference in New Issue
Block a user