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 A218220862 for ; Sat, 8 Dec 2018 16:21:10 -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 9iWjik1TghxU for ; Sat, 8 Dec 2018 16:21:10 -0500 (EST) Received: from smtp51.i.mail.ru (smtp51.i.mail.ru [94.100.177.111]) (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 E403B2085E for ; Sat, 8 Dec 2018 16:21:09 -0500 (EST) Subject: [tarantool-patches] Re: [PATCH 0/3 v2] sql: add test for indexed char in sub subquery References: <97B7ED6F-8AD4-47D4-B988-32958A4B1370@tarantool.org> From: roman Message-ID: <5e0cdcca-9089-e53e-4475-e4f7eeb5961b@tarantool.org> Date: Sun, 9 Dec 2018 00:21:01 +0300 MIME-Version: 1.0 In-Reply-To: <97B7ED6F-8AD4-47D4-B988-32958A4B1370@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit 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: tarantool-patches@freelists.org, "n.pettik" Cc: Vladislav Shpilevoy Sorry. Forgot to attach diff. diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index 6dfc81f70..50bb2ba01 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -1485,17 +1485,26 @@ typedef(A) ::= DATE . { A.type = AFFINITY_REAL; }  typedef(A) ::= TIME . { A.type = AFFINITY_REAL; }  typedef(A) ::= DATETIME . { A.type = AFFINITY_REAL; } -%type char_len_typedef {struct type_def} -typedef(A) ::= CHAR|VARCHAR char_len_typedef(B) . { +%type char_len {int} +typedef(A) ::= CHAR . {    A.type = AFFINITY_TEXT; -  (void) B;  } -char_len_typedef(A) ::= LP INTEGER(B) RP . { +char_len(A) ::= LP INTEGER(B) RP . {    (void) A;    (void) B;  } +typedef(A) ::= CHAR char_len(B) . { +  A.type = AFFINITY_TEXT; +  (void) B; +} + +typedef(A) ::= VARCHAR char_len(B) . { +  A.type = AFFINITY_TEXT; +  (void) B; +} +  %type number_typedef {struct type_def}  typedef(A) ::= number_typedef(A) .  number_typedef(A) ::= FLOAT|REAL|DOUBLE . { A.type = AFFINITY_REAL; } diff --git a/test/sql-tap/select6.test.lua b/test/sql-tap/select6.test.lua index 6fdb4195e..9a0fe6efb 100755 --- a/test/sql-tap/select6.test.lua +++ b/test/sql-tap/select6.test.lua @@ -1,6 +1,6 @@  #!/usr/bin/env tarantool  test = require("sqltester") -test:plan(83) +test:plan(88)  --!./tcltestrunner.lua  -- 2001 September 15 @@ -1052,5 +1052,84 @@ test:do_execsql_test(          --      }) +-- gh-3616 Check result for indexed char in sub subquery. + +test:do_execsql_test( +    12.1, +    [[ +        DROP TABLE t1; +        DROP TABLE t2; +        CREATE TABLE t1 (s1 INT PRIMARY KEY, u CHAR UNIQUE); +        CREATE TABLE t2 (s1 INT PRIMARY KEY, u CHAR); +        INSERT INTO t1 VALUES (1,''); +        INSERT INTO t2 VALUES (1,''); +        SELECT COUNT(*) FROM t1 WHERE u IN +                (SELECT u FROM t2 WHERE u IN (SELECT u FROM t1)); +    ]], { +        -- <12.1> +        1 +        -- +    }) + +test:do_execsql_test( +    12.2, +    [[ +        DROP TABLE t1; +        CREATE TABLE t1 (s1 INT PRIMARY KEY, u CHAR); +        INSERT INTO t1 VALUES (1,''); +        SELECT COUNT(*) FROM t1 WHERE u IN +                (SELECT u FROM t2 WHERE u IN (SELECT u FROM t1)); +    ]], { +        -- <12.2> +        1 +        -- +    }) + +test:do_execsql_test( +    12.3, +    [[ +        DROP TABLE t1; +        DROP TABLE t2; +        CREATE TABLE t1 (s1 INT PRIMARY KEY, u INT UNIQUE); +        CREATE TABLE t2 (s1 INT PRIMARY KEY, u INT); +        INSERT INTO t1 VALUES (1, 0); +        INSERT INTO t2 VALUES (1, 0); +        SELECT COUNT(*) FROM t1 WHERE u IN +                (SELECT u FROM t2 WHERE u IN (SELECT u FROM t1)); +    ]], { +        -- <12.3> +        1 +        -- +    }) + +test:do_execsql_test( +    12.4, +    [[ +        DROP TABLE t1; +        CREATE TABLE t1 (s1 INT PRIMARY KEY, u INT); +        INSERT INTO t1 VALUES (1, 0); +        SELECT COUNT(*) FROM t1 WHERE u IN +                (SELECT u FROM t2 WHERE u IN (SELECT u FROM t1)); +    ]], { +        -- <12.4> +        1 +        -- +    }) + +test:do_execsql_test( +    12.5, +    [[ +        UPDATE t2 +          SET u = 1; +        SELECT COUNT(*) FROM t1 WHERE u IN +                (SELECT u FROM t2 WHERE u IN (SELECT u FROM t1)); +        DROP TABLE t1; +        DROP TABLE t2; +    ]], { +        -- <12.5> +        0 +        -- +    }) +  test:finish_test() diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua index 7fd9bac9f..71645e2e2 100755 --- a/test/sql-tap/table.test.lua +++ b/test/sql-tap/table.test.lua @@ -1,6 +1,6 @@  #!/usr/bin/env tarantool  test = require("sqltester") -test:plan(74) +test:plan(78)  --!./tcltestrunner.lua  -- 2001 September 15 @@ -1393,4 +1393,49 @@ test:do_execsql_test(          --      }) + +-- gh-3616 Add char type without length in definitions. + +test:do_execsql_test( +    "table-23.1", +    [[ +        CREATE TABLE T23( +           id INT PRIMARY KEY, +           u CHAR +        ); +    ]], { +        -- + +        -- +    }) + +test:do_execsql_test( +    "table-23.2", +    [[ +        INSERT INTO T23 VALUES (1, 'a'), (2, 'b'); +    ]], { +        -- + +        -- +    }) + +test:do_execsql_test( +    "table-23.3", +    [[ +        SELECT u FROM T23; +    ]], { +        -- +        "a","b" +        -- +    }) + +test:do_execsql_test( +    "check-23.cleanup", +    [[ +        DROP TABLE IF EXISTS t23; +    ]], { +        -- + +        -- +    })  test:finish_test()