| 203 | } |
| 204 | |
| 205 | char *redisProtocolToLuaType_Aggregate(lua_State *lua, char *reply, int atype) { |
| 206 | char *p = strchr(reply+1,'\r'); |
| 207 | long long mbulklen; |
| 208 | int j = 0; |
| 209 | |
| 210 | string2ll(reply+1,p-reply-1,&mbulklen); |
| 211 | if (serverTL->lua_client->resp == 2 || atype == '*') { |
| 212 | p += 2; |
| 213 | if (mbulklen == -1) { |
| 214 | lua_pushboolean(lua,0); |
| 215 | return p; |
| 216 | } |
| 217 | lua_newtable(lua); |
| 218 | for (j = 0; j < mbulklen; j++) { |
| 219 | lua_pushnumber(lua,j+1); |
| 220 | p = redisProtocolToLuaType(lua,p); |
| 221 | lua_settable(lua,-3); |
| 222 | } |
| 223 | } else if (serverTL->lua_client->resp == 3) { |
| 224 | /* Here we handle only Set and Map replies in RESP3 mode, since arrays |
| 225 | * follow the above RESP2 code path. Note that those are represented |
| 226 | * as a table with the "map" or "set" field populated with the actual |
| 227 | * table representing the set or the map type. */ |
| 228 | p += 2; |
| 229 | lua_newtable(lua); |
| 230 | lua_pushstring(lua,atype == '%' ? "map" : "set"); |
| 231 | lua_newtable(lua); |
| 232 | for (j = 0; j < mbulklen; j++) { |
| 233 | p = redisProtocolToLuaType(lua,p); |
| 234 | if (atype == '%') { |
| 235 | p = redisProtocolToLuaType(lua,p); |
| 236 | } else { |
| 237 | if (!lua_checkstack(lua, 1)) { |
| 238 | /* Notice that here we need to check the stack again because the recursive |
| 239 | * call to redisProtocolToLuaType might have use the room allocated in the stack */ |
| 240 | serverPanic("lua stack limit reach when parsing redis.call reply"); |
| 241 | } |
| 242 | lua_pushboolean(lua,1); |
| 243 | } |
| 244 | lua_settable(lua,-3); |
| 245 | } |
| 246 | lua_settable(lua,-3); |
| 247 | } |
| 248 | return p; |
| 249 | } |
| 250 | |
| 251 | char *redisProtocolToLuaType_Null(lua_State *lua, char *reply) { |
| 252 | char *p = strchr(reply+1,'\r'); |
no test coverage detected