Send SELECT input_dbnum to the server */
| 618 | |
| 619 | /* Send SELECT input_dbnum to the server */ |
| 620 | static int cliSelect(void) { |
| 621 | redisReply *reply; |
| 622 | if (config.input_dbnum == config.dbnum) return REDIS_OK; |
| 623 | |
| 624 | reply = redisCommand(context,"SELECT %d",config.input_dbnum); |
| 625 | if (reply == NULL) { |
| 626 | fprintf(stderr, "\nI/O error\n"); |
| 627 | return REDIS_ERR; |
| 628 | } |
| 629 | |
| 630 | int result = REDIS_OK; |
| 631 | if (reply->type == REDIS_REPLY_ERROR) { |
| 632 | result = REDIS_ERR; |
| 633 | fprintf(stderr,"SELECT %d failed: %s\n",config.input_dbnum,reply->str); |
| 634 | } else { |
| 635 | config.dbnum = config.input_dbnum; |
| 636 | cliRefreshPrompt(); |
| 637 | } |
| 638 | freeReplyObject(reply); |
| 639 | return result; |
| 640 | } |
| 641 | |
| 642 | /* Select RESP3 mode if redis-cli was started with the -3 option. */ |
| 643 | static int cliSwitchProto(void) { |
no test coverage detected