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 C317A6EC40; Tue, 1 Jun 2021 17:03:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C317A6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622556217; bh=/n/wJotYEZAU3TXXB84s6HF9IyeFU/39A76jbY6v27o=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=LytL9I2aZGUORZJEKGj2MsoZEXZ3F5YvMOSt1bimIV37pe+hEC88eTBjggqkZxtxJ LH//E+/WzHIF+mklrk8YZK1aeF3yzz0sD9WWtgtcFdujO1bvTFcOD+oz2SFe2QDLfV c0bLyp290OchsSWToIb3OMijuY3oaNsSJyrB3etM= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 613046EC40 for ; Tue, 1 Jun 2021 17:02:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 613046EC40 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1lo4yh-0004Qn-OM; Tue, 01 Jun 2021 17:02:44 +0300 To: Timur Safin Cc: tarantool-patches@dev.tarantool.org References: <83da98665e41452e7c401e23d6fb646e6d4f6bbb.1621894609.git.tsafin@tarantool.org> Message-ID: <346444c0-0862-9a68-77ea-57fcd86d3859@tarantool.org> Date: Tue, 1 Jun 2021 17:02:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <83da98665e41452e7c401e23d6fb646e6d4f6bbb.1621894609.git.tsafin@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C549A9F97C297FFF2C725C7934AD8E7B4B9182A05F538085040FFC7649AA598D228FFD705EECAD589176F9250C8C79FBF88E97B30B08803F98C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71EEA4C46C73542F4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372094AD700861FA748638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D868FC313DCE761720D4C5E36C8B3FD0BA117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18CB629EEF1311BF91D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B66F6A3E018CF4DC80089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5124500B1D034E9E033984C03D6A5FED783618425AEAA842CD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75FBC5FED0552DA851410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340EEB18E49183157128CE57AF13D3A240BA1237F3BB6FB3BBC1948C189D8A7B918991409C9AAF99371D7E09C32AA3244CC26F7345E0891F551A8D532189E5CFF4853296C06374E602729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojt1KCq4WZgK7J+oLPCIu8ow== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638228527573313FB107975C0807057F7FCD283D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [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: Mergen Imeev via Tarantool-patches Reply-To: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thank you for the patch. See 10 comments below. 1. I believe we do not have field type ANY in SQL. Also, I believe that to add it to explicit cast we have to add it to SQL. 2. What this patch actually does? I mean, after this patch I still not able to cast values to ANY: tarantool> box.execute('SELECT CAST(1 AS ANY);') --- - null - 'At line 1 at or near position 18: keyword ''ANY'' is reserved. Please use double quotes if ''ANY'' is an identifier.' ... On Tue, May 25, 2021 at 12:01:01PM +0300, Timur Safin wrote: > 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. > 3. I still think that it is better to put RFC name instead of this relative link. > 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. > 4. There is no way to create literal, however you can use space with field type ANY, right? > | 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 | > +---+---+---+---+---+---+---+---+---+---+---+---+---+ > 5. This strange order again. 6. Again, do you really need this table in commit-message? This time it is also a lot simpler to just describe this explicit conversion rules using words. > * 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 7. Wrong issue number. Also, I am again not sure that you should include "Relates to" here. > --- > 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 }, 8. Why some types describes as TK_ID, and some as TK_? > { "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 }, 9. Why not name it as TK_WILDCARD to avoid further misunderstanding? > { "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 > 10. Why there is no tests?