From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id BA3E56EC58; Tue, 25 May 2021 12:02:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BA3E56EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1621933356; bh=rEE9GSQRetydReKDSz9arj5YzCnQFfL+mQe+0qUTc/I=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yo4JJ7u7o7892+z2ErYcwMV5s9fTQxYTjTN/Ezy5ULDQIqdfBF6HNQWVBrMxSBPg3 eXn0mMjkMSdLjxljqwlU2PvWf6INluy/eoZ4dpcrUKsbwaLjfhyChmxTHLedgA87rC S/myP9kIqizaAeusqiDFgcAcJsVFmPFkdt+2aVaE= Received: from smtp46.i.mail.ru (smtp46.i.mail.ru [94.100.177.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 725516EC58 for ; Tue, 25 May 2021 12:01:35 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 725516EC58 Received: by smtp46.i.mail.ru with esmtpa (envelope-from ) id 1llSwQ-0005YC-NU; Tue, 25 May 2021 12:01:35 +0300 To: tarantool-patches@dev.tarantool.org, imeevma@tarantool.org Date: Tue, 25 May 2021 12:01:01 +0300 Message-Id: <83da98665e41452e7c401e23d6fb646e6d4f6bbb.1621894609.git.tsafin@tarantool.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91B019B01C53E51AFA94C0B24B2C939D4C80F0683D6F6F7C600894C459B0CD1B9FAF8DCDFF1CD59D0F05128E8EB9B5ECD86E560675804A5CA1473A5891B7656E9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE75A6765C746F51968EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379F6495389D012EA98638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8D129FABAAEE190F2B094F233AF211CF3117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE38D4DC57D478E6889935A1E27F592749D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3893991AD1F2BFC6A6136E347CC761E07C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F790063764BD0C886786234BEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978314B2132A5FE2FB318BC778C3F84A8D0C8 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CDFB9373DB28FDDFBDD170CEB2BCFFCE22019337F84D04D5D9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF92B0BE0DA6BB795D699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34FACF503ACC83041B73497019C8A9B2C78D80252E6BF270A7D39A4860D795F719B4F4175B409E949B1D7E09C32AA3244C7EBFA74E426ED4B06D11A223428EAACE408A6A02710B7304FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXiFlDFT/xDPqs8oFX7zVcva X-Mailru-Sender: B5B6A6EBBD94DAD8C2E767F6285855A0E63C70BC1120C78F465538F9CE1ED6131B155545B1CDE02F5C2808D6142752370A8ED71B308007E3DC85537438B7E1A423D748DE48713E689437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: [Tarantool-patches] [PATCH 2/3] sql: enabled ANY as target for explicit conversions X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Timur Safin via Tarantool-patches Reply-To: Timur Safin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 --- extra/mkkeywordhash.c | 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(-) diff --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