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 DC53A259BC for ; Sat, 19 Jan 2019 07:37:39 -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 slkVsOHLI7Gj for ; Sat, 19 Jan 2019 07:37:39 -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 9922C25960 for ; Sat, 19 Jan 2019 07:37:39 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v4 3/6] sql: Show currently set sql_default_engine Date: Sat, 19 Jan 2019 15:37:37 +0300 Message-Id: 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 476771d..5e276b4 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -582,12 +582,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