From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rhino.ch-server.com (rhino.ch-server.com [209.59.190.103]) (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 31BA1445320 for ; Wed, 8 Jul 2020 21:58:44 +0300 (MSK) References: <2a8578c7-10f5-fd38-409e-4e996f07b865@tarantool.org> <1924f068-8ec2-ad91-569a-7eeecaad9767@ocelot.ca> <857a0e74-cb78-4b1e-4704-5502b72473f8@tarantool.org> From: Peter Gulutzan Message-ID: <643ea7d2-97f9-a301-3350-999e21afd2d6@ocelot.ca> Date: Wed, 8 Jul 2020 12:58:40 -0600 MIME-Version: 1.0 In-Reply-To: <857a0e74-cb78-4b1e-4704-5502b72473f8@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-US Subject: Re: [Tarantool-discussions] Check implicit cast between strings and numbers List-Id: Tarantool development process List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mergen Imeev , tarantool-discussions@dev.tarantool.org, Nikita Pettik , Vladislav Shpilevoy , tsafin@tarantool.org Hi, On 2020-07-08 10:58 a.m., Mergen Imeev wrote: > Hi, > > Thank you for testing! I added check types of arguments of the > functions, could you look once more? > > There are some functions in which we support both STRING and BLOB > as arguments, for example substr(). Do you think we should leave > them as they are now, or can we change them so that they support > only STRING arguments? I think those functions are SELECT HEX('Г'), HEX(CAST('Г' AS VARBINARY)); SELECT LENGTH('Г'), LENGTH(CAST('Г' AS VARBINARY)); SELECT LOWER('Г'), LOWER(CAST('Г' AS VARBINARY)); SELECT POSITION('1', 'Г1'), POSITION('1', CAST('Г1' AS VARBINARY)); SELECT PRINTF('%s', 'Г'), PRINTF('%s', CAST('Г' AS VARBINARY)); SELECT QUOTE('Г'), QUOTE(CAST('Г' AS VARBINARY)); SELECT REPLACE('1Г1','1','2'), REPLACE(CAST('1Г1' AS VARBINARY),'1','2'); SELECT SOUNDEX('Г'), SOUNDEX(CAST('Г' AS VARBINARY)); SELECT SUBSTR('1Г1',2,1), SUBSTR(CAST('1Г1' AS VARBINARY),2,1); SELECT TRIM(TRAILING '1' FROM '1Г1'), TRIM(TRAILING '1' FROM CAST('1Г1' AS VARBINARY)); SELECT UNICODE('Г'), UNICODE(CAST('Г' AS VARBINARY)); SELECT UPPER('Г'), UPPER(CAST('Г' AS VARBINARY)); They all work now. I think that is good, we should leave them as they are now. That does not mean they are all perfect, though. Here are complaints, which are not relevant to your question but which we should look at someday. As you can see in the comments on issue#4145 sql: remake string value functions https://github.com/tarantool/tarantool/issues/4145 sometimes functions with multiple parameters can have multiple data types. As you can see from the comments on issue#3929 Length functions for SQL character strings https://github.com/tarantool/tarantool/issues/3929 As you know, I objected to the idea that CHARACTER_LENGTH() should be applied to VARBINARY values, but it was a firm order from Konstantin Osipov. If we accepted that these functions should look for bytes (rather than characters) when the values are VARBINARY, then some of the results would differ. Peter Gulutzan