* [tarantool-patches] [PATCH 1/2] sql: add CHAR description without length @ 2018-12-01 1:12 Roman Khabibov 2018-12-01 1:12 ` [tarantool-patches] [PATCH 2/2] sql: add test for indexed char in sub subquery Roman Khabibov 2018-12-03 13:48 ` [tarantool-patches] Re: [PATCH 1/2] sql: add CHAR description without length Vladislav Shpilevoy 0 siblings, 2 replies; 3+ messages in thread From: Roman Khabibov @ 2018-12-01 1:12 UTC (permalink / raw) To: tarantool-patches; +Cc: v.shpilevoy Add ability to describe CHAR without specifying the length. Part of #3616 Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-3616-char-in-sub-subquery Issue: https://github.com/tarantool/tarantool/issues/3616 --- src/box/sql/parse.y | 16 +++++++++++-- test/sql-tap/table.test.lua | 47 ++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index 6dfc81f70..babfca23a 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -1486,12 +1486,24 @@ 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) . { +typedef(A) ::= CHAR char_len_typedef(B) . { A.type = AFFINITY_TEXT; (void) B; } -char_len_typedef(A) ::= LP INTEGER(B) RP . { +%type vchar_len_typedef {struct type_def} +typedef(A) ::= VARCHAR vchar_len_typedef(B) . { + A.type = AFFINITY_TEXT; + (void) B; +} + +char_len_typedef(A) ::= . { + (void) A; +} + +char_len_typedef(A) ::= vchar_len_typedef(A) . + +vchar_len_typedef(A) ::= LP INTEGER(B) RP . { (void) A; (void) B; } 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() -- 2.19.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [tarantool-patches] [PATCH 2/2] sql: add test for indexed char in sub subquery 2018-12-01 1:12 [tarantool-patches] [PATCH 1/2] sql: add CHAR description without length Roman Khabibov @ 2018-12-01 1:12 ` Roman Khabibov 2018-12-03 13:48 ` [tarantool-patches] Re: [PATCH 1/2] sql: add CHAR description without length Vladislav Shpilevoy 1 sibling, 0 replies; 3+ messages in thread From: Roman Khabibov @ 2018-12-01 1:12 UTC (permalink / raw) To: tarantool-patches; +Cc: v.shpilevoy Add test to check result for indexed char in sub subquery. Closes #3616 Branch: https://github.com/tarantool/tarantool/tree/romanhabibov/gh-3616-char-in-sub-subquery Issue: https://github.com/tarantool/tarantool/issues/3616 --- test/sql-tap/select6.test.lua | 91 ++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/test/sql-tap/select6.test.lua b/test/sql-tap/select6.test.lua index 6fdb4195e..a1fadb631 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,94 @@ 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; + DROP TABLE t2; + CREATE TABLE t1 (s1 INT PRIMARY KEY, u CHAR); + 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.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; + DROP TABLE t2; + CREATE TABLE t1 (s1 INT PRIMARY KEY, u INT); + 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.4> + 1 + -- </12.4> + }) + +test:do_execsql_test( + 12.5, + [[ + DROP TABLE t1; + DROP TABLE t2; + CREATE TABLE t1 (s1 INT PRIMARY KEY, u INT); + CREATE TABLE t2 (s1 INT PRIMARY KEY, u INT); + INSERT INTO t1 VALUES (1, 0); + INSERT INTO t2 VALUES (1, 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() -- 2.19.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [tarantool-patches] Re: [PATCH 1/2] sql: add CHAR description without length 2018-12-01 1:12 [tarantool-patches] [PATCH 1/2] sql: add CHAR description without length Roman Khabibov 2018-12-01 1:12 ` [tarantool-patches] [PATCH 2/2] sql: add test for indexed char in sub subquery Roman Khabibov @ 2018-12-03 13:48 ` Vladislav Shpilevoy 1 sibling, 0 replies; 3+ messages in thread From: Vladislav Shpilevoy @ 2018-12-03 13:48 UTC (permalink / raw) To: tarantool-patches, Roman Khabibov Hi! Thanks for the patch! Please, sending a patchset consisting from multiple commits send a cover-letter too. Branch and Issue links should be there. No cover-letter is ok only for single-commit patches. Talking about functional part - it is ok. But I've pushed one preparation patch before your: commit 7c0ef3cc962ce5724485b18c0da014625920bf3e Author: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Date: Mon Dec 3 16:16:51 2018 +0300 sql: store CHAR|VARCHAR len as integer, not type_def Please, send all the 3 commits as v2 thread to Nikita for a second review. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-12-03 13:48 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-12-01 1:12 [tarantool-patches] [PATCH 1/2] sql: add CHAR description without length Roman Khabibov 2018-12-01 1:12 ` [tarantool-patches] [PATCH 2/2] sql: add test for indexed char in sub subquery Roman Khabibov 2018-12-03 13:48 ` [tarantool-patches] Re: [PATCH 1/2] sql: add CHAR description without length Vladislav Shpilevoy
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox