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 84F1924343 for ; Sat, 15 Dec 2018 07:05:12 -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 bvTxhMNjrqUX for ; Sat, 15 Dec 2018 07:05:12 -0500 (EST) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 6BFC72434E for ; Sat, 15 Dec 2018 07:05:10 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v2 3/6] sql: Show currently set sql_default_engine Date: Sat, 15 Dec 2018 15:01:47 +0300 Message-Id: <4b7280d1e803f31c73cba874e445f82295bba2a6.1544871594.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: v.shpilevoy@tarantool.org, tarantool-patches@freelists.org After this patch, "PRAGMA sql_default_engine" called without arguments will return currently set sql_default_engine. Part of #3832 --- src/box/sql/pragma.c | 18 +++++++++++++----- test/sql-tap/gh-2367-pragma.test.lua | 35 +++++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index 1fe5b3e..f34e7b8 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -600,12 +600,20 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ } case PragTyp_DEFAULT_ENGINE: { - if (sql_default_engine_set(zRight) != 0) { - pParse->rc = SQL_TARANTOOL_ERROR; - pParse->nErr++; - goto pragma_out; + if (zRight == NULL) { + const char *engine_name = + sql_storage_engine_strs[current_session()-> + sql_default_engine]; + sqlite3VdbeLoadString(v, 1, engine_name); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); + } else { + if (sql_default_engine_set(zRight) != 0) { + pParse->rc = SQL_TARANTOOL_ERROR; + pParse->nErr++; + goto pragma_out; + } + sqlite3VdbeAddOp0(v, OP_Expire); } - sqlite3VdbeAddOp0(v, OP_Expire); break; } diff --git a/test/sql-tap/gh-2367-pragma.test.lua b/test/sql-tap/gh-2367-pragma.test.lua index c0792c9..90ecd56 100755 --- a/test/sql-tap/gh-2367-pragma.test.lua +++ b/test/sql-tap/gh-2367-pragma.test.lua @@ -1,7 +1,7 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(7) +test:plan(8) test:do_catchsql_test( "pragma-1.3", @@ -41,25 +41,44 @@ test:do_catchsql_test( test:do_catchsql_test( "pragma-2.4", [[ - pragma sql_default_engine; + pragma sql_default_engine 'memtx'; ]], { - 1, 'Illegal parameters, \'sql_default_engine\' was not specified' + 1, 'near \"\'memtx\'\": syntax error' }) test:do_catchsql_test( "pragma-2.5", [[ - pragma sql_default_engine 'memtx'; + pragma sql_default_engine 1; ]], { - 1, 'near \"\'memtx\'\": syntax error' + 1, 'near \"1\": syntax error' }) +-- +-- gh-3832: Some statements do not return column type +-- +-- Check that "PRAGMA sql_default_engine" called without arguments +-- returns currently set sql_default_engine. test:do_catchsql_test( - "pragma-2.5", + "pragma-3.1", [[ - pragma sql_default_engine 1; + pragma sql_default_engine='vinyl'; + pragma sql_default_engine; ]], { - 1, 'near \"1\": syntax error' + -- + 0, {'vinyl'} + -- +}) + +test:do_catchsql_test( + "pragma-3.2", + [[ + pragma sql_default_engine='memtx'; + pragma sql_default_engine; + ]], { + -- + 0, {'memtx'} + -- }) test:finish_test() -- 2.7.4