From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@dev.tarantool.org
Cc: v.shpilevoy@tarantool.org
Subject: [Tarantool-patches] [PATCH v2 07/10] box: use stacked diagnostic area for functional indexes
Date: Wed, 25 Mar 2020 04:43:03 +0300 [thread overview]
Message-ID: <025887cafb6ed752962ec238db670ec2f46c0a86.1585097339.git.korablev@tarantool.org> (raw)
In-Reply-To: <cover.1585097339.git.korablev@tarantool.org>
In-Reply-To: <cover.1585097339.git.korablev@tarantool.org>
Since we've introduced stacked diagnostic in previous commit, let's use
it in the code implementing functional indexes.
Part of #1148
---
src/box/key_list.c | 12 ++++----
src/box/lua/call.c | 4 +--
test/engine/func_index.result | 52 +++++++++++++++++++++++++++++----
test/engine/func_index.test.lua | 8 +++++
4 files changed, 62 insertions(+), 14 deletions(-)
diff --git a/src/box/key_list.c b/src/box/key_list.c
index 81eb501a5..a766ce0ec 100644
--- a/src/box/key_list.c
+++ b/src/box/key_list.c
@@ -63,9 +63,9 @@ key_list_iterator_create(struct key_list_iterator *it, struct tuple *tuple,
if (rc != 0) {
/* Can't evaluate function. */
struct space *space = space_by_id(index_def->space_id);
- diag_set(ClientError, ER_FUNC_INDEX_FUNC, index_def->name,
+ diag_add(ClientError, ER_FUNC_INDEX_FUNC, index_def->name,
space != NULL ? space_name(space) : "",
- diag_last_error(diag_get())->errmsg);
+ "can't evaluate function");
return -1;
}
uint32_t key_data_sz;
@@ -74,9 +74,9 @@ key_list_iterator_create(struct key_list_iterator *it, struct tuple *tuple,
if (key_data == NULL) {
struct space *space = space_by_id(index_def->space_id);
/* Can't get a result returned by function . */
- diag_set(ClientError, ER_FUNC_INDEX_FUNC, index_def->name,
+ diag_add(ClientError, ER_FUNC_INDEX_FUNC, index_def->name,
space != NULL ? space_name(space) : "",
- diag_last_error(diag_get())->errmsg);
+ "can't get a value returned by function");
return -1;
}
@@ -170,9 +170,9 @@ key_list_iterator_next(struct key_list_iterator *it, const char **value)
* The key doesn't follow functional index key
* definition.
*/
- diag_set(ClientError, ER_FUNC_INDEX_FORMAT, it->index_def->name,
+ diag_add(ClientError, ER_FUNC_INDEX_FORMAT, it->index_def->name,
space ? space_name(space) : "",
- diag_last_error(diag_get())->errmsg);
+ "key does not follow functional index definition");
return -1;
}
diff --git a/src/box/lua/call.c b/src/box/lua/call.c
index 92575374d..5d3579eff 100644
--- a/src/box/lua/call.c
+++ b/src/box/lua/call.c
@@ -687,9 +687,9 @@ func_persistent_lua_load(struct func_lua *func)
if (func->base.def->is_sandboxed) {
if (prepare_lua_sandbox(tarantool_L, default_sandbox_exports,
nelem(default_sandbox_exports)) != 0) {
- diag_set(ClientError, ER_LOAD_FUNCTION,
+ diag_add(ClientError, ER_LOAD_FUNCTION,
func->base.def->name,
- diag_last_error(diag_get())->errmsg);
+ "can't prepare a Lua sandbox");
goto end;
}
} else {
diff --git a/test/engine/func_index.result b/test/engine/func_index.result
index 159158f1c..8f92fcf11 100644
--- a/test/engine/func_index.result
+++ b/test/engine/func_index.result
@@ -5,6 +5,10 @@ test_run = require('test_run').new()
engine = test_run:get_cfg('engine')
| ---
| ...
+test_run:cmd("push filter \"file: .*\" to \"file: <filename>\"")
+ | ---
+ | - true
+ | ...
--
-- gh-1260: Func index.
@@ -158,8 +162,7 @@ idx = s:create_index('idx', {func = box.func.invalidreturn1.id, parts = {{1, 'un
s:insert({1})
| ---
| - error: 'Key format doesn''t match one defined in functional index ''idx'' of space
- | ''withdata'': Supplied key type of part 0 does not match index part type: expected
- | unsigned'
+ | ''withdata'': key does not follow functional index definition'
| ...
idx:drop()
| ---
@@ -197,8 +200,7 @@ idx = s:create_index('idx', {func = box.func.invalidreturn3.id, parts = {{1, 'un
s:insert({1})
| ---
| - error: 'Key format doesn''t match one defined in functional index ''idx'' of space
- | ''withdata'': Supplied key type of part 0 does not match index part type: expected
- | unsigned'
+ | ''withdata'': key does not follow functional index definition'
| ...
idx:drop()
| ---
@@ -217,8 +219,7 @@ idx = s:create_index('idx', {func = box.func.invalidreturn4.id, parts = {{1, 'un
s:insert({1})
| ---
| - error: 'Key format doesn''t match one defined in functional index ''idx'' of space
- | ''withdata'': Supplied key type of part 0 does not match index part type: expected
- | unsigned'
+ | ''withdata'': key does not follow functional index definition'
| ...
idx:drop()
| ---
@@ -261,6 +262,45 @@ box.schema.func.create('runtimeerror', {body = lua_code, is_deterministic = true
idx = s:create_index('idx', {func = box.func.runtimeerror.id, parts = {{1, 'string'}}})
| ---
| ...
+s:insert({1})
+ | ---
+ | - error: 'Failed to build a key for functional index ''idx'' of space ''withdata'':
+ | can''t evaluate function'
+ | ...
+e = box.error.last()
+ | ---
+ | ...
+e:unpack()
+ | ---
+ | - code: 198
+ | trace:
+ | - file: <filename>
+ | line: 68
+ | type: ClientError
+ | message: 'Failed to build a key for functional index ''idx'' of space ''withdata'':
+ | can''t evaluate function'
+ | prev: '[string "return function(tuple) local ..."]:1: attempt to
+ | call global ''require'' (a nil value)'
+ | ...
+e = e.prev
+ | ---
+ | ...
+e:unpack()
+ | ---
+ | - type: LuajitError
+ | message: '[string "return function(tuple) local ..."]:1: attempt
+ | to call global ''require'' (a nil value)'
+ | trace:
+ | - file: <filename>
+ | line: 1028
+ | ...
+e = e.prev
+ | ---
+ | ...
+e == nil
+ | ---
+ | - true
+ | ...
idx:drop()
| ---
| ...
diff --git a/test/engine/func_index.test.lua b/test/engine/func_index.test.lua
index c3c3a7029..0e4043260 100644
--- a/test/engine/func_index.test.lua
+++ b/test/engine/func_index.test.lua
@@ -1,5 +1,6 @@
test_run = require('test_run').new()
engine = test_run:get_cfg('engine')
+test_run:cmd("push filter \"file: .*\" to \"file: <filename>\"")
--
-- gh-1260: Func index.
@@ -98,6 +99,13 @@ lua_code = [[function(tuple)
test_run:cmd("setopt delimiter ''");
box.schema.func.create('runtimeerror', {body = lua_code, is_deterministic = true, is_sandboxed = true})
idx = s:create_index('idx', {func = box.func.runtimeerror.id, parts = {{1, 'string'}}})
+s:insert({1})
+e = box.error.last()
+e:unpack()
+e = e.prev
+e:unpack()
+e = e.prev
+e == nil
idx:drop()
-- Remove old persistent functions
--
2.17.1
next prev parent reply other threads:[~2020-03-25 1:43 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 1:42 [Tarantool-patches] [PATCH v2 00/10] Stacked diagnostics Nikita Pettik
2020-03-25 1:42 ` [Tarantool-patches] [PATCH v2 01/10] box: rfc for stacked diagnostic area Nikita Pettik
2020-03-25 8:27 ` Konstantin Osipov
2020-03-25 14:08 ` Nikita Pettik
2020-03-25 1:42 ` [Tarantool-patches] [PATCH v2 02/10] box: rename diag_add_error to diag_set_error Nikita Pettik
2020-03-25 8:27 ` Konstantin Osipov
2020-03-26 0:22 ` Vladislav Shpilevoy
2020-03-26 12:31 ` Nikita Pettik
2020-03-25 1:42 ` [Tarantool-patches] [PATCH v2 03/10] test: move box.error tests to box/error.test.lua Nikita Pettik
2020-03-25 8:28 ` Konstantin Osipov
2020-03-26 0:22 ` Vladislav Shpilevoy
2020-03-26 12:31 ` Nikita Pettik
2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 04/10] box/error: introduce box.error.set() method Nikita Pettik
2020-03-25 8:33 ` Konstantin Osipov
2020-03-25 17:41 ` Nikita Pettik
2020-03-26 0:22 ` Vladislav Shpilevoy
2020-03-26 12:31 ` Nikita Pettik
2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 05/10] box/error: don't set error created via box.error.new to diag Nikita Pettik
2020-03-26 16:50 ` Konstantin Osipov
2020-03-26 17:59 ` Nikita Pettik
2020-03-26 18:06 ` Nikita Pettik
2020-03-26 18:07 ` Alexander Turenko
2020-03-27 0:19 ` Vladislav Shpilevoy
2020-03-27 13:09 ` Nikita Pettik
2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 06/10] box: introduce stacked diagnostic area Nikita Pettik
2020-03-26 16:54 ` Konstantin Osipov
2020-03-26 18:03 ` Nikita Pettik
2020-03-26 18:08 ` Konstantin Osipov
2020-03-28 18:40 ` Vladislav Shpilevoy
2020-04-01 16:09 ` Nikita Pettik
2020-04-02 0:29 ` Vladislav Shpilevoy
2020-04-02 17:42 ` Nikita Pettik
2020-04-02 22:20 ` Vladislav Shpilevoy
2020-04-03 1:54 ` Nikita Pettik
2020-04-03 23:17 ` Vladislav Shpilevoy
2020-03-28 18:59 ` Vladislav Shpilevoy
2020-03-31 17:44 ` Nikita Pettik
2020-04-02 0:29 ` Vladislav Shpilevoy
2020-04-02 14:16 ` Nikita Pettik
2020-03-25 1:43 ` Nikita Pettik [this message]
2020-03-30 23:24 ` [Tarantool-patches] [PATCH v2 07/10] box: use stacked diagnostic area for functional indexes Vladislav Shpilevoy
2020-04-01 15:53 ` Nikita Pettik
2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 08/10] box/error: clarify purpose of reference counting in struct error Nikita Pettik
2020-03-30 23:24 ` Vladislav Shpilevoy
2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 09/10] iproto: refactor error encoding with mpstream Nikita Pettik
2020-03-30 23:24 ` Vladislav Shpilevoy
2020-04-01 15:54 ` Nikita Pettik
2020-03-25 1:43 ` [Tarantool-patches] [PATCH v2 10/10] iproto: support error stacked diagnostic area Nikita Pettik
2020-03-30 23:24 ` Vladislav Shpilevoy
2020-04-01 16:26 ` Nikita Pettik
2020-04-01 22:24 ` Nikita Pettik
2020-04-02 0:29 ` Vladislav Shpilevoy
2020-04-02 14:01 ` Nikita Pettik
2020-04-02 22:20 ` Vladislav Shpilevoy
2020-04-03 2:16 ` Nikita Pettik
2020-04-03 23:17 ` Vladislav Shpilevoy
2020-04-06 11:07 ` Nikita Pettik
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=025887cafb6ed752962ec238db670ec2f46c0a86.1585097339.git.korablev@tarantool.org \
--to=korablev@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2 07/10] box: use stacked diagnostic area for functional indexes' \
/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