* [Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT
@ 2021-08-26 11:07 Mergen Imeev via Tarantool-patches
2021-08-26 20:11 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-27 12:30 ` Kirill Yukhin via Tarantool-patches
0 siblings, 2 replies; 3+ messages in thread
From: Mergen Imeev via Tarantool-patches @ 2021-08-26 11:07 UTC (permalink / raw)
To: v.shpilevoy; +Cc: tarantool-patches
After this patch, getting an unknown msgpack extension in SQL will throw
the correct error.
Closes #6375
---
https://github.com/tarantool/tarantool/issues/6375
https://github.com/tarantool/tarantool/tree/imeevma/gh-6375-assert-on-getting-unknown-mp-ext
.../gh-6375-fix-assert-on-unsupported-ext.md | 5 ++++
src/box/sql/mem.c | 11 +++++---
test/sql-tap/engine.cfg | 1 +
...gh-6375-assert-on-unsupported-ext.test.lua | 25 +++++++++++++++++++
4 files changed, 38 insertions(+), 4 deletions(-)
create mode 100644 changelogs/unreleased/gh-6375-fix-assert-on-unsupported-ext.md
create mode 100755 test/sql-tap/gh-6375-assert-on-unsupported-ext.test.lua
diff --git a/changelogs/unreleased/gh-6375-fix-assert-on-unsupported-ext.md b/changelogs/unreleased/gh-6375-fix-assert-on-unsupported-ext.md
new file mode 100644
index 000000000..c68251239
--- /dev/null
+++ b/changelogs/unreleased/gh-6375-fix-assert-on-unsupported-ext.md
@@ -0,0 +1,5 @@
+## bugfix/sql
+
+* Now getting unsupported msgpack extension in SQL will throw correct
+ error (gh-6375).
+
diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
index 0aca76112..4c40f15dc 100644
--- a/src/box/sql/mem.c
+++ b/src/box/sql/mem.c
@@ -3484,12 +3484,15 @@ port_lua_get_vdbemem(struct port *base, uint32_t *size)
goto error;
break;
case MP_EXT: {
- assert(field.ext_type == MP_UUID ||
- field.ext_type == MP_DECIMAL);
- if (field.ext_type == MP_UUID)
+ if (field.ext_type == MP_UUID) {
mem_set_uuid(&val[i], field.uuidval);
- else
+ } else if (field.ext_type == MP_DECIMAL) {
mem_set_dec(&val[i], field.decval);
+ } else {
+ diag_set(ClientError, ER_SQL_EXECUTE,
+ "Unsupported type passed from Lua");
+ goto error;
+ }
break;
}
case MP_NIL:
diff --git a/test/sql-tap/engine.cfg b/test/sql-tap/engine.cfg
index 35754f769..587adbed9 100644
--- a/test/sql-tap/engine.cfg
+++ b/test/sql-tap/engine.cfg
@@ -36,6 +36,7 @@
"memtx": {"engine": "memtx"}
},
"gh-4077-iproto-execute-no-bind.test.lua": {},
+ "gh-6375-assert-on-unsupported-ext.test.lua": {},
"*": {
"memtx": {"engine": "memtx"},
"vinyl": {"engine": "vinyl"}
diff --git a/test/sql-tap/gh-6375-assert-on-unsupported-ext.test.lua b/test/sql-tap/gh-6375-assert-on-unsupported-ext.test.lua
new file mode 100755
index 000000000..35980c58e
--- /dev/null
+++ b/test/sql-tap/gh-6375-assert-on-unsupported-ext.test.lua
@@ -0,0 +1,25 @@
+#!/usr/bin/env tarantool
+local test = require("sqltester")
+test:plan(2)
+
+--
+-- Make sure that the correct error occurs when unsupported extension is
+-- received by SQL.
+--
+test:do_catchsql_test(
+ "gh-6375-1",
+ [[
+ SELECT LUA('return box.space._vindex:select()[1]');
+ ]], {
+ 1, "Failed to execute SQL statement: Unsupported type passed from Lua"
+ })
+
+test:do_catchsql_test(
+ "gh-6375-2",
+ [[
+ SELECT 1 > LUA('return box.space._vindex:select()[1]');
+ ]], {
+ 1, "Failed to execute SQL statement: Unsupported type passed from Lua"
+ })
+
+test:finish_test()
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT
2021-08-26 11:07 [Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT Mergen Imeev via Tarantool-patches
@ 2021-08-26 20:11 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-27 12:30 ` Kirill Yukhin via Tarantool-patches
1 sibling, 0 replies; 3+ messages in thread
From: Vladislav Shpilevoy via Tarantool-patches @ 2021-08-26 20:11 UTC (permalink / raw)
To: imeevma; +Cc: tarantool-patches
Hi! Thanks for the patch!
LGTM.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT
2021-08-26 11:07 [Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT Mergen Imeev via Tarantool-patches
2021-08-26 20:11 ` Vladislav Shpilevoy via Tarantool-patches
@ 2021-08-27 12:30 ` Kirill Yukhin via Tarantool-patches
1 sibling, 0 replies; 3+ messages in thread
From: Kirill Yukhin via Tarantool-patches @ 2021-08-27 12:30 UTC (permalink / raw)
To: imeevma; +Cc: v.shpilevoy, tarantool-patches
Hello,
On 26 авг 14:07, Mergen Imeev via Tarantool-patches wrote:
> After this patch, getting an unknown msgpack extension in SQL will throw
> the correct error.
>
> Closes #6375
> ---
> https://github.com/tarantool/tarantool/issues/6375
> https://github.com/tarantool/tarantool/tree/imeevma/gh-6375-assert-on-getting-unknown-mp-ext
LGTM.
I've checked your patch into master.
--
Regards, Kirill Yukhin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-27 12:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26 11:07 [Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT Mergen Imeev via Tarantool-patches
2021-08-26 20:11 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-27 12:30 ` Kirill Yukhin via Tarantool-patches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox