Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Chris Sosnin" <k.sosnin@tarantool.org>
To: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches]  [PATCH] box: fix non-informative update() error message
Date: Mon, 25 Nov 2019 00:15:12 +0300	[thread overview]
Message-ID: <1574630112.698478354@f497.i.mail.ru> (raw)

[-- Attachment #1: Type: text/plain, Size: 2793 bytes --]


Calling tuple_object:update() with invalid argument number
yields 'Unknown UPDATE operation' error. Instead, we replace this
error with explicit "Wrong argument number".
Taking an actual issue into account, the problem is about
nil - box.NULL confusion, maybe we could consider giving some
kind of warning in this case.
Fixes: #3884
---
src/box/xrow_update_field.c | 4 +++-
test/box/update.result | 4 ++--
test/engine/upsert.result | 6 +++---
test/vinyl/gh.result | 2 +-
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/box/xrow_update_field.c b/src/box/xrow_update_field.c
index c694e17e9..6d1334e02 100644
--- a/src/box/xrow_update_field.c
+++ b/src/box/xrow_update_field.c
@@ -625,7 +625,9 @@ xrow_update_op_decode(struct xrow_update_op *op, int index_base,
if (op->meta == NULL)
return -1;
if (arg_count != op->meta->arg_count) {
- diag_set(ClientError, ER_UNKNOWN_UPDATE_OP);
+ char s[10];
+ sprintf(s, "%u", op->meta->arg_count);
+ diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT, "update", s, arg_count);
return -1;
}
int32_t field_no = 0;
diff --git a/test/box/update.result b/test/box/update.result
index c6a5a25a7..b89b7124b 100644
--- a/test/box/update.result
+++ b/test/box/update.result
@@ -826,11 +826,11 @@ s:update({0}, {{}})
...
s:update({0}, {{'+'}})
---
-- error: Unknown UPDATE operation
+- error: 'Wrong number of arguments is passed to update(): expected 3, got 1'
...
s:update({0}, {{'+', 0}})
---
-- error: Unknown UPDATE operation
+- error: 'Wrong number of arguments is passed to update(): expected 3, got 2'
...
s:update({0}, {{'+', '+', '+'}})
---
diff --git a/test/engine/upsert.result b/test/engine/upsert.result
index 47da307fa..1e1441237 100644
--- a/test/engine/upsert.result
+++ b/test/engine/upsert.result
@@ -2117,15 +2117,15 @@ test(t, {{'+', 3, 3}, {'&', 3, 'a'}}, {{1, '1', 1, '1'}})
...
test(t, {{'+', 3}, {'&', 3, 'a'}}, {{1, '1', 1, '1'}})
---
-- error: Unknown UPDATE operation
+- error: 'Wrong number of arguments is passed to update(): expected 3, got 2'
...
test(t, {{':', 3, 3}}, {{1, '1', 1, '1'}})
---
-- error: Unknown UPDATE operation
+- error: 'Wrong number of arguments is passed to update(): expected 5, got 3'
...
test(t, {{':', 3, 3, 3}}, {{1, '1', 1, '1'}})
---
-- error: Unknown UPDATE operation
+- error: 'Wrong number of arguments is passed to update(): expected 5, got 4'
...
test(t, {{'?', 3, 3}}, {{1, '1', 1, '1'}})
---
diff --git a/test/vinyl/gh.result b/test/vinyl/gh.result
index 78cb2a28d..7985ac903 100644
--- a/test/vinyl/gh.result
+++ b/test/vinyl/gh.result
@@ -369,7 +369,7 @@ s:select()
...
s:upsert({1, 'test', 'failed'}, {{'=', 3, 33}, {'=', 4, nil}})
---
-- error: Unknown UPDATE operation
+- error: 'Wrong number of arguments is passed to update(): expected 3, got 2'
...
s:select()
---
-- 
2.24.0
 

[-- Attachment #2: Type: text/html, Size: 3153 bytes --]

             reply	other threads:[~2019-11-24 21:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-24 21:15 Chris Sosnin [this message]
2019-11-25 23:42 ` Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1574630112.698478354@f497.i.mail.ru \
    --to=k.sosnin@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches]  [PATCH] box: fix non-informative update() error message' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox