Tarantool development patches archive
 help / color / mirror / Atom feed
From: roman <roman.habibov@tarantool.org>
To: tarantool-patches@freelists.org, "n.pettik" <korablev@tarantool.org>
Cc: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 0/3 v2] sql: add test for indexed char in sub subquery
Date: Sun, 9 Dec 2018 00:21:01 +0300	[thread overview]
Message-ID: <5e0cdcca-9089-e53e-4475-e4f7eeb5961b@tarantool.org> (raw)
In-Reply-To: <97B7ED6F-8AD4-47D4-B988-32958A4B1370@tarantool.org>

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(
          -- </11.100>
      })

+-- 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
+        -- </12.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
+        -- </12.2>
+    })
+
+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
+        -- </12.3>
+    })
+
+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
+        -- </12.4>
+    })
+
+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
+        -- </12.5>
+    })
+
  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(

          -- </check-22.cleanup>
      })
+
+-- 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
+        );
+    ]], {
+        -- <table-23.2>
+
+        -- </table-23.2>
+    })
+
+test:do_execsql_test(
+    "table-23.2",
+    [[
+        INSERT INTO T23 VALUES (1, 'a'), (2, 'b');
+    ]], {
+        -- <table-23.2>
+
+        -- </table-23.2>
+    })
+
+test:do_execsql_test(
+    "table-23.3",
+    [[
+        SELECT u FROM T23;
+    ]], {
+        -- <table-23.3>
+        "a","b"
+        -- </table-23.3>
+    })
+
+test:do_execsql_test(
+    "check-23.cleanup",
+    [[
+        DROP TABLE IF EXISTS t23;
+    ]], {
+        -- <check-23.cleanup>
+
+        -- </check-23.cleanup>
+    })
  test:finish_test()

  parent reply	other threads:[~2018-12-08 21:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 23:47 Roman Khabibov
2018-12-04 23:47 ` [PATCH 1/3 v2] sql: store CHAR|VARCHAR len as integer, not type_def Roman Khabibov
2018-12-04 23:47 ` [PATCH 2/3 v2] sql: add CHAR description without length Roman Khabibov
2018-12-04 23:47 ` [PATCH 3/3 v2] sql: add test for indexed char in sub subquery Roman Khabibov
2018-12-05 20:35 ` [tarantool-patches] [PATCH 0/3 " Vladislav Shpilevoy
2018-12-07 11:20   ` [tarantool-patches] " n.pettik
2018-12-07 11:27     ` Vladislav Shpilevoy
2018-12-07 15:59       ` n.pettik
2018-12-08 16:49     ` roman
2018-12-08 21:21     ` roman [this message]
2018-12-08 21:56       ` n.pettik
2018-12-14  5:47 ` [tarantool-patches] " Kirill Yukhin

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=5e0cdcca-9089-e53e-4475-e4f7eeb5961b@tarantool.org \
    --to=roman.habibov@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH 0/3 v2] sql: add test for indexed char in sub subquery' \
    /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