Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending null values in an EVAL script. #9

Open
tbrezot opened this issue Sep 6, 2024 · 0 comments
Open

Sending null values in an EVAL script. #9

tbrezot opened this issue Sep 6, 2024 · 0 comments

Comments

@tbrezot
Copy link

tbrezot commented Sep 6, 2024

Hi there, I was trying to send an EVAL script that takes as argument a possibly null value, but it seems the type dispatch here does not allow it. If I understand correctly, passing an empty string is prepended by 0 (the length) and thus do not match Redis' .

My script (a Lua implementation of a kind of CAS):

local w = redis.call('GET', ARGV[1]);
if (w == ARGV[2]) then
	redis.call('SET', ARGV[3], ARGV[4]);
end;
return w;

Steps to reproduce it:

scheme@(guile-user)> (display script)
local w = redis.call('GET', ARGV[1]);
if (w == ARGV[2]) then
	return "OK";
else
        return "NOK";
end;
scheme@(guile-user)> (use-modules (redis))
scheme@(guile-user)> (define cnx (redis-connect))
scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 "")))
$8 = "NOK"
scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 '())))
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `redis-invalid' with args `()'.

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.

I also tried the following (after this doc):

scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 "_\r\n")))
$9 = "NOK"
scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 "_")))
$10 = "NOK"

My script works for non-null values:

scheme@(guile-user)> (redis-send cnx (set '(0 0)))
$12 = "OK"
scheme@(guile-user)> (redis-send cnx (eval (list script 0 0 0)))
$13 = "OK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant