From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id F28572FB08 for ; Sat, 17 Nov 2018 09:04:03 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sLRktMRiM0MU for ; Sat, 17 Nov 2018 09:04:03 -0500 (EST) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 9A59B2FB28 for ; Sat, 17 Nov 2018 09:04:03 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 06/10] sql: SELECT from system spaces returns unpacked msgpack. Date: Sat, 17 Nov 2018 17:04:01 +0300 Message-Id: <673a50e14f0633075a5869580f4a9559d1b877c7.1542460773.git.imeevma@gmail.com> In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org SELECT executed through net.box returns unpacked msgpask. Fixed in this patch. Needed for #3505 --- src/box/execute.c | 22 +++++++++++++++------- test/sql/iproto.result | 9 +++++++++ test/sql/iproto.test.lua | 4 ++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/box/execute.c b/src/box/execute.c index da2f09c..a7f8a54 100644 --- a/src/box/execute.c +++ b/src/box/execute.c @@ -283,13 +283,21 @@ sql_column_to_messagepack(struct sqlite3_stmt *stmt, int i, } case SQLITE_BLOB: { uint32_t len = sqlite3_column_bytes(stmt, i); - size = mp_sizeof_bin(len); - char *pos = (char *) region_alloc(region, size); - if (pos == NULL) - goto oom; - const char *s; - s = (const char *)sqlite3_column_blob(stmt, i); - mp_encode_bin(pos, s, len); + const char *s = + (const char *)sqlite3_column_blob(stmt, i); + if (sql_column_subtype(stmt, i) == SQL_SUBTYPE_MSGPACK) { + size = len; + char *pos = (char *)region_alloc(region, size); + if (pos == NULL) + goto oom; + memcpy(pos, s, len); + } else { + size = mp_sizeof_bin(len); + char *pos = (char *)region_alloc(region, size); + if (pos == NULL) + goto oom; + mp_encode_bin(pos, s, len); + } break; } case SQLITE_NULL: { diff --git a/test/sql/iproto.result b/test/sql/iproto.result index 0571a3b..d1bd42a 100644 --- a/test/sql/iproto.result +++ b/test/sql/iproto.result @@ -781,6 +781,15 @@ cn = remote.connect(box.cfg.listen) _ = cn:execute("EXPLAIN SELECT 1;") --- ... +-- SELECT from system spaces returns unpacked msgpack. +res = cn:execute('select "format" from "_space" limit 1;') +--- +... +res.rows +--- +- - [[{'name': 'space_id', 'type': 'unsigned'}, {'name': 'lsn', 'type': 'unsigned'}, + {'name': 'tuple', 'type': 'array'}]] +... cn:close() --- ... diff --git a/test/sql/iproto.test.lua b/test/sql/iproto.test.lua index e708bb2..54f17bc 100644 --- a/test/sql/iproto.test.lua +++ b/test/sql/iproto.test.lua @@ -253,6 +253,10 @@ cn = remote.connect(box.cfg.listen) -- Segmentation fault when EXPLAIN executed using net.box. _ = cn:execute("EXPLAIN SELECT 1;") +-- SELECT from system spaces returns unpacked msgpack. +res = cn:execute('select "format" from "_space" limit 1;') +res.rows + cn:close() box.schema.user.revoke('guest', 'read,write,execute', 'universe') -- 2.7.4