From: Timur Safin via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org, imeevma@tarantool.org
Subject: [Tarantool-patches] [PATCH 2/3] sql: enabled ANY as target for explicit conversions
Date: Tue, 25 May 2021 12:01:01 +0300 [thread overview]
Message-ID: <83da98665e41452e7c401e23d6fb646e6d4f6bbb.1621894609.git.tsafin@tarantool.org> (raw)
In-Reply-To: <cover.1621894609.git.tsafin@tarantool.org>
For consistency sake it was decided to provide
`CAST(anything TO ANY)` as allowed, but still noop.
Fuller explicit conversions table is described in the
/doc/rfc/5910-consistent-sql-lua-types.md and here we
represent only relevant to ANY.
Furthermore, there is no direct way in SQL to create literal and
expression of ANY type, thus there is no defined CAST from ANY
to anything else.
| 0 | 1 | 2 | 4 | 5 | 6 | 7 | 3 | 9 |10 |11 |12 | 8 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+
0. any | | | | | | | | | | | | | |
1. unsigned | | . | . | . | . | | | . | | | | | Y |
2. string | | . | . | . | . | . | . | . | | | | | Y |
4. double | | . | . | . | . | | | . | | | | | Y |
5. integer | | . | . | . | . | | | . | | | | | Y |
6. boolean | | | . | | | . | | | | | | | Y |
7. varbinary | | | . | | | | . | | | | | | Y |
3. number | | . | . | . | . | | | . | | | | | Y |
9. decimal | | | | | | | | | | | | | |
10. uuid | | | | | | | | | | | | | |
11. array | | | | | | | | | | | | | |
12. map | | | | | | | | | | | | | |
8. scalar | | . | . | . | . | . | . | . | | | | | Y |
+---+---+---+---+---+---+---+---+---+---+---+---+---+
* We introduced new token ANY as known lexem to the Lemon parser.
While renamed prior %wildcard to ANYTHING;
* Modified explicit conversion rules to allow ANY as _target_ in
conversion pair.
Relates to #5910, #6009
Part of #4407
---
| 3 ++-
src/box/sql/mem.c | 2 ++
src/box/sql/parse.y | 3 ++-
test/sql-tap/keyword1.test.lua | 2 +-
4 files changed, 7 insertions(+), 3 deletions(-)
--git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c
index 7480c0211..d343cf706 100644
--- a/extra/mkkeywordhash.c
+++ b/extra/mkkeywordhash.c
@@ -60,6 +60,7 @@ static Keyword aKeywordTable[] = {
{ "ALL", "TK_ALL", true },
{ "ALTER", "TK_ALTER", true },
{ "ANALYZE", "TK_STANDARD", true },
+ { "ANY", "TK_ID", true },
{ "AND", "TK_AND", true },
{ "AS", "TK_AS", true },
{ "ASC", "TK_ASC", true },
@@ -178,7 +179,7 @@ static Keyword aKeywordTable[] = {
{ "WITH", "TK_WITH", true },
{ "WHEN", "TK_WHEN", true },
{ "WHERE", "TK_WHERE", true },
- { "ANY", "TK_STANDARD", true },
+ { "ANYTHING", "TK_STANDARD", true },
{ "ASENSITIVE", "TK_STANDARD", true },
{ "BLOB", "TK_STANDARD", true },
{ "BINARY", "TK_ID", true },
diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
index d40366754..b4f1078ae 100644
--- a/src/box/sql/mem.c
+++ b/src/box/sql/mem.c
@@ -874,6 +874,8 @@ mem_cast_explicit(struct Mem *mem, enum field_type type)
(mem->flags & MEM_Subtype) != 0)
return -1;
return 0;
+ case FIELD_TYPE_ANY:
+ return 0;
default:
break;
}
diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
index abc363951..e586d0181 100644
--- a/src/box/sql/parse.y
+++ b/src/box/sql/parse.y
@@ -270,7 +270,7 @@ columnlist ::= tcons.
QUERY KEY OFFSET RAISE RELEASE REPLACE RESTRICT
RENAME CTIME_KW IF ENABLE DISABLE
.
-%wildcard ANY.
+%wildcard ANYTHING.
// And "ids" is an identifer-or-string.
@@ -1834,6 +1834,7 @@ typedef(A) ::= SCALAR . { A.type = FIELD_TYPE_SCALAR; }
typedef(A) ::= BOOL . { A.type = FIELD_TYPE_BOOLEAN; }
typedef(A) ::= BOOLEAN . { A.type = FIELD_TYPE_BOOLEAN; }
typedef(A) ::= VARBINARY . { A.type = FIELD_TYPE_VARBINARY; }
+typedef(A) ::= ANY . { A.type = FIELD_TYPE_ANY; }
/**
* Time-like types are temporary disabled, until they are
diff --git a/test/sql-tap/keyword1.test.lua b/test/sql-tap/keyword1.test.lua
index f9a9c6865..4855f3ebc 100755
--- a/test/sql-tap/keyword1.test.lua
+++ b/test/sql-tap/keyword1.test.lua
@@ -242,7 +242,7 @@ for _, kw in ipairs(bannedkws) do
local query = 'CREATE TABLE '..kw..'(a INT PRIMARY KEY);'
if kw == 'end' or kw == 'match' or kw == 'release' or kw == 'rename' or
kw == 'replace' or kw == 'binary' or kw == 'character' or
- kw == 'smallint' then
+ kw == 'smallint' or kw == 'any' then
test:do_catchsql_test(
"bannedkw1-"..kw..".1",
query, {
--
2.29.2
next prev parent reply other threads:[~2021-05-25 9:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-25 9:00 [Tarantool-patches] [PATCH 0/3] sql: modify explicit conversion tables Timur Safin via Tarantool-patches
2021-05-25 9:01 ` [Tarantool-patches] [PATCH 1/3] sql: fixes for boolean expressions in explicit converstion tables Timur Safin via Tarantool-patches
2021-06-01 14:02 ` Mergen Imeev via Tarantool-patches
2021-06-02 21:03 ` Timur Safin via Tarantool-patches
2021-06-02 21:10 ` Timur Safin via Tarantool-patches
2021-05-25 9:01 ` Timur Safin via Tarantool-patches [this message]
2021-06-01 14:02 ` [Tarantool-patches] [PATCH 2/3] sql: enabled ANY as target for explicit conversions Mergen Imeev via Tarantool-patches
2021-06-02 21:04 ` Timur Safin via Tarantool-patches
2021-05-25 9:01 ` [Tarantool-patches] [PATCH 3/3] sql: introduced explicit casts test e_casts.test.lua Timur Safin via Tarantool-patches
2021-06-01 14:02 ` Mergen Imeev via Tarantool-patches
2021-06-02 21:04 ` Timur Safin via Tarantool-patches
2021-06-01 14:02 ` [Tarantool-patches] [PATCH 0/3] sql: modify explicit conversion tables Mergen Imeev via Tarantool-patches
2021-06-02 21:04 ` Timur Safin via Tarantool-patches
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=83da98665e41452e7c401e23d6fb646e6d4f6bbb.1621894609.git.tsafin@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=imeevma@tarantool.org \
--cc=tsafin@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH 2/3] sql: enabled ANY as target for explicit conversions' \
/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