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 B2C01259BC for ; Sat, 19 Jan 2019 07:37:41 -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 AQG5lHT8kIDJ for ; Sat, 19 Jan 2019 07:37:41 -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 6E5D025960 for ; Sat, 19 Jan 2019 07:37:41 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v4 4/6] sql: fix "PRAGMA case_sensitive_like" result Date: Sat, 19 Jan 2019 15:37:39 +0300 Message-Id: <0de150401e2a202e515ed7a5c4daa2bad593244b.1547899933.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 Hi! Thank you for review. My answers, diff between versions and new version below. On 1/16/19 6:35 PM, n.pettik wrote: > >> diff --git a/test/sql/misc.test.lua b/test/sql/misc.test.lua >> index 994e64f..cc31a5d 100644 >> --- a/test/sql/misc.test.lua >> +++ b/test/sql/misc.test.lua >> @@ -11,3 +11,16 @@ box.sql.execute(';') >> box.sql.execute('') >> box.sql.execute(' ;') >> box.sql.execute('\n\n\n\t\t\t ') >> + >> +-- >> +-- gh-3832: Some statements do not return column type >> + >> +-- Check that "PRAGMA case_sensitive_like" returns 0 or 1 if >> +-- called without parameter. >> +result = box.sql.execute('PRAGMA case_sensitive_like') >> +-- Should be nothing. >> +box.sql.execute('PRAGMA case_sensitive_like = 1') >> +-- Should be 1. >> +box.sql.execute('PRAGMA case_sensitive_like') >> +-- Should be nothing. > > Again: useless comments. > The rest is OK. > Fixed. Diff between versions: commit 6623963e948b8367534446769dfc8160d5c39228 Author: Mergen Imeev Date: Thu Jan 17 11:56:21 2019 +0300 Temporary: Review fixes diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index efee229..a610345 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -494,7 +494,7 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ */ if (mask == LIKE_CASE_SENS_FLAG) { sqlite3RegisterLikeFunctions(db, - !is_value_true); + !is_pragma_set); } } break; diff --git a/test/sql/misc.result b/test/sql/misc.result index 66f5a7b..3496fab 100644 --- a/test/sql/misc.result +++ b/test/sql/misc.result @@ -47,16 +47,13 @@ box.sql.execute('\n\n\n\t\t\t ') result = box.sql.execute('PRAGMA case_sensitive_like') --- ... --- Should be nothing. box.sql.execute('PRAGMA case_sensitive_like = 1') --- ... --- Should be 1. box.sql.execute('PRAGMA case_sensitive_like') --- - - [1] ... --- Should be nothing. box.sql.execute('PRAGMA case_sensitive_like = '.. result[1][1]) --- ... diff --git a/test/sql/misc.test.lua b/test/sql/misc.test.lua index cc31a5d..9d4abf5 100644 --- a/test/sql/misc.test.lua +++ b/test/sql/misc.test.lua @@ -18,9 +18,6 @@ box.sql.execute('\n\n\n\t\t\t ') -- Check that "PRAGMA case_sensitive_like" returns 0 or 1 if -- called without parameter. result = box.sql.execute('PRAGMA case_sensitive_like') --- Should be nothing. box.sql.execute('PRAGMA case_sensitive_like = 1') --- Should be 1. box.sql.execute('PRAGMA case_sensitive_like') --- Should be nothing. box.sql.execute('PRAGMA case_sensitive_like = '.. result[1][1]) New version: commit 0de150401e2a202e515ed7a5c4daa2bad593244b Author: Mergen Imeev Date: Thu Dec 13 15:18:54 2018 +0300 sql: fix "PRAGMA case_sensitive_like" result Currently PRAGMA case_sensitive_like returns nothing. This seems wrong, since other similar pragmas return their status. Fixed in the current patch. diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c index 5e276b4..a610345 100644 --- a/src/box/sql/pragma.c +++ b/src/box/sql/pragma.c @@ -487,6 +487,15 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */ sqlite3ParserTrace(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) { + sqlite3RegisterLikeFunctions(db, + !is_pragma_set); + } } break; } @@ -567,20 +576,6 @@ sqlite3Pragma(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 = - !(sqlite3GetBoolean(zRight, 0)); - sqlite3RegisterLikeFunctions(db, is_like_ci); - } - break; - } - case PragTyp_DEFAULT_ENGINE: { if (zRight == NULL) { const char *engine_name = diff --git a/src/box/sql/pragma.h b/src/box/sql/pragma.h index 4837923..6ccf720 100644 --- a/src/box/sql/pragma.h +++ b/src/box/sql/pragma.h @@ -6,7 +6,6 @@ /* The various pragma types */ #define PragTyp_BUSY_TIMEOUT 1 -#define PragTyp_CASE_SENSITIVE_LIKE 2 #define PragTyp_COLLATION_LIST 3 #define PragTyp_FLAG 5 #define PragTyp_FOREIGN_KEY_LIST 9 @@ -92,10 +91,10 @@ static const PragmaName aPragmaName[] = { /* ColNames: */ 31, 1, /* iArg: */ 0}, { /* 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/sqliteInt.h b/src/box/sql/sqliteInt.h index 740db9f..026fada 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -1550,6 +1550,8 @@ struct sqlite3 { /* Debug print info about SQL query as it parsed */ #define PARSER_TRACE_FLAG 0x00000002 #define SQLITE_FullColNames 0x00000004 /* Show full column names on SELECT */ +/* True if LIKE is case sensitive. */ +#define LIKE_CASE_SENS_FLAG 0x00000008 #define SQLITE_ShortColNames 0x00000040 /* Show short columns names */ #define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */ /* DELETE, or UPDATE and return */ diff --git a/test/sql/misc.result b/test/sql/misc.result index ef104c1..3496fab 100644 --- a/test/sql/misc.result +++ b/test/sql/misc.result @@ -40,3 +40,20 @@ box.sql.execute('\n\n\n\t\t\t ') --- - error: 'syntax error: empty request' ... +-- +-- gh-3832: Some statements do not return column type +-- Check that "PRAGMA case_sensitive_like" returns 0 or 1 if +-- called without parameter. +result = box.sql.execute('PRAGMA case_sensitive_like') +--- +... +box.sql.execute('PRAGMA case_sensitive_like = 1') +--- +... +box.sql.execute('PRAGMA case_sensitive_like') +--- +- - [1] +... +box.sql.execute('PRAGMA case_sensitive_like = '.. result[1][1]) +--- +... diff --git a/test/sql/misc.test.lua b/test/sql/misc.test.lua index 994e64f..9d4abf5 100644 --- a/test/sql/misc.test.lua +++ b/test/sql/misc.test.lua @@ -11,3 +11,13 @@ box.sql.execute(';') box.sql.execute('') box.sql.execute(' ;') box.sql.execute('\n\n\n\t\t\t ') + +-- +-- gh-3832: Some statements do not return column type + +-- Check that "PRAGMA case_sensitive_like" returns 0 or 1 if +-- called without parameter. +result = box.sql.execute('PRAGMA case_sensitive_like') +box.sql.execute('PRAGMA case_sensitive_like = 1') +box.sql.execute('PRAGMA case_sensitive_like') +box.sql.execute('PRAGMA case_sensitive_like = '.. result[1][1]) -- 2.7.4