feat(script): Support script flags of Eval script and Function#2446
Conversation
|
Just ping me if ready for code review |
|
The converting integer part uses the
What do you think, or is there a better solution? @PragmaTwice |
|
I think maybe we can just use |
This API seems to be supported by lua 5.3 |
git-hulk
left a comment
There was a problem hiding this comment.
LGTM, this PR is in good shape.
|
@mapleFU To see if you have further comments? or we can merge this PR to avoid pending too long. |
|




fix: #1884, #2133
a part of: #2414
This PR is designed to support three script flags within Eval Script and Function:
no-writes,no-cluster, andallow-cross-slot-keys.Implementation Details
Focus on
ScriptRunCtx. I use it to pass context between Lua and C++. Before executing the Lua script,SaveOnRegistrystores the parsed flags inREGISTRY_SCRIPT_RUN_CTX_NAME. During the execution of the Lua script,GetFromRegistryretrieves the flags of the currently executing script. After the script execution ends, it should be set tonil.For APIs like
EVAL,SCRIPT LOAD, andFUNCTION LOAD, the flags parsed from the Eval Script will be stored in Lua's global variablef_<sha>_flags_. The flags parsed by FUNCTIONregister_function()will be stored in the Lua global variable_registered_flags_<funcname>.Testing
#!in the EVAL Script.name=and EVAL Script’sflags=which will not appear simultaneously.#!luaandname=.allow-cross-slot-keys, pre-defined Keys are still prohibited from crossing Slots.Different slots on different nodes are still prohibited from crossing Slots. However, slots on the same node are allowed to cross slots when this flag is enabled (generally not recommended).
read_onlyofEVAL_RO,EVALSHA_RO, andFCALL_ROwill be added to the script flags, and even if theno-writesflag is not set, checks will still be performed.Note
Since I am not very familiar with Lua, the rationality and safety of related operations need to be reviewed.