Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
beb9746a
Unverified
Commit
beb9746a
authored
Aug 02, 2022
by
Wen Hui
Committed by
GitHub
Aug 02, 2022
Browse files
Fix function load error message (#10964)
Update error messages for function load
parent
4fe9242a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/functions.c
View file @
beb9746a
...
@@ -245,7 +245,7 @@ functionsLibCtx* functionsLibCtxCreate() {
...
@@ -245,7 +245,7 @@ functionsLibCtx* functionsLibCtxCreate() {
*/
*/
int
functionLibCreateFunction
(
sds
name
,
void
*
function
,
functionLibInfo
*
li
,
sds
desc
,
uint64_t
f_flags
,
sds
*
err
)
{
int
functionLibCreateFunction
(
sds
name
,
void
*
function
,
functionLibInfo
*
li
,
sds
desc
,
uint64_t
f_flags
,
sds
*
err
)
{
if
(
functionsVerifyName
(
name
)
!=
C_OK
)
{
if
(
functionsVerifyName
(
name
)
!=
C_OK
)
{
*
err
=
sdsnew
(
"
Function
names can only contain letters
and
numbers and must be at least one character long"
);
*
err
=
sdsnew
(
"
Library
names can only contain letters
,
numbers
, or underscores(_)
and must be at least one character long"
);
return
C_ERR
;
return
C_ERR
;
}
}
...
@@ -819,7 +819,7 @@ void functionFlushCommand(client *c) {
...
@@ -819,7 +819,7 @@ void functionFlushCommand(client *c) {
/* FUNCTION HELP */
/* FUNCTION HELP */
void
functionHelpCommand
(
client
*
c
)
{
void
functionHelpCommand
(
client
*
c
)
{
const
char
*
help
[]
=
{
const
char
*
help
[]
=
{
"LOAD
<ENGINE NAME> <LIBRARY NAME> [REPLACE] [DESCRIPTION <LIBRARY DESCRIPTION>] <LIBRARY
CODE>"
,
"LOAD
[REPLACE] <FUNCTION
CODE>"
,
" Create a new library with the given library name and code."
,
" Create a new library with the given library name and code."
,
"DELETE <LIBRARY NAME>"
,
"DELETE <LIBRARY NAME>"
,
" Delete the given library."
,
" Delete the given library."
,
...
@@ -847,7 +847,7 @@ void functionHelpCommand(client *c) {
...
@@ -847,7 +847,7 @@ void functionHelpCommand(client *c) {
" * ASYNC: Asynchronously flush the libraries."
,
" * ASYNC: Asynchronously flush the libraries."
,
" * SYNC: Synchronously flush the libraries."
,
" * SYNC: Synchronously flush the libraries."
,
"DUMP"
,
"DUMP"
,
" Return
s
a serialized payload representing the current libraries, can be restored using FUNCTION RESTORE command"
,
" Return a serialized payload representing the current libraries, can be restored using FUNCTION RESTORE command"
,
"RESTORE <PAYLOAD> [FLUSH|APPEND|REPLACE]"
,
"RESTORE <PAYLOAD> [FLUSH|APPEND|REPLACE]"
,
" Restore the libraries represented by the given payload, it is possible to give a restore policy to"
,
" Restore the libraries represented by the given payload, it is possible to give a restore policy to"
,
" control how to handle existing libraries (default APPEND):"
,
" control how to handle existing libraries (default APPEND):"
,
...
@@ -961,7 +961,7 @@ sds functionsCreateWithLibraryCtx(sds code, int replace, sds* err, functionsLibC
...
@@ -961,7 +961,7 @@ sds functionsCreateWithLibraryCtx(sds code, int replace, sds* err, functionsLibC
}
}
if
(
functionsVerifyName
(
md
.
name
))
{
if
(
functionsVerifyName
(
md
.
name
))
{
*
err
=
sdsnew
(
"Library names can only contain letters
and
numbers and must be at least one character long"
);
*
err
=
sdsnew
(
"Library names can only contain letters
,
numbers
, or underscores(_)
and must be at least one character long"
);
goto
error
;
goto
error
;
}
}
...
...
tests/unit/functions.tcl
View file @
beb9746a
...
@@ -38,7 +38,7 @@ start_server {tags {"scripting"}} {
...
@@ -38,7 +38,7 @@ start_server {tags {"scripting"}} {
r function load
[
get_function_code LUA
{
bad
\0
foramat
}
test
{
return 'hello1'
}]
r function load
[
get_function_code LUA
{
bad
\0
foramat
}
test
{
return 'hello1'
}]
}
e
}
e
set _ $e
set _ $e
}
{
*Library names can only contain letters
and
numbers*
}
}
{
*Library names can only contain letters
,
numbers
, or underscores
(
_
)
*
}
test
{
FUNCTION - Create library with unexisting engine
}
{
test
{
FUNCTION - Create library with unexisting engine
}
{
catch
{
catch
{
...
@@ -597,7 +597,7 @@ start_server {tags {"scripting"}} {
...
@@ -597,7 +597,7 @@ start_server {tags {"scripting"}} {
}
}
}
e
}
e
set _ $e
set _ $e
}
{
*
Function
names can only contain letters
and
numbers and must be at least one character long*
}
}
{
*
Library
names can only contain letters
,
numbers
, or underscores
(
_
)
and must be at least one character long*
}
test
{
LIBRARIES - test registration with empty name
}
{
test
{
LIBRARIES - test registration with empty name
}
{
catch
{
catch
{
...
@@ -606,7 +606,7 @@ start_server {tags {"scripting"}} {
...
@@ -606,7 +606,7 @@ start_server {tags {"scripting"}} {
}
}
}
e
}
e
set _ $e
set _ $e
}
{
*
Function
names can only contain letters
and
numbers and must be at least one character long*
}
}
{
*
Library
names can only contain letters
,
numbers
, or underscores
(
_
)
and must be at least one character long*
}
test
{
LIBRARIES - math.random from function load
}
{
test
{
LIBRARIES - math.random from function load
}
{
catch
{
catch
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment