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 D416D210ED for ; Wed, 26 Dec 2018 13:18:16 -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 BFbJ-MuuI2xS for ; Wed, 26 Dec 2018 13:18:16 -0500 (EST) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 93696210E4 for ; Wed, 26 Dec 2018 13:18:16 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v3 3/6] sql: Show currently set sql_default_engine Date: Wed, 26 Dec 2018 21:18:14 +0300 Message-Id: <274e7ff85ccde82a37912ae77a18ee33a56dabbf.1545844480.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, korablev@tarantool.org After this patch, "PRAGMA sql_default_engine" called without arguments will return currently set sql_default_engine. --- 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 6122986..9b68c13 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -583,12 +583,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