From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 24CFC2D5B7 for ; Fri, 12 Oct 2018 07:19:16 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KSE4lpDy8L4Y for ; Fri, 12 Oct 2018 07:19:16 -0400 (EDT) Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [94.100.177.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id D8D6D2D5B6 for ; Fri, 12 Oct 2018 07:19:15 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [tarantool-patches] Re: [PATCH 6/6] sql: discard numeric conversion by unary plus From: "n.pettik" In-Reply-To: <050a58c0-759e-28d2-5389-e7bad74826f6@tarantool.org> Date: Fri, 12 Oct 2018 14:19:13 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <050a58c0-759e-28d2-5389-e7bad74826f6@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Vladislav Shpilevoy > On 27 Sep 2018, at 23:24, Vladislav Shpilevoy = wrote: >=20 > See 1 comment below. >=20 > On 17/09/2018 23:32, Nikita Pettik wrote: >> In SQLite unary plus behaves as implicit conversion to numeric type. >> Consider following example: >> CREATE TABLE t1 (id INT PRIMARY KEY, a TEXT, b BLOB); >> INSERT INTO t1 VALUES (1, '99', '99'); >> SELECT * FROM t1 WHERE a =3D b; (*) >> SELECT * FROM t1 WHERE +a =3D +b; (**) >> Since BLOB and TEXT are incompatible, result of (*) would be empty = set. >> However, comparison in second query (**) would be of types, >> and result set would consist of one tuple [1, '99', '99']. >> Lets discard this conversion produced by unary plus, since it = implicitly >> affects result set of query and no one other DB support such = behaviour. >> Instead, simply use type of operand it is related to. >=20 > So unary minus is ok? Yep, unary minus doesn=E2=80=99t affect types. You can check it modifying example from commit message: CREATE TABLE t1 (id INT PRIMARY KEY, a TEXT, b BLOB); INSERT INTO t1 VALUES (1, '99', '99'); SELECT * FROM t1 WHERE a =3D b; SELECT * FROM t1 WHERE -a =3D -b; Result is the same. Also, for the sake of clarity, added note to commit message concerning this case: ... Lets discard this conversion produced by unary plus, since it = implicitly affects result set of query and no one other DB support such = behaviour. Instead, simply use type of operand it is related to. Note, that unary minus doesn't affect types in any way.=