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 5A88E27A71 for ; Thu, 21 Feb 2019 08:00:53 -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 lEaPGPU0iAY7 for ; Thu, 21 Feb 2019 08:00:53 -0500 (EST) Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (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 05C6527A6E for ; Thu, 21 Feb 2019 08:00:52 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v6 4/7] sql: fix "PRAGMA case_sensitive_like" result Date: Thu, 21 Feb 2019 16:00:50 +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: v.shpilevoy@tarantool.org Cc: tarantool-patches@freelists.org 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( -- }) +-- 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, + -- + 1 + -- + ) + test:finish_test() -- 2.7.4