Send SELECT input_dbnum to the server */
| 811 | |
| 812 | /* Send SELECT input_dbnum to the server */ |
| 813 | static 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. */ |
| 836 | static int cliSwitchProto(void) { |
no test coverage detected