From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 2C27C6EC55; Thu, 26 Aug 2021 14:07:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2C27C6EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1629976032; bh=xb52GQvLjuv+F8MeaDbkegSV4H0aSwKPts7eJp5TbFU=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=UjK5YK4P3VVgGl6TBT2w8819pKkmCqhpZ9hdGTx07pJvQcRUNyZo6R6QTwLfM5HMt S2mASQzat2tN+ivyOCkhELkznMdWQAROcq/4Z3LecH7+/3C6QbGC7veJkqoz2vFCl4 N2B5KjteQn+bRyRWPFsQPPTXUsmXMX8N3sYSz8HI= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 5E3076EC55 for ; Thu, 26 Aug 2021 14:07:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5E3076EC55 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1mJDDy-0005qH-K0; Thu, 26 Aug 2021 14:07:11 +0300 To: v.shpilevoy@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Thu, 26 Aug 2021 14:07:10 +0300 Message-Id: <97b34dbbaf797bfe417c7317e3cb1ec244701d6e.1629975948.git.imeevma@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9736CF3E71F18CE0C3E1D5927724F4AAA182A05F5380850401E1EC831D58473DC954B100A9528720375FEFB7CD583D62CCE40BF8B85E2FBDA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78736B27BC39BD580EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637802D3462438662818638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8C088C013D8C5479BF881AAA060B6F2B2117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B66F6A3E018CF4DC80089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CD38A7E49931D2E15C4F589C41A6EE902CE2DA8DA08E1E41A9C2B6934AE262D3EE7EAB7254005DCEDFB29427B7C22B3881E0A4E2319210D9B64D260DF9561598F01A9E91200F654B0BDBC62CB1440F3B18E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34324A9840C798D50043279168B16525BB05EDEF53719D15B38EFEF0C142C33DDCC70154EDCA5867051D7E09C32AA3244CE958CE67F4630FCA96078676F81A2BD6B038C9161EF167A1729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojXSF/Tsl6M2N+Y3FV4jfIcA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DE4A84D04FE5DC2AA00D5E7BA2C6203E683D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 1/1] sql: Throw an error when getting an unknown MP_EXT X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "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