MCPcopy Create free account
hub / github.com/apache/kvrocks / RedisReturnSingleFieldTable

Function RedisReturnSingleFieldTable

src/storage/scripting.cc:963–974  ·  view source on GitHub ↗

Returns a table with a single field 'field' set to the string value * passed as argument. This helper function is handy when returning * a Redis Protocol error or status reply from Lua: * * return redis.error_reply("ERR Some Error") * return redis.status_reply("ERR Some Error") */

Source from the content-addressed store, hash-verified

961 * return redis.status_reply("ERR Some Error")
962 */
963int RedisReturnSingleFieldTable(lua_State *lua, const char *field) {
964 if (lua_gettop(lua) != 1 || lua_type(lua, -1) != LUA_TSTRING) {
965 PushError(lua, "wrong number or type of arguments");
966 return 1;
967 }
968
969 lua_newtable(lua);
970 lua_pushstring(lua, field);
971 lua_pushvalue(lua, -3);
972 lua_settable(lua, -3);
973 return 1;
974}
975
976int RedisSetResp(lua_State *lua) {
977 auto *script_run_ctx = GetFromRegistry<ScriptRunCtx>(lua, REGISTRY_SCRIPT_RUN_CTX_NAME);

Callers 2

RedisErrorReplyCommandFunction · 0.85
RedisStatusReplyCommandFunction · 0.85

Calls 1

PushErrorFunction · 0.85

Tested by

no test coverage detected