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 B563A6EC41; Thu, 3 Jun 2021 00:04:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B563A6EC41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622667895; bh=KKe3o+CeG1Q0yMWA73SR3wUc/lbdMmHzoBpSNwS3CF0=; h=To:Cc:References:In-Reply-To:Date:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=rlhff+qAC8q2qgiL8LdSdcp/04deYDvSkF4+OvhvIVi5ju0yUOM52tXdLb5kKg1ME ejc2uGGOez7F3qXsYC7mhRxPT/U8vLaIM/fH0Pa0PLF6teb6JbZcuEeEFImtgf6119 g9C3YYzaK6g4W1//HanxDoquuyVAjrwv62Gi7KWQ= Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (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 E94876EC41 for ; Thu, 3 Jun 2021 00:04:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E94876EC41 Received: by smtp36.i.mail.ru with esmtpa (envelope-from ) id 1loY2A-00057Z-9k; Thu, 03 Jun 2021 00:04:14 +0300 To: "'Mergen Imeev'" Cc: References: <83da98665e41452e7c401e23d6fb646e6d4f6bbb.1621894609.git.tsafin@tarantool.org> <346444c0-0862-9a68-77ea-57fcd86d3859@tarantool.org> In-Reply-To: <346444c0-0862-9a68-77ea-57fcd86d3859@tarantool.org> Date: Thu, 3 Jun 2021 00:04:13 +0300 Message-ID: <053101d757f2$d7a73280$86f59780$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIN143y2CAuVXbaZAstAFvLluhQBgHLe7G+Arpu6Lmqb/uFEA== Content-Language: ru X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C549A9F97C297FFF2C725C7934AD8E7B4B9182A05F5380850402CFD7EDCCA30BEEA4DA0B72FDF7DC8175713754FACDA0B2BD430718C096838CA X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7BF6699A3AA9BACA6EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063770398A047C76876C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8728B3CD41559460C715EB1DD4D0B59F4117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF80095D1E57F4578A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE599709FD55CB46A68F49F126DDB898E8D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE313BDA61BF53F5E1DC0837EA9F3D19764C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BBEA499411984DA1EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD494FFA51BD827F93233AD276573E7B44 X-C1DE0DAB: 0D63561A33F958A5D602EDDFCDFFE55F63D237CE17ACA7B59CF918B44CA732EDD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75FBC5FED0552DA851410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34128DEC38EFF4BE5A763B4DE4D3BDBF9E72CC82A95BFBD7577AF581FC8B69186121758720AC51961D1D7E09C32AA3244C60D9C11B28B48127FD2BD6C4727BD650259227199D06760A729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+mfSpkNmA2qF+MxTPuLrBw== X-Mailru-Sender: B5B6A6EBBD94DAD840208BF9E14C1DD267CAAAC99014A0C16BDF3CA5755BBB9393B4A7D274D4FA801EC9E4A2C82A33BC8C24925A86E657CE0C70AEE3C9A96FBAB3D7EE8ED63280BE112434F685709FCF0DA7A0AF5A3A8387 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: Timur Safin via Tarantool-patches Reply-To: Timur Safin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" : From: Mergen Imeev : Sent: Tuesday, June 1, 2021 5:03 PM : To: Timur Safin : Cc: tarantool-patches@dev.tarantool.org : Subject: Re: [PATCH 2/3] sql: enabled ANY as target for explicit = conversions :=20 : Thank you for the patch. See 10 comments below. :=20 : 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. Yes, there is no way to declare field of ANY type, or create such = literal. But As result of discussion, for consistency sake (with SCALAR) it was = decided to still allow=20 explicit cast to ANY, just as plain noop. :=20 : 2. What this patch actually does? I mean, after this patch I still not = able : to cast values to ANY: :=20 : 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.' : ... That's odd - I've seen such behavior when there was no renamed %wildcard = ANY and=20 Old generated parser code. It was working for me with that old patch, = but will check. :=20 : 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. Whatever. :=20 : > 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? Nope, SQL is strict-typed language at runtime. ANY is NoSQL type, and there should be no way to declare untyped field. But if, by any chance, we have received data of `any` type from Lua side, then we should have some means to at least cast to it expression. :=20 : > | 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. This order is from illustrations of the spec. It's too late to redraw all pictures there, but reordering here is easy. So we need to live=20 with this order forever :( :=20 : 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. Picture worth thousand words. You tend to prefer wording, many prefer pictures. :=20 : > * 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. Relates will allow us to keep them linked with parent specification. Even if there will be multiple steps and commits. :=20 : > --- : > 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[] =3D { : > { "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_? :=20 : > { "AND", "TK_AND", true }, : > { "AS", "TK_AS", true }, : > { "ASC", "TK_ASC", true }, : > @@ -178,7 +179,7 @@ static Keyword aKeywordTable[] =3D { : > { "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? :=20 : > { "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) !=3D 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 ::=3D 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) ::=3D SCALAR . { A.type =3D : FIELD_TYPE_SCALAR; } : > typedef(A) ::=3D BOOL . { A.type =3D FIELD_TYPE_BOOLEAN; } : > typedef(A) ::=3D BOOLEAN . { A.type =3D FIELD_TYPE_BOOLEAN; } : > typedef(A) ::=3D VARBINARY . { A.type =3D FIELD_TYPE_VARBINARY; } : > +typedef(A) ::=3D ANY . { A.type =3D 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 =3D 'CREATE TABLE '..kw..'(a INT PRIMARY KEY);' : > if kw =3D=3D 'end' or kw =3D=3D 'match' or kw =3D=3D 'release' = or kw =3D=3D 'rename' : or : > kw =3D=3D 'replace' or kw =3D=3D 'binary' or kw =3D=3D = 'character' or : > - kw =3D=3D 'smallint' then : > + kw =3D=3D 'smallint' or kw =3D=3D 'any' then : > test:do_catchsql_test( : > "bannedkw1-"..kw..".1", : > query, { : > -- : > 2.29.2 : > : 10. Why there is no tests? All newly introduced modifications extensively covered in = e_casts.test.lua test you see the other patch. [And I really mean "extensively", because = test matrix there covers hundreds and hundreds of test cases, which is impossible to = cover=20 with manual result-based test. Regardless how hard you try and how = careful you are] I'll merge all explicit conversion code changes with corresponding part = of e_casts.test.lua if we had to have test in the same commit. Timur