Tarantool development patches archive
 help / color / mirror / Atom feed
From: Mergen Imeev via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: v.shpilevoy@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT
Date: Thu, 26 Aug 2021 14:07:10 +0300	[thread overview]
Message-ID: <97b34dbbaf797bfe417c7317e3cb1ec244701d6e.1629975948.git.imeevma@gmail.com> (raw)

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


             reply	other threads:[~2021-08-26 11:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 11:07 Mergen Imeev via Tarantool-patches [this message]
2021-08-26 20:11 ` Vladislav Shpilevoy via Tarantool-patches
2021-08-27 12:30 ` Kirill Yukhin via Tarantool-patches

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=97b34dbbaf797bfe417c7317e3cb1ec244701d6e.1629975948.git.imeevma@gmail.com \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT' \
    /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