From: imeevma@tarantool.org To: v.shpilevoy@tarantool.org Cc: tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH v6 3/7] sql: Show currently set sql_default_engine Date: Thu, 21 Feb 2019 16:00:48 +0300 [thread overview] Message-ID: <54c77b2bf6b53bde791bf0738dd37a905b86f6ec.1550753723.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1550753723.git.imeevma@gmail.com> 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 | 65 ---------------------------- test/sql-tap/gh-3733-pragma.test.lua | 13 +----- test/sql-tap/pragma.test.lua | 84 ++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 82 deletions(-) delete mode 100755 test/sql-tap/gh-2367-pragma.test.lua create mode 100755 test/sql-tap/pragma.test.lua diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index 1d36655..097f22b 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -605,12 +605,20 @@ sqlPragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ pParse->nErr++; goto pragma_out; } - 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]; + sqlVdbeLoadString(v, 1, engine_name); + sqlVdbeAddOp2(v, OP_ResultRow, 1, 1); + } else { + if (sql_default_engine_set(zRight) != 0) { + pParse->rc = SQL_TARANTOOL_ERROR; + pParse->nErr++; + goto pragma_out; + } + sqlVdbeAddOp0(v, OP_Expire); } - sqlVdbeAddOp0(v, OP_Expire); break; } diff --git a/test/sql-tap/gh-2367-pragma.test.lua b/test/sql-tap/gh-2367-pragma.test.lua deleted file mode 100755 index d874bce..0000000 --- a/test/sql-tap/gh-2367-pragma.test.lua +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env tarantool -test = require("sqltester") - -test:plan(7) - -test:do_catchsql_test( - "pragma-1.3", - [[ - PRAGMA kek = 'ON'; - ]], { - 1, "Pragma 'KEK' does not exist" - }) - ---- ---- gh-2199: SQL default engine pragma ---- -test:do_catchsql_test( - "pragma-2.1", - [[ - pragma sql_default_engine='creepy'; - ]], { - 1, "Space engine 'creepy' does not exist" -}) - -test:do_catchsql_test( - "pragma-2.2", - [[ - pragma sql_default_engine='vinyl'; - ]], { - 0 -}) - -test:do_catchsql_test( - "pragma-2.3", - [[ - pragma sql_default_engine='memtx'; - ]], { - 0 -}) - -test:do_catchsql_test( - "pragma-2.4", - [[ - pragma sql_default_engine; - ]], { - 1, 'Illegal parameters, \'sql_default_engine\' was not specified' -}) - -test:do_catchsql_test( - "pragma-2.5", - [[ - pragma sql_default_engine 'memtx'; - ]], { - 1, 'near \"\'memtx\'\": syntax error' -}) - -test:do_catchsql_test( - "pragma-2.5", - [[ - pragma sql_default_engine 1; - ]], { - 1, 'near \"1\": syntax error' -}) - -test:finish_test() diff --git a/test/sql-tap/gh-3733-pragma.test.lua b/test/sql-tap/gh-3733-pragma.test.lua index 991ef82..0f856aa 100755 --- a/test/sql-tap/gh-3733-pragma.test.lua +++ b/test/sql-tap/gh-3733-pragma.test.lua @@ -1,7 +1,7 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(17) +test:plan(16) --- --- Prerequisites @@ -105,17 +105,6 @@ test:do_execsql_test( }) --- ---- pragma sql_default_engine requires value ---- -test:do_catchsql_test( - "pragma-6.1", - [[ - pragma sql_default_engine; - ]], { - 1, "Illegal parameters, 'sql_default_engine' was not specified" -}) - ---- --- pragma sql_default_engine accepts string values and rejects IDs --- test:do_catchsql_test( diff --git a/test/sql-tap/pragma.test.lua b/test/sql-tap/pragma.test.lua new file mode 100755 index 0000000..5055ba7 --- /dev/null +++ b/test/sql-tap/pragma.test.lua @@ -0,0 +1,84 @@ +#!/usr/bin/env tarantool +test = require("sqltester") + +test:plan(8) + +test:do_catchsql_test( + "pragma-1.3", + [[ + PRAGMA kek = 'ON'; + ]], { + 1, "Pragma 'KEK' does not exist" + }) + +--- +--- gh-2199: SQL default engine pragma +--- +test:do_catchsql_test( + "pragma-2.1", + [[ + pragma sql_default_engine='creepy'; + ]], { + 1, "Space engine 'creepy' does not exist" +}) + +test:do_catchsql_test( + "pragma-2.2", + [[ + pragma sql_default_engine='vinyl'; + ]], { + 0 +}) + +test:do_catchsql_test( + "pragma-2.3", + [[ + pragma sql_default_engine='memtx'; + ]], { + 0 +}) + +test:do_catchsql_test( + "pragma-2.4", + [[ + pragma sql_default_engine 'memtx'; + ]], { + 1, 'near \"\'memtx\'\": syntax error' +}) + +test:do_catchsql_test( + "pragma-2.5", + [[ + pragma sql_default_engine 1; + ]], { + 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_execsql_test( + "pragma-3.1", + [[ + pragma sql_default_engine='vinyl'; + pragma sql_default_engine; + ]], { + -- <pragma-3.1> + 'vinyl' + -- <pragma-3.1> +}) + +test:do_execsql_test( + "pragma-3.2", + [[ + pragma sql_default_engine='memtx'; + pragma sql_default_engine; + ]], { + -- <pragma-3.2> + 'memtx' + -- <pragma-3.2> +}) + +test:finish_test() -- 2.7.4
next prev parent reply other threads:[~2019-02-21 13:00 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-21 13:00 [tarantool-patches] [PATCH v6 0/7] sql: set column types for EXPLAIN and PRAGMA imeevma 2019-02-21 13:00 ` [tarantool-patches] [PATCH v6 1/7] sql: remove unused macros from pragma.c and pragma.h imeevma 2019-02-21 13:00 ` [tarantool-patches] [PATCH v6 2/7] sql: fix "PRAGMA parser_trace" result imeevma 2019-02-21 13:00 ` imeevma [this message] 2019-02-21 15:52 ` [tarantool-patches] Re: [PATCH v6 3/7] sql: Show currently set sql_default_engine Konstantin Osipov 2019-02-21 13:00 ` [tarantool-patches] [PATCH v6 4/7] sql: fix "PRAGMA case_sensitive_like" result imeevma 2019-02-21 13:00 ` [tarantool-patches] [PATCH v6 5/7] sql: get results of PRAGMA statement as result set imeevma 2019-02-21 13:00 ` [tarantool-patches] [PATCH v6 6/7] sql: set column types for EXPLAIN and PRAGMA imeevma 2019-02-21 13:00 ` [tarantool-patches] [PATCH v6 7/7] sql: remove test gh-3733-pragma.test.lua imeevma 2019-02-25 11:59 ` [tarantool-patches] Re: [PATCH v6 0/7] sql: set column types for EXPLAIN and PRAGMA Vladislav Shpilevoy 2019-02-25 21:05 ` Imeev Mergen 2019-02-26 9:33 ` Vladislav Shpilevoy 2019-02-27 11:09 ` Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=54c77b2bf6b53bde791bf0738dd37a905b86f6ec.1550753723.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v6 3/7] sql: Show currently set sql_default_engine' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox