From 5b253d89c7cc9593723334e0a45077bd4008d3db Mon Sep 17 00:00:00 2001 From: git-hulk Date: Sat, 27 Jan 2024 22:21:54 +0800 Subject: Add support of RESP3 attribute type Currently, Redis DEBUG PROTOCOL 'attrib' command will return an attribute type, but hiredis doesn't support it yet. So it got the protocol type error: ``` 127.0.0.1:6379> DEBUG PROTOCOL attrib Error: Protocol error, got "|" as reply type byte ``` After apply this PR, it should reply: ``` 127.0.0.1:6379> DEBUG PROTOCOL attrib 1# "key-popularity" 1# 1) "key:123" 2) (integer) 90 ``` --- read.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'read.c') diff --git a/read.c b/read.c index 9c8f869..fa40e61 100644 --- a/read.c +++ b/read.c @@ -250,6 +250,7 @@ static void moveToNextTask(redisReader *r) { prv = r->task[r->ridx-1]; assert(prv->type == REDIS_REPLY_ARRAY || prv->type == REDIS_REPLY_MAP || + prv->type == REDIS_REPLY_ATTR || prv->type == REDIS_REPLY_SET || prv->type == REDIS_REPLY_PUSH); if (cur->idx == prv->elements-1) { @@ -534,7 +535,7 @@ static int processAggregateItem(redisReader *r) { moveToNextTask(r); } else { - if (cur->type == REDIS_REPLY_MAP) elements *= 2; + if (cur->type == REDIS_REPLY_MAP || cur->type == REDIS_REPLY_ATTR) elements *= 2; if (r->fn && r->fn->createArray) obj = r->fn->createArray(cur,elements); @@ -602,6 +603,9 @@ static int processItem(redisReader *r) { case '%': cur->type = REDIS_REPLY_MAP; break; + case '|': + cur->type = REDIS_REPLY_ATTR; + break; case '~': cur->type = REDIS_REPLY_SET; break; @@ -642,6 +646,7 @@ static int processItem(redisReader *r) { return processBulkItem(r); case REDIS_REPLY_ARRAY: case REDIS_REPLY_MAP: + case REDIS_REPLY_ATTR: case REDIS_REPLY_SET: case REDIS_REPLY_PUSH: return processAggregateItem(r); -- cgit v1.2.3