[Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT
imeevma at tarantool.org
imeevma at tarantool.org
Thu Aug 26 14:07:10 MSK 2021
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
More information about the Tarantool-patches
mailing list