@@ -2492,6 +2492,71 @@ int redis_sdiffstore_cmd(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock,
24922492 "SDIFFSTORE" , sizeof ("SDIFFSTORE" )- 1 , 2 , 0 , cmd , cmd_len , slot );
24932493}
24942494
2495+ /* COMMAND */
2496+ int redis_command_cmd (INTERNAL_FUNCTION_PARAMETERS , RedisSock * redis_sock ,
2497+ char * * cmd , int * cmd_len , short * slot , void * * ctx )
2498+ {
2499+ char * kw = NULL ;
2500+ zval * z_arg ;
2501+ int kw_len ;
2502+
2503+ /* Parse our args */
2504+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "|sz" , & kw , & kw_len ,
2505+ & z_arg )== FAILURE )
2506+ {
2507+ return FAILURE ;
2508+ }
2509+
2510+ /* Construct our command */
2511+ if (!kw ) {
2512+ * cmd_len = redis_cmd_format_static (cmd , "COMMAND" , "" );
2513+ } else if (kw && !z_arg ) {
2514+ /* Sanity check */
2515+ if (strncasecmp (kw , "info" , sizeof ("info" )- 1 ) ||
2516+ Z_TYPE_P (z_arg )!= IS_STRING )
2517+ {
2518+ return FAILURE ;
2519+ }
2520+
2521+ /* COMMAND INFO <cmd> */
2522+ * cmd_len = redis_cmd_format_static (cmd , "COMMAND" , "ss" , "INFO" ,
2523+ sizeof ("INFO" )- 1 , Z_STRVAL_P (z_arg ), Z_STRLEN_P (z_arg ));
2524+ } else {
2525+ int arr_len ;
2526+
2527+ /* Sanity check on args */
2528+ if (strncasecmp (kw , "getkeys" , sizeof ("getkeys" )- 1 ) ||
2529+ Z_TYPE_P (z_arg )!= IS_ARRAY ||
2530+ (arr_len = zend_hash_num_elements (Z_ARRVAL_P (z_arg )))< 1 )
2531+ {
2532+ return FAILURE ;
2533+ }
2534+
2535+ zval * * z_ele ;
2536+ HashTable * ht_arr = Z_ARRVAL_P (z_arg );
2537+ smart_str cmdstr = {0 };
2538+
2539+ redis_cmd_init_sstr (& cmdstr , 1 + arr_len , "COMMAND" , sizeof ("COMMAND" )- 1 );
2540+ redis_cmd_append_sstr (& cmdstr , "GETKEYS" , sizeof ("GETKEYS" )- 1 );
2541+
2542+ for (zend_hash_internal_pointer_reset (ht_arr );
2543+ zend_hash_get_current_data (ht_arr , (void * * )& z_ele )== SUCCESS ;
2544+ zend_hash_move_forward (ht_arr ))
2545+ {
2546+ convert_to_string (* z_ele );
2547+ redis_cmd_append_sstr (& cmdstr , Z_STRVAL_PP (z_ele ), Z_STRLEN_PP (z_ele ));
2548+ }
2549+
2550+ * cmd = cmdstr .c ;
2551+ * cmd_len = cmdstr .len ;
2552+ }
2553+
2554+ /* Any slot will do */
2555+ CMD_RAND_SLOT (slot );
2556+
2557+ return SUCCESS ;
2558+ }
2559+
24952560/*
24962561 * Redis commands that don't deal with the server at all. The RedisSock*
24972562 * pointer is the only thing retreived differently, so we just take that
0 commit comments