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 1BE1B284BF for ; Mon, 18 Mar 2019 19:51:28 -0400 (EDT) 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 HD00719oJjZ4 for ; Mon, 18 Mar 2019 19:51:27 -0400 (EDT) Received: from smtp14.mail.ru (smtp14.mail.ru [94.100.181.95]) (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 422202819C for ; Mon, 18 Mar 2019 19:51:27 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 1/2] sql: fix OP_MakeRecord argument of ANALYZE bytecode Date: Tue, 19 Mar 2019 02:51:20 +0300 Message-Id: In-Reply-To: References: 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 Cc: v.shpilevoy@tarantool.org, Nikita Pettik Accidentally, wrong number of fields was passed to OP_MakeRecord opcode which encodes tuple to be inserted to _sql_stat1 space: instead of three fields (as format of space says), four were specified. Since this system space doesn't feature exact field count, this insertion was successfully processed. What is more, this additional field was invisible for SQL means since it is out of space format (so it didn't get to resulting set of SELECT * FROM _sql_stat1; queries). This patch fixes number of fields to be encoded of this particular OP_MakeRecord. --- src/box/sql/analyze.c | 2 +- .../sql/{sql-statN-index-drop.result => analyze.result} | 17 +++++++++++++++++ .../{sql-statN-index-drop.test.lua => analyze.test.lua} | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-) rename test/sql/{sql-statN-index-drop.result => analyze.result} (86%) rename test/sql/{sql-statN-index-drop.test.lua => analyze.test.lua} (91%) diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c index ea5cbc39b..9d3df8a15 100644 --- a/src/box/sql/analyze.c +++ b/src/box/sql/analyze.c @@ -996,7 +996,7 @@ vdbe_emit_analyze_space(struct Parse *parse, struct space *space) FIELD_TYPE_STRING, FIELD_TYPE_STRING, field_type_MAX }; - sqlVdbeAddOp4(v, OP_MakeRecord, tab_name_reg, 4, tmp_reg, + sqlVdbeAddOp4(v, OP_MakeRecord, tab_name_reg, 3, tmp_reg, (char *)types, sizeof(types)); sqlVdbeAddOp4(v, OP_IdxInsert, tmp_reg, 0, 0, (char *)stat1, P4_SPACEPTR); diff --git a/test/sql/sql-statN-index-drop.result b/test/sql/analyze.result similarity index 86% rename from test/sql/sql-statN-index-drop.result rename to test/sql/analyze.result index 760595188..42210ea13 100644 --- a/test/sql/sql-statN-index-drop.result +++ b/test/sql/analyze.result @@ -45,6 +45,23 @@ box.sql.execute("SELECT * FROM \"_sql_stat1\";") - ['T2', 'I1', '1 1'] - ['T2', 'T2', '1 1'] ... +-- Make sure that tuples in spaces with statistics don't +-- containt fields out of format. +-- +box.space._sql_stat1:select() +--- +- - ['T1', 'I1', '1 1'] + - ['T1', 'T1', '1 1'] + - ['T2', 'I1', '1 1'] + - ['T2', 'T2', '1 1'] +... +box.space._sql_stat4:select() +--- +- - ['T1', 'I1', '1', '0', '0', !!binary kQI=] + - ['T1', 'T1', '1', '0', '0', !!binary kQE=] + - ['T2', 'I1', '1', '0', '0', !!binary kQI=] + - ['T2', 'T2', '1', '0', '0', !!binary kQE=] +... -- Dropping an index. box.sql.execute("DROP INDEX i1 ON t1;") --- diff --git a/test/sql/sql-statN-index-drop.test.lua b/test/sql/analyze.test.lua similarity index 91% rename from test/sql/sql-statN-index-drop.test.lua rename to test/sql/analyze.test.lua index 35f22910c..ba31d5fbc 100644 --- a/test/sql/sql-statN-index-drop.test.lua +++ b/test/sql/analyze.test.lua @@ -17,6 +17,12 @@ box.sql.execute("ANALYZE;") box.sql.execute("SELECT * FROM \"_sql_stat4\";") box.sql.execute("SELECT * FROM \"_sql_stat1\";") +-- Make sure that tuples in spaces with statistics don't +-- containt fields out of format. +-- +box.space._sql_stat1:select() +box.space._sql_stat4:select() + -- Dropping an index. box.sql.execute("DROP INDEX i1 ON t1;") -- 2.15.1