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 EE92827B27 for ; Thu, 19 Jul 2018 07:56:24 -0400 (EDT) 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 agY7gbTemCXu for ; Thu, 19 Jul 2018 07:56:24 -0400 (EDT) Received: from smtp15.mail.ru (smtp15.mail.ru [94.100.176.133]) (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 7C96527AB5 for ; Thu, 19 Jul 2018 07:56:24 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH] sql: LIKE & GLOB pattern comparison issue References: <1530190036-10105-1-git-send-email-hollow653@gmail.com> <20180718024314.be245cmsgklxuvnk@tkn_work_nb> From: Alex Khatskevich Message-ID: Date: Thu, 19 Jul 2018 14:56:22 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------1371F97E039E1E00FAAAC14F" Content-Language: en-US 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: Nikita Tatunov Cc: alexander.turenko@tarantool.org, tarantool-patches@freelists.org This is a multi-part message in MIME format. --------------1371F97E039E1E00FAAAC14F Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Hi. I have some questions related to the func.c file, however before that I would ask you to fix tests. General ideas: 1. Those tests are regresson tests (it just tests that problem will not appear in the future).     We name those tests in the following manear: gh-XXXX-short-description.test.lua 2. The thing you test is not related to a table and other columns.     Please, convert the tests to the next format: {[[select '' like '_B';]], {1}]]}.     To make it more readable, you can do it like `like_testcases` in `sql-tap/collation.test.lua`. 3. There is two extra things that should be tested:     1. When string or pattern ends with incorrect unicode symbol (e.g. half of the whole unicode symbol)     2. String or pattern contains incorrect unicode symbol. Implementing 3 point may require some additional investigations. E.g. it is ok for a blob to have invalid Unicode symbols. > diff --git a/test/sql-tap/like1.test.lua b/test/sql-tap/like1.test.lua > new file mode 100755 > index 0000000..807ee65 > --- /dev/null > +++ b/test/sql-tap/like1.test.lua > @@ -0,0 +1,181 @@ > +#!/usr/bin/env tarantool > +test = require("sqltester") > +test:plan(16) > + > +test:do_catchsql_test( > +"like-test-1.1", > +[[ > +CREATE TABLE t2 (column1 INTEGER, > +     column2 VARCHAR(100), > +     column3 BLOB, > +     column4 FLOAT, > +     PRIMARY KEY (column1, column2)); > +INSERT INTO t2 VALUES (1, 'AB', X'4142', 5.5); > +INSERT INTO t2 VALUES (1, 'CD', X'2020', 1E4); > +INSERT INTO t2 VALUES (2, 'AB', X'2020', 12.34567); > +INSERT INTO t2 VALUES (-1000, '', X'', 0.0); > +CREATE TABLE t1 (a INT PRIMARY KEY, str VARCHAR(100)); > +INSERT INTO t1 VALUES (1, 'ab'); > +INSERT INTO t1 VALUES (2, 'abCDF'); > +INSERT INTO t1 VALUES (3, 'CDF'); > +CREATE TABLE t (s1 char(2) primary key, s2 char(2)); > +INSERT INTO t VALUES ('AB', 'AB'); > +]], { > +-- > +0 > +-- > +}) > + > +test:do_execsql_test( > +"like-test-1.2", > +[[ > +SELECT column1, column2, column1 * column4 FROM t2 WHERE column2 LIKE > '_B'; > +]], { > +-- > +1, 'AB', 5.5, 2, 'AB', 24.69134 > +-- > +}) > + > +test:do_execsql_test( > +"like-test-1.3", > +[[ > +SELECT column1, column2 FROM t2 WHERE column2 LIKE '%B'; > +]], { > +             -- > +             1, 'AB', 2, 'AB' > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.4", > +[[ > +SELECT column1, column2 FROM t2 WHERE column2 LIKE 'A__'; > +]], { > +             -- > + > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.5", > +[[ > +SELECT column1, column2 FROM t2 WHERE column2 LIKE 'A_'; > +]], { > +             -- > +             1, 'AB', 2, 'AB' > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.6", > +[[ > +SELECT column1, column2 FROM t2 WHERE column2 LIKE 'A'; > +]], { > +             -- > + > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.7", > +[[ > +SELECT column1, column2 FROM t2 WHERE column2 LIKE '_'; > +]], { > +             -- > + > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.8", > +[[ > +SELECT * FROM t WHERE s1 LIKE '%A'; > +]], { > +             -- > + > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.9", > +[[ > +SELECT * FROM t WHERE s1 LIKE '%C'; > +]], { > +             -- > + > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.10", > +[[ > +SELECT * FROM t1 WHERE str LIKE '%df'; > +]], { > +             -- > +             2, 'abCDF', 3, 'CDF' > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.11", > +[[ > +SELECT * FROM t1 WHERE str LIKE 'a_'; > +]], { > +             -- > +             1, 'ab' > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.12", > +[[ > +SELECT column1, column2 FROM t2 WHERE column2 LIKE '__'; > +]], { > +             -- > +             1, 'AB', 1, 'CD', 2, 'AB' > +             -- > +}) > + > +test:do_execsql_test( > +"like-test-1.13", > +[[ > +SELECT str FROM t1 WHERE str LIKE 'ab%'; > +]], { > +-- > +'ab', 'abCDF' > +-- > +}) > + > +test:do_execsql_test( > +"like-test-1.14", > +[[ > +SELECT str FROM t1 WHERE str LIKE 'abC%'; > +]], { > +-- > +'abCDF' > +-- > +}) > + > +test:do_execsql_test( > +"like-test-1.15", > +[[ > +SELECT str FROM t1 WHERE str LIKE 'a_%'; > +]], { > +-- > +'ab', 'abCDF' > +-- > +}) > + > +test:do_execsql_test( > +"like-test-1.16", > +[[ > +DROP TABLE t1; > +DROP TABLE t2; > +DROP TABLE t; > +]], { > +             -- > + > +             -- > +}) > + > +test:finish_test() --------------1371F97E039E1E00FAAAC14F Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 8bit

Hi.

I have some questions related to the func.c file, however before that I would ask you to fix tests.

General ideas:

1. Those tests are regresson tests (it just tests that problem will not appear in the future).
    We name those tests in the following manear: gh-XXXX-short-description.test.lua
2. The thing you test is not related to a table and other columns.
    Please, convert the tests to the next format: {[[select '' like '_B';]], {1}]]}.
    To make it more readable, you can do it like `like_testcases` in `sql-tap/collation.test.lua`.
3. There is two extra things that should be tested:
    1. When string or pattern ends with incorrect unicode symbol (e.g. half of the whole unicode symbol)
    2. String or pattern contains incorrect unicode symbol.

Implementing 3 point may require some additional investigations. E.g. it is ok for a blob to have invalid Unicode symbols.
diff --git a/test/sql-tap/like1.test.lua b/test/sql-tap/like1.test.lua
new file mode 100755
index 0000000..807ee65
--- /dev/null
+++ b/test/sql-tap/like1.test.lua
@@ -0,0 +1,181 @@
+#!/usr/bin/env tarantool
+test = require("sqltester")
+test:plan(16)
+
+test:do_catchsql_test(
+ "like-test-1.1",
+ [[
+ CREATE TABLE t2 (column1 INTEGER,
+      column2 VARCHAR(100),
+      column3 BLOB,
+      column4 FLOAT,
+      PRIMARY KEY (column1, column2));
+ INSERT INTO t2 VALUES (1, 'AB', X'4142', 5.5);
+ INSERT INTO t2 VALUES (1, 'CD', X'2020', 1E4);
+ INSERT INTO t2 VALUES (2, 'AB', X'2020', 12.34567);
+ INSERT INTO t2 VALUES (-1000, '', X'', 0.0);
+ CREATE TABLE t1 (a INT PRIMARY KEY, str VARCHAR(100));
+ INSERT INTO t1 VALUES (1, 'ab');
+ INSERT INTO t1 VALUES (2, 'abCDF');
+ INSERT INTO t1 VALUES (3, 'CDF');
+ CREATE TABLE t (s1 char(2) primary key, s2 char(2));
+ INSERT INTO t VALUES ('AB', 'AB');
+ ]], {
+ -- <like-test-1.1>
+ 0
+ -- <like-test-1.1>
+ })
+
+test:do_execsql_test(
+ "like-test-1.2",
+ [[
+ SELECT column1, column2, column1 * column4 FROM t2 WHERE column2 LIKE '_B';
+ ]], {
+ -- <like-test-1.2>
+ 1, 'AB', 5.5, 2, 'AB', 24.69134
+ -- <like-test-1.2>
+ })
+
+test:do_execsql_test(
+ "like-test-1.3",
+ [[
+ SELECT column1, column2 FROM t2 WHERE column2 LIKE '%B';
+ ]], {
+             -- <like-test-1.3>
+             1, 'AB', 2, 'AB'
+             -- <like-test-1.3>
+ })
+
+test:do_execsql_test(
+ "like-test-1.4",
+ [[
+ SELECT column1, column2 FROM t2 WHERE column2 LIKE 'A__';
+ ]], {
+             -- <like-test-1.4>
+
+             -- <like-test-1.4>
+ })
+
+test:do_execsql_test(
+ "like-test-1.5",
+ [[
+ SELECT column1, column2 FROM t2 WHERE column2 LIKE 'A_';
+ ]], {
+             -- <like-test-1.5>
+             1, 'AB', 2, 'AB'
+             -- <like-test-1.5>
+ })
+
+test:do_execsql_test(
+ "like-test-1.6",
+ [[
+ SELECT column1, column2 FROM t2 WHERE column2 LIKE 'A';
+ ]], {
+             -- <like-test-1.6>
+
+             -- <like-test-1.6>
+ })
+
+test:do_execsql_test(
+ "like-test-1.7",
+ [[
+ SELECT column1, column2 FROM t2 WHERE column2 LIKE '_';
+ ]], {
+             -- <like-test-1.7>
+
+             -- <like-test-1.7>
+ })
+
+test:do_execsql_test(
+ "like-test-1.8",
+ [[
+ SELECT * FROM t WHERE s1 LIKE '%A';
+ ]], {
+             -- <like-test-1.8>
+
+             -- <like-test-1.8>
+ })
+
+test:do_execsql_test(
+ "like-test-1.9",
+ [[
+ SELECT * FROM t WHERE s1 LIKE '%C';
+ ]], {
+             -- <like-test-1.9>
+
+             -- <like-test-1.9>
+ })
+
+test:do_execsql_test(
+ "like-test-1.10",
+ [[
+ SELECT * FROM t1 WHERE str LIKE '%df';
+ ]], {
+             -- <like-test-1.10>
+             2, 'abCDF', 3, 'CDF'
+             -- <like-test-1.10>
+ })
+
+test:do_execsql_test(
+ "like-test-1.11",
+ [[
+ SELECT * FROM t1 WHERE str LIKE 'a_';
+ ]], {
+             -- <like-test-1.11>
+             1, 'ab'
+             -- <like-test-1.11>
+ })
+
+test:do_execsql_test(
+ "like-test-1.12",
+ [[
+ SELECT column1, column2 FROM t2 WHERE column2 LIKE '__';
+ ]], {
+             -- <like-test-1.12>
+             1, 'AB', 1, 'CD', 2, 'AB'
+             -- <like-test-1.12>
+ })
+
+test:do_execsql_test(
+ "like-test-1.13",
+ [[
+ SELECT str FROM t1 WHERE str LIKE 'ab%';
+ ]], {
+ -- <like-test-1.13>
+ 'ab', 'abCDF'
+ -- <like-test-1.13>
+ })
+
+test:do_execsql_test(
+ "like-test-1.14",
+ [[
+ SELECT str FROM t1 WHERE str LIKE 'abC%';
+ ]], {
+ -- <like-test-1.14>
+ 'abCDF'
+ -- <like-test-1.14>
+ })
+
+test:do_execsql_test(
+ "like-test-1.15",
+ [[
+ SELECT str FROM t1 WHERE str LIKE 'a_%';
+ ]], {
+ -- <like-test-1.15>
+ 'ab', 'abCDF'
+ -- <like-test-1.15>
+ })
+
+test:do_execsql_test(
+ "like-test-1.16",
+ [[
+ DROP TABLE t1;
+ DROP TABLE t2;
+ DROP TABLE t;
+ ]], {
+             -- <like-test-1.16>
+
+             -- <like-test-1.16>
+ })
+
+test:finish_test()
 

--------------1371F97E039E1E00FAAAC14F--