Tarantool development patches archive
 help / color / mirror / Atom feed
From: Imeev Mergen <imeevma@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	tarantool-patches@freelists.org
Cc: korablev@tarantool.org
Subject: [tarantool-patches] Re: [PATCH v5 4/6] sql: fix "PRAGMA case_sensitive_like" result
Date: Thu, 31 Jan 2019 17:56:51 +0300	[thread overview]
Message-ID: <916c3793-c46c-4e9b-d80d-3e9dcee8cd5c@tarantool.org> (raw)
In-Reply-To: <a5ea8eea-8c48-47e3-ecf1-40e0dc32e4dc@tarantool.org>

Hi Thank you for review! Answer, fixes and patch below.


On 1/30/19 4:56 PM, Vladislav Shpilevoy wrote:
>
>
> On 29/01/2019 17:29, imeevma@tarantool.org wrote:
>> 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    | 23 +++++++++--------------
>>   src/box/sql/pragma.h    |  7 +++----
>>   src/box/sql/sqliteInt.h |  2 ++
>>   test/sql/misc.result    | 17 +++++++++++++++++
>>   test/sql/misc.test.lua  | 10 ++++++++++
>>   5 files changed, 41 insertions(+), 18 deletions(-)
>
> Why the previous commit puts a pragma-related test into
> gh-***-pragma.test.lua, but this puts into misc.test.lua?
>
> Please, be consistent. Move this test into the same
> file as the previous commit did.

Fixed. Moved test to pragma.test.lua.


Diff:

commit df25df6610f84b2fec894e4b0b471c038bae1d96
Author: Mergen Imeev <imeevma@gmail.com>
Date:   Thu Jan 31 16:45:52 2019 +0300

     Temporary: Review fix

diff --git a/test/sql-tap/pragma.test.lua b/test/sql-tap/pragma.test.lua
index a847547..0832ec6 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()
diff --git a/test/sql/misc.result b/test/sql/misc.result
index 3496fab..ef104c1 100644
--- a/test/sql/misc.result
+++ b/test/sql/misc.result
@@ -40,20 +40,3 @@ 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 9d4abf5..994e64f 100644
--- a/test/sql/misc.test.lua
+++ b/test/sql/misc.test.lua
@@ -11,13 +11,3 @@ 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])


Patch:

commit f08ee01ae154bd154b2cb5068a9a72417a6e403a
Author: Mergen Imeev <imeevma@gmail.com>
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 9a3ae8f..416af3b 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-tap/pragma.test.lua b/test/sql-tap/pragma.test.lua
index a847547..0832ec6 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()

  reply	other threads:[~2019-01-31 14:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29 14:29 [tarantool-patches] [PATCH v5 0/6] sql: set column types for EXPLAIN and PRAGMA imeevma
2019-01-29 14:29 ` [tarantool-patches] [PATCH v5 1/6] sql: remove unused macros from pragma.c and pragma.h imeevma
2019-01-30 13:57   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-31 14:56     ` Imeev Mergen
2019-01-29 14:29 ` [tarantool-patches] [PATCH v5 2/6] sql: fix "PRAGMA parser_trace" result imeevma
2019-01-30 13:57   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-31 14:56     ` Imeev Mergen
2019-02-04 13:06       ` Vladislav Shpilevoy
2019-02-09 10:08         ` Mergen Imeev
2019-01-29 14:29 ` [tarantool-patches] [PATCH v5 3/6] sql: Show currently set sql_default_engine imeevma
2019-01-30 13:57   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-31 14:56     ` Imeev Mergen
2019-01-29 14:29 ` [tarantool-patches] [PATCH v5 4/6] sql: fix "PRAGMA case_sensitive_like" result imeevma
2019-01-30 13:56   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-31 14:56     ` Imeev Mergen [this message]
2019-01-29 14:29 ` [tarantool-patches] [PATCH v5 5/6] sql: get results of PRAGMA statement in YAML format imeevma
2019-01-30 13:56   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-31 14:56     ` Imeev Mergen
2019-02-04 13:08       ` Vladislav Shpilevoy
2019-02-09 10:11         ` Mergen Imeev
2019-01-29 14:29 ` [tarantool-patches] [PATCH v5 6/6] sql: set column types for EXPLAIN and PRAGMA imeevma
2019-01-30 13:59 ` [tarantool-patches] Re: [PATCH v5 0/6] " Vladislav Shpilevoy
2019-01-31 14:56   ` Imeev Mergen
2019-02-15 20:44 ` Vladislav Shpilevoy

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=916c3793-c46c-4e9b-d80d-3e9dcee8cd5c@tarantool.org \
    --to=imeevma@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH v5 4/6] 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