Tarantool development patches archive
 help / color / mirror / Atom feed
From: Roman Khabibov <roman.habibov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: vdavydov.dev@gmail.com
Subject: [PATCH 2/3 v2] sql: add CHAR description without length
Date: Wed,  5 Dec 2018 02:47:29 +0300	[thread overview]
Message-ID: <55ac10f0c10d33658c8c870aa350be57851d4ac3.1543941445.git.roman.habibov@tarantool.org> (raw)
In-Reply-To: <cover.1543941445.git.roman.habibov@tarantool.org>

Fix an ability to describe CHAR without specifying the
length as it is allowed by standard. It was
accidentally broken by this commit:
7752cdfd31f9956a4d6bb0f306c561a0ac73e7ab

Needed for #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 5f64bfe8c..f5e86fba1 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 {int}
-typedef(A) ::= CHAR|VARCHAR char_len(B) . {
+typedef(A) ::= CHAR char_len(B) . {
   A.type = AFFINITY_TEXT;
   (void) B;
 }
 
-char_len(A) ::= LP INTEGER(B) RP . {
+%type vchar_len {int}
+typedef(A) ::= VARCHAR vchar_len(B) . {
+  A.type = AFFINITY_TEXT;
+  (void) B;
+}
+
+char_len(A) ::=  . {
+  (void) A;
+}
+
+char_len(A) ::=  vchar_len(A) .
+
+vchar_len(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

  parent reply	other threads:[~2018-12-04 23:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04 23:47 [PATCH 0/3 v2] sql: add test for indexed char in sub subquery 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 ` Roman Khabibov [this message]
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
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=55ac10f0c10d33658c8c870aa350be57851d4ac3.1543941445.git.roman.habibov@tarantool.org \
    --to=roman.habibov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [PATCH 2/3 v2] sql: add CHAR description without length' \
    /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