MCPcopy Create free account
hub / github.com/F-Stack/f-stack / getKeysUsingCommandTable

Function getKeysUsingCommandTable

app/redis-6.2.6/src/db.c:1602–1636  ·  view source on GitHub ↗

The base case is to use the keys position as given in the command table * (firstkey, lastkey, step). */

Source from the content-addressed store, hash-verified

1600/* The base case is to use the keys position as given in the command table
1601 * (firstkey, lastkey, step). */
1602int getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, getKeysResult *result) {
1603 int j, i = 0, last, *keys;
1604 UNUSED(argv);
1605
1606 if (cmd->firstkey == 0) {
1607 result->numkeys = 0;
1608 return 0;
1609 }
1610
1611 last = cmd->lastkey;
1612 if (last < 0) last = argc+last;
1613
1614 int count = ((last - cmd->firstkey)+1);
1615 keys = getKeysPrepareResult(result, count);
1616
1617 for (j = cmd->firstkey; j <= last; j += cmd->keystep) {
1618 if (j >= argc) {
1619 /* Modules commands, and standard commands with a not fixed number
1620 * of arguments (negative arity parameter) do not have dispatch
1621 * time arity checks, so we need to handle the case where the user
1622 * passed an invalid number of arguments here. In this case we
1623 * return no keys and expect the command implementation to report
1624 * an arity or syntax error. */
1625 if (cmd->flags & CMD_MODULE || cmd->arity < 0) {
1626 result->numkeys = 0;
1627 return 0;
1628 } else {
1629 serverPanic("Redis built-in command declared keys positions not matching the arity requirements.");
1630 }
1631 }
1632 keys[i++] = j;
1633 }
1634 result->numkeys = i;
1635 return i;
1636}
1637
1638/* Return all the arguments that are keys in the command passed via argc / argv.
1639 *

Callers 1

getKeysFromCommandFunction · 0.85

Calls 1

getKeysPrepareResultFunction · 0.85

Tested by

no test coverage detected