apache / kvrocks

Apache Kvrocks is a distributed key value NoSQL database that uses RocksDB as storage engine and is compatible with Redis protocol.
https://kvrocks.apache.org/
Apache License 2.0
3.44k stars 442 forks source link

Add support for `flags` parameter of `redis.register_function` #2133

Open i18nsite opened 6 months ago

i18nsite commented 6 months ago

Search before asking

https://redis.io/docs/interact/programmability/functions-intro/#function-flags

image

Motivation

compatibility

Solution

No response

Are you willing to submit a PR?

VasuDevrani commented 3 months ago

@PragmaTwice

Possible implementation:

  1. RedisRegisterFunction parses flags table and checks for no-writes src/storage/scripting.cc
  2. if invalid flag, raise error, else store as constant (or something else)
  3. check function flags before execution FunctionCall src/storage/scripting.cc
if (read_only && !(flags & redis::kFunctionNoWrites)) {
  return {Status::NotOK, "Can not execute a function with write flag using fcall_ro."};
}