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

Function cliSelect

app/redis-6.2.6/src/redis-cli.c:813–833  ·  view source on GitHub ↗

Send SELECT input_dbnum to the server */

Source from the content-addressed store, hash-verified

811
812/* Send SELECT input_dbnum to the server */
813static int cliSelect(void) {
814 redisReply *reply;
815 if (config.input_dbnum == config.dbnum) return REDIS_OK;
816
817 reply = redisCommand(context,"SELECT %d",config.input_dbnum);
818 if (reply == NULL) {
819 fprintf(stderr, "\nI/O error\n");
820 return REDIS_ERR;
821 }
822
823 int result = REDIS_OK;
824 if (reply->type == REDIS_REPLY_ERROR) {
825 result = REDIS_ERR;
826 fprintf(stderr,"SELECT %d failed: %s\n",config.input_dbnum,reply->str);
827 } else {
828 config.dbnum = config.input_dbnum;
829 cliRefreshPrompt();
830 }
831 freeReplyObject(reply);
832 return result;
833}
834
835/* Select RESP3 mode if redis-cli was started with the -3 option. */
836static int cliSwitchProto(void) {

Callers 2

cliConnectFunction · 0.85
cliSendCommandFunction · 0.85

Calls 3

cliRefreshPromptFunction · 0.85
freeReplyObjectFunction · 0.85
redisCommandClass · 0.70

Tested by

no test coverage detected