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 B86A56EC55; Fri, 11 Jun 2021 10:48:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B86A56EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623397708; bh=LeDyUuweMKgmEd+nIWxtblHAqtR9U5ZcqpIsipK/o6k=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=T529AOZnqG8yMPKxp61cF0EhowsVRPTu7LrZ1vIW3ayp04hYiUjSN1gpAbrr3jsTh Pb1TEm7WUqH2BuK7NhPAuhfakl7mbRP4CGdfqOrkitLq8c2OWX34+GVpU/Z1hcXHhf Y7U1tAFSMIIjQ3vcQahRMKAIXzHxpbAb7pR2Vpc8= Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (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 731586EC55 for ; Fri, 11 Jun 2021 10:48:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 731586EC55 Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1lrbtz-0001PD-9i; Fri, 11 Jun 2021 10:48:27 +0300 To: imeevma@tarantool.org Date: Fri, 11 Jun 2021 10:48:10 +0300 Message-Id: X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C540E30C2BDD69416C6E46C178CD572CB10182A05F53808504087D1AB2A3B10B02E139DD4E856E29E8B5B0584360D0CECE2C9829DF49AC6213D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7B9FBA884A7C9B8BAEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D3A9DC970DD6E2F6EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BD6CF32B5F8F9D4043E5C64169B5ED205F5F7F084E0238F9DCC7F00164DA146DAFE8445B8C89999728AA50765F79006370BDB19F53EE528DD389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8D2DCF9CF1F528DBCF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C1B3F1E879BC1E2F1040F9FF01DFDA4A84AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C3809CE7B25EB0CC6ABA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7E1BCFB2C0BE3F189731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C8874A2D3FA5089FE439382DEB1B618FB5A59A953A09F7C8A9C2B6934AE262D3EE7EAB7254005DCED91AE2E076B69AE4EC581CE5390BD6510078749EA292E75700EA540613ABC294F04EBA3D8E7E5B87ABF8C51168CD8EBDB5FC25ED3FCEC3375DC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34F6110710A6CC527FD31E779C19F71C5B527751E74A94163BC502CC1BD56AB3DA82FC0B4665CD52731D7E09C32AA3244C57D0E4BBBA25019A01322E7542F17E4439C99C45E8D137E9FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXh6pWKRNkcpuajtZBt+Xhwn X-Mailru-Sender: 6CA451E36783D721CBEA96CEA26D325D5B83CF6CCDECB754C364207B9E371BAFB7CBEF92542CD7C82F97C478340294DCC77752E0C033A69E0F0C7111264B8915FF1320A92A5534336C18EFA0BB12DBB0 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 0/3] sql: modify explicit and implicit conversion tables 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 Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Issues: https://github.com/tarantool/tarantool/issues/4470 https://github.com/tarantool/tarantool/issues/6010 Branch: https://github.com/tarantool/tarantool/tree/tsafin/gh-4470-explicit-implicit-conversions-V2 This patchset containes of 2 major part and 1 bonus. Major parts are changes in explicit and implicit conversion tables, with all accompanying tests we have so far (and 1 extensive test introduced). The bonus part is for improvements in the testing system tap.lua which became apparent during debugging of this patches. Relates to #5910, #6009 Part of #4470 Fixes #6010 Explicit table ============== As we discovered harder way, there is no need to introduce so much changes to the current explicit conversion table, because it's mostly compliant already: - most of changes we had to do was about `BOOLEAN` conversions, which are stricter now than before; - there are addition of to `ANY` conversion, which we have decided to make behaving similar to `SCALAR` conversions; Those changes could be visualized via this table: | 0 | 1 | 2 | 4 | 5 | 6 | 7 | 3 | 9 |10 |11 |12 | 8 | +---+---+---+---+---+---+---+---+---+---+---+---+---+ 0. any | | | | | | | | | | | | | | 1. unsigned | | . | . | . | . | - | | . | | | | | Y | 2. string | | . | . | . | . | S | . | . | | | | | Y | 4. double | | . | . | . | . | - | | . | | | | | Y | 5. integer | | . | . | . | . | - | | . | | | | | Y | 6. boolean | | - | Y | - | - | Y | | | | | | | Y | 7. varbinary | | | . | | | - | . | | | | | | Y | 3. number | | . | . | . | . | - | | . | | | | | Y | 9. decimal | | | | | | | | | | | | | | 10. uuid | | | | | | | | | | | | | | 11. array | | | | | | | | | | | | | | 12. map | | | | | | | | | | | | | | 8. scalar | | . | . | . | . | S | . | . | | | | | Y | +---+---+---+---+---+---+---+---+---+---+---+---+---+ This table above represent all possible combinations of explicit cast from type (row) to another type (column). Numbering of types might look confusing (it's not sequential) but the order is what we see in the consistency specification RFC, and we should live with that. Values are actual enum values from the code. Unfortunately, changing of order is almost impossible because of massive rework for the spec it would require. How to interpret this table, e.g.: - for the explicit cast from `BOOLEAN` (6) to `BOOLEAN` (6) we should always allow cast (and make it noop), thus intersection is `Y` (yes); - `STRING` (2) to `BOOLEAN` (6) may work sometimes (if string represents TRUE or FALSE literals), but may fail otherwise, thus there is `S` (sometimes); - We have prohibited majority of ther directions for `BOOLEAN` thus there are `-` (minus) in such cells, i.e. `BOOLEAN` (6) to `INTEGER` (5); - Untouched entries in the table marked with '.'. Assumption is - we already have correct conversion rule here activated well before; - Worth to mention that empty cell means that this conversion direction is prohibited. For obvious reasons those chnaged conversion rules made us modify expected results for many tests - they are fixed. But to cover all possible conversion combinations (minus those, not yet implemented in SQL types like DECIMAL, ARRAY and MAP) we have created special test which check _all combinations of CASTs()_ and verifies results against table rules defined in the RFC. There is e_casts.test.lua created for that purpose. Implicit table ============== Similarly to explicit conversion rules we have update implicit conversion rules, and this is 2nd part of patchset. We will not draw changed values of implicit conversion table (please see it's final state in the consistemcy types RFC), but verbally we have modified following directions of conversions: - string to/from double - double to/from integer - varbinary to/from string In addition to modifciation of all relevant test results, we have also extended e_casts.test.lua introduced above for checking of all possible directions of implicit conversions. Approach to check it though is different than for explicit cast, we do not use simple expression with implicit cast activated (like we might be using `CAST()` for explicit casts), but rather we insert value of original type into columns of expected target type. Relates to #5910, #6009 Closes #4470 Bonus - better error reporting in tap tests =========================================== Also, during debugging of explicit/implicitit conversions test it was discovered the harder way, that TAP infrastructure does not report correctly origin source line of and error, but rather report :0 line as location. This has been fixed. Closes #6134 Timur Safin (3): test: corrected reported error lines sql: updated explicit conversion table sql: updated implicit conversion table extra/mkkeywordhash.c | 3 +- src/box/sql/mem.c | 188 +++-------- src/box/sql/mem.h | 6 - src/box/sql/parse.y | 9 +- src/box/sql/util.c | 3 +- src/box/sql/vdbe.c | 8 +- src/box/sql/vdbeaux.c | 2 +- src/lua/tap.lua | 2 +- test/sql-tap/cse.test.lua | 12 +- test/sql-tap/e_casts.test.lua | 474 +++++++++++++++++++++++++++ test/sql-tap/e_select1.test.lua | 2 +- test/sql-tap/in1.test.lua | 8 +- test/sql-tap/in4.test.lua | 19 +- test/sql-tap/misc3.test.lua | 2 +- test/sql-tap/numcast.test.lua | 2 +- test/sql-tap/tkt-9a8b09f8e6.test.lua | 40 +-- test/sql/boolean.result | 38 +-- test/sql/types.result | 132 ++++---- 18 files changed, 654 insertions(+), 296 deletions(-) create mode 100755 test/sql-tap/e_casts.test.lua -- 2.29.2