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 CA0E13095B for ; Fri, 30 Nov 2018 20:12:58 -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 JuGKwRYldQVf for ; Fri, 30 Nov 2018 20:12:58 -0500 (EST) Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (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 64FA6290E3 for ; Fri, 30 Nov 2018 20:12:58 -0500 (EST) From: Roman Khabibov Subject: [tarantool-patches] [PATCH 1/2] sql: add CHAR description without length Date: Sat, 1 Dec 2018 04:12:50 +0300 Message-Id: <20181201011251.30573-1-roman.habibov@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: v.shpilevoy@tarantool.org 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( -- }) + +-- 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() -- 2.19.1