From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [94.100.177.92]) (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 997BB430412 for ; Fri, 21 Aug 2020 12:21:31 +0300 (MSK) Date: Fri, 21 Aug 2020 09:21:30 +0000 From: Nikita Pettik Message-ID: <20200821092130.GC6452@tarantool.org> References: <56f685097fb1120e36bf03114a32d567e668a2a2.1597998754.git.imeevma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <56f685097fb1120e36bf03114a32d567e668a2a2.1597998754.git.imeevma@gmail.com> Subject: Re: [Tarantool-patches] [PATCH v1 2/2] sql: remove implicit cast in bitwise operations List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org On 21 Aug 11:40, imeevma@tarantool.org wrote: > This patch removes the implicit conversion from STRING to INTEGER from > bitwise operations. However, DOUBLE can still be implicitly converted to > INTEGER. I see no test involving doubles in bitwise operations. Does it make any sense at all? > Follow-up #3809 > --- > src/box/sql/vdbe.c | 59 ++++++++++++++++++++++++++++++++--------- > test/sql/types.result | 49 ++++++++++++++++++++++++++++++++++ > test/sql/types.test.lua | 14 ++++++++++ > 3 files changed, 110 insertions(+), 12 deletions(-) > > diff --git a/test/sql/types.result b/test/sql/types.result > index caedbf409..601e5beca 100644 > --- a/test/sql/types.result > +++ b/test/sql/types.result > @@ -2846,3 +2846,52 @@ box.execute([[SELECT 1 - '2';]]) > - null > - 'Type mismatch: can not convert 2 to numeric' > ... > +-- > +-- Make sure there is no implicit string-to-number conversion in bitwise > +-- operations. > +-- > +box.execute([[SELECT '1' | 2;]]) > +--- > +- null > +- 'Type mismatch: can not convert 1 to integer' > +... > +box.execute([[SELECT '1' & 2;]]) > +--- > +- null > +- 'Type mismatch: can not convert 1 to integer' > +... > +box.execute([[SELECT '1' << 2;]]) > +--- > +- null > +- 'Type mismatch: can not convert 1 to integer' > +... > +box.execute([[SELECT '1' >> 2;]]) > +--- > +- null > +- 'Type mismatch: can not convert 1 to integer' > +... > +box.execute([[SELECT ~'1';]]) > +--- > +- null > +- 'Type mismatch: can not convert 1 to integer' > +... > +box.execute([[SELECT 1 | '2';]]) > +--- > +- null > +- 'Type mismatch: can not convert 2 to integer' > +... > +box.execute([[SELECT 1 & '2';]]) > +--- > +- null > +- 'Type mismatch: can not convert 2 to integer' > +... > +box.execute([[SELECT 1 << '2';]]) > +--- > +- null > +- 'Type mismatch: can not convert 2 to integer' > +... > +box.execute([[SELECT 1 >> '2';]]) > +--- > +- null > +- 'Type mismatch: can not convert 2 to integer' > +... > diff --git a/test/sql/types.test.lua b/test/sql/types.test.lua > index 844a6b670..2d2f41da2 100644 > --- a/test/sql/types.test.lua > +++ b/test/sql/types.test.lua > @@ -638,3 +638,17 @@ box.execute([[SELECT 1 % '2';]]) > box.execute([[SELECT 1 * '2';]]) > box.execute([[SELECT 1 / '2';]]) > box.execute([[SELECT 1 - '2';]]) > + > +-- > +-- Make sure there is no implicit string-to-number conversion in bitwise > +-- operations. > +-- > +box.execute([[SELECT '1' | 2;]]) > +box.execute([[SELECT '1' & 2;]]) > +box.execute([[SELECT '1' << 2;]]) > +box.execute([[SELECT '1' >> 2;]]) > +box.execute([[SELECT ~'1';]]) > +box.execute([[SELECT 1 | '2';]]) > +box.execute([[SELECT 1 & '2';]]) > +box.execute([[SELECT 1 << '2';]]) > +box.execute([[SELECT 1 >> '2';]]) > -- > 2.25.1 >