Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kostja@tarantool.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] [PATCH 1/2] sql: add STRING alias to TEXT type
Date: Tue, 30 Jul 2019 02:34:10 +0300	[thread overview]
Message-ID: <c07cc1e98d21b70792ef79696a341f76dec936f4.1564437728.git.korablev@tarantool.org> (raw)
In-Reply-To: <cover.1564437728.git.korablev@tarantool.org>
In-Reply-To: <cover.1564437728.git.korablev@tarantool.org>

TEXT type is called "string" in the original Tarantool NoSQL, so it would
be rational to allow using the same type name in SQL.
---
 extra/mkkeywordhash.c   |  1 +
 src/box/sql/parse.y     |  1 +
 test/sql/types.result   | 13 +++++++++++++
 test/sql/types.test.lua |  6 ++++++
 4 files changed, 21 insertions(+)

diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c
index 64a5bbfc6..a353d4781 100644
--- a/extra/mkkeywordhash.c
+++ b/extra/mkkeywordhash.c
@@ -176,6 +176,7 @@ static Keyword aKeywordTable[] = {
   { "SET",                    "TK_SET",         ALWAYS,           true  },
   { "SIMPLE",                 "TK_SIMPLE",      ALWAYS,           true  },
   { "START",                  "TK_START",       ALWAYS,           true  },
+  { "STRING",                 "TK_STRING_KW",   ALWAYS,           true  },
   { "TABLE",                  "TK_TABLE",       ALWAYS,           true  },
   { "THEN",                   "TK_THEN",        ALWAYS,           true  },
   { "TO",                     "TK_TO",          ALWAYS,           true  },
diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
index d4e1ec859..3929ed9c6 100644
--- a/src/box/sql/parse.y
+++ b/src/box/sql/parse.y
@@ -1725,6 +1725,7 @@ wqlist(A) ::= wqlist(A) COMMA nm(X) eidlist_opt(Y) AS LP select(Z) RP. {
 ////////////////////////////// TYPE DECLARATION ///////////////////////////////
 %type typedef {struct type_def}
 typedef(A) ::= TEXT . { A.type = FIELD_TYPE_STRING; }
+typedef(A) ::= STRING_KW . { A.type = FIELD_TYPE_STRING; }
 typedef(A) ::= SCALAR . { A.type = FIELD_TYPE_SCALAR; }
 /** BOOL | BOOLEAN is not used due to possible bug in Lemon. */
 typedef(A) ::= BOOL . { A.type = FIELD_TYPE_BOOLEAN; }
diff --git a/test/sql/types.result b/test/sql/types.result
index 4589b2d58..0dc90d5a4 100644
--- a/test/sql/types.result
+++ b/test/sql/types.result
@@ -1751,3 +1751,16 @@ box.execute("SELECT CAST('-123' AS UNSIGNED);")
 box.space.T1:drop()
 ---
 ...
+-- Check that STRING is a valid alias to TEXT type.
+--
+box.execute("CREATE TABLE t (id STRING PRIMARY KEY);")
+---
+- row_count: 1
+...
+box.space.T:format()[1].type
+---
+- string
+...
+box.space.T:drop()
+---
+...
diff --git a/test/sql/types.test.lua b/test/sql/types.test.lua
index f07a90b37..06de8c977 100644
--- a/test/sql/types.test.lua
+++ b/test/sql/types.test.lua
@@ -399,3 +399,9 @@ box.execute("SELECT CAST('123' AS UNSIGNED);")
 box.execute("SELECT CAST('-123' AS UNSIGNED);")
 
 box.space.T1:drop()
+
+-- Check that STRING is a valid alias to TEXT type.
+--
+box.execute("CREATE TABLE t (id STRING PRIMARY KEY);")
+box.space.T:format()[1].type
+box.space.T:drop()
-- 
2.15.1

  reply	other threads:[~2019-07-29 23:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-29 23:34 [tarantool-patches] [PATCH 0/2] Fix type aliases in SQL Nikita Pettik
2019-07-29 23:34 ` Nikita Pettik [this message]
2019-07-30  7:18   ` [tarantool-patches] Re: [PATCH 1/2] sql: add STRING alias to TEXT type Konstantin Osipov
2019-07-30  7:19   ` Konstantin Osipov
2019-07-29 23:34 ` [tarantool-patches] [PATCH 2/2] sql: rename REAL/FLOAT/DOUBLE types to NUMBER Nikita Pettik
2019-07-30  7:21   ` [tarantool-patches] " Konstantin Osipov
2019-07-30 14:21 ` [tarantool-patches] Re: [PATCH 0/2] Fix type aliases in SQL 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=c07cc1e98d21b70792ef79696a341f76dec936f4.1564437728.git.korablev@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 1/2] sql: add STRING alias to TEXT type' \
    /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