Open gettyying opened 11 years ago
With the debugging information,
$6 = 0x7fb8b7f088e0 "ERR wrong number of arguments for 'hset' command"
you can see that during the call of redisCommand of hiRedis, it reported such error information.
mysql> select @b;
+------------------------------------------+ | @b | +------------------------------------------+ | hset "htest" "1" "{"topic":"h e l l o"}" | +------------------------------------------+ 1 row in set (0.00 sec)
in gdb, you can see that
(gdb) p cmd
$8 = 0x7fb8b869c380 "hset \"htest\" \"1\" \"{\"topic\":\"h e l l o\"}\""
and the redisCommand complaint that with "ERR wrong number of arguments for 'hset' command".
It's illegal to pass white space between mysql SQL and hiredis.
I have two suggestion for you.
To verify the problem, I did tests using hiredis directly.
reply = redisCommand(c,"SET %s %s", "foo", "{\"topic\" : \"hello world\"}"); printf("The value has white space: %s\n", reply->str); freeReplyObject(reply);
It's gonna work out fine. Unfortunately, it's failed when transfer keys and values directly, as below:
reply = redisCommand(c,"SET foo {\"topic\" : \"hello world\"}"); printf("The value has white space: %s\n", reply->str); freeReplyObject(reply);
@gettyying thank you for your work.
I patched this in the latest version, let the redis_command can get 3 or 5 parameters.
You can test the new one.
But as the talking in issue/2, the solution from mysql to redis, it is not a very meaningful work. Why we have to take some much time on this?
By the way, the code is open-sourced, you can do it as you want.
Like as below:
But it's succeed when wrap off white space.