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 2D88D24EDE for ; Mon, 29 Jul 2019 19:34:17 -0400 (EDT) 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 Xry-6Kq7TtqR for ; Mon, 29 Jul 2019 19:34:17 -0400 (EDT) Received: from smtp56.i.mail.ru (smtp56.i.mail.ru [217.69.128.36]) (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 8970324E78 for ; Mon, 29 Jul 2019 19:34:16 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 1/2] sql: add STRING alias to TEXT type Date: Tue, 30 Jul 2019 02:34:10 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: 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: kostja@tarantool.org, Nikita Pettik 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