From: imeevma@tarantool.org To: v.shpilevoy@tarantool.org Cc: tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH v6 4/7] sql: fix "PRAGMA case_sensitive_like" result Date: Thu, 21 Feb 2019 16:00:50 +0300 [thread overview] Message-ID: <f1e1e5c269ca0eb9d361fe5dc52ba8a5a313ec24.1550753723.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1550753723.git.imeevma@gmail.com> Currently PRAGMA case_sensitive_like returns nothing. This seems wrong, since other similar pragmas return their status. Fixed in the current patch. --- src/box/sql/pragma.c | 21 +++++++-------------- src/box/sql/pragma.h | 7 +++---- src/box/sql/sqlInt.h | 2 ++ test/sql-tap/pragma.test.lua | 18 +++++++++++++++++- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index 097f22b..c2431bf 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -503,6 +503,13 @@ sqlPragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ sqlParserTrace(0, 0); } #endif + /* + * Reinstall the LIKE and functions. The + * variant of LIKE * used will be case + * sensitive or not depending on the RHS. + */ + if (mask == LIKE_CASE_SENS_FLAG) + sqlRegisterLikeFunctions(db, !is_pragma_set); } break; } @@ -583,20 +590,6 @@ sqlPragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ break; } - /* - * Reinstall the LIKE and functions. The variant - * of LIKE * used will be case sensitive or not - * depending on the RHS. - */ - case PragTyp_CASE_SENSITIVE_LIKE:{ - if (zRight) { - int is_like_ci = - !(sqlGetBoolean(zRight, 0)); - sqlRegisterLikeFunctions(db, is_like_ci); - } - break; - } - case PragTyp_DEFAULT_ENGINE: { if (!token_is_string(pValue)) { diag_set(ClientError, ER_ILLEGAL_PARAMS, diff --git a/src/box/sql/pragma.h b/src/box/sql/pragma.h index 9c8e79c..31c83b5 100644 --- a/src/box/sql/pragma.h +++ b/src/box/sql/pragma.h @@ -5,7 +5,6 @@ */ /* The various pragma types */ -#define PragTyp_CASE_SENSITIVE_LIKE 2 #define PragTyp_COLLATION_LIST 3 #define PragTyp_FLAG 5 #define PragTyp_FOREIGN_KEY_LIST 9 @@ -82,10 +81,10 @@ typedef struct PragmaName { */ static const PragmaName aPragmaName[] = { { /* zName: */ "case_sensitive_like", - /* ePragTyp: */ PragTyp_CASE_SENSITIVE_LIKE, - /* ePragFlg: */ PragFlg_NoColumns, + /* ePragTyp: */ PragTyp_FLAG, + /* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1, /* ColNames: */ 0, 0, - /* iArg: */ 0}, + /* iArg: */ LIKE_CASE_SENS_FLAG}, { /* zName: */ "collation_list", /* ePragTyp: */ PragTyp_COLLATION_LIST, /* ePragFlg: */ PragFlg_Result0, diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 0d8945d..ace9b0d 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -1525,6 +1525,8 @@ struct sql { /* Debug print info about SQL query as it parsed */ #define PARSER_TRACE_FLAG 0x00000002 #define SQL_FullColNames 0x00000004 /* Show full column names on SELECT */ +/* True if LIKE is case sensitive. */ +#define LIKE_CASE_SENS_FLAG 0x00000008 #define SQL_ShortColNames 0x00000040 /* Show short columns names */ #define SQL_CountRows 0x00000080 /* Count rows changed by INSERT, */ /* DELETE, or UPDATE and return */ diff --git a/test/sql-tap/pragma.test.lua b/test/sql-tap/pragma.test.lua index 5055ba7..935cb96 100755 --- a/test/sql-tap/pragma.test.lua +++ b/test/sql-tap/pragma.test.lua @@ -1,7 +1,7 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(8) +test:plan(9) test:do_catchsql_test( "pragma-1.3", @@ -81,4 +81,20 @@ test:do_execsql_test( -- <pragma-3.2> }) +-- Check that "PRAGMA case_sensitive_like" returns its status +-- (0 or 1) if called without parameter. +test:do_test( + "pragma-3.3", + function() + old_value = box.sql.execute('PRAGMA case_sensitive_like') + box.sql.execute('PRAGMA case_sensitive_like = 1') + new_value = box.sql.execute('PRAGMA case_sensitive_like') + box.sql.execute('PRAGMA case_sensitive_like = '.. old_value[1][1]) + return new_value[1][1] + end, + -- <pragma-3.3> + 1 + -- <pragma-3.3> + ) + 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 ` [tarantool-patches] [PATCH v6 3/7] sql: Show currently set sql_default_engine imeevma 2019-02-21 15:52 ` [tarantool-patches] " Konstantin Osipov 2019-02-21 13:00 ` imeevma [this message] 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=f1e1e5c269ca0eb9d361fe5dc52ba8a5a313ec24.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 4/7] sql: fix "PRAGMA case_sensitive_like" result' \ /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