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 038142056F for ; Mon, 15 Jul 2019 09:32:11 -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 9fTyTNBflJ77 for ; Mon, 15 Jul 2019 09:32:10 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 B7FBC1FF37 for ; Mon, 15 Jul 2019 09:32:10 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: Fix UPDATE for types unknown to SQL. From: "n.pettik" In-Reply-To: <09286d9d-870b-f5dd-f328-56d374173160@tarantool.org> Date: Mon, 15 Jul 2019 16:32:08 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <598DA602-A524-48B9-8D15-78E67A61852B@tarantool.org> References: <132ca83597d0e9c2b4ef75bc8f0d03d22cdf27dd.1561736006.git.imeevma@gmail.com> <20190708101336.GA10686@tarantool.org> <09286d9d-870b-f5dd-f328-56d374173160@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: Imeev Mergen > On 9 Jul 2019, at 12:14, Imeev Mergen wrote: >=20 > Hi! Thank you for review. My answer below. >=20 > On 7/8/19 4:32 PM, n.pettik wrote: >>=20 >>> Diff: >>>=20 >>> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c >>> index f8cf1af..79232de 100644 >>> --- a/src/box/sql/vdbe.c >>> +++ b/src/box/sql/vdbe.c >>> @@ -351,19 +351,22 @@ mem_apply_type(struct Mem *record, enum = field_type type) >>> return 0; >>> case FIELD_TYPE_SCALAR: >>> /* Can't cast MAP and ARRAY to scalar types. */ >>> - if (record->subtype =3D=3D SQL_SUBTYPE_MSGPACK) { >>> + if ((record->flags & MEM_Blob) =3D=3D MEM_Blob && >>=20 >> Why do you need this additional check on MEM_Blob? >> Is it possible that memory holds raw msgpack and its >> type not blob? If so, please provide an example. >>=20 > I'm not sure what you describe is possible. But it is impossible > to say what type MEM has when you look at the SUBTYPE. At the same > time, the subtype has any meaning only for BLOBs. Any other type > has any SUBTYPE, and it is not checked anywhere. So, to avoid an > error, when something, for example INT, throws an error when > casting to SCALAR, I added these checks. Ok, but then I guess more appropriate solution would be checking MEM_Subtype flag, instead of MEM_Blob Anyway, I would add clear test which reaches this path and record->flags !=3D MEM_Blob, but ->subtype =3D=3D msgpack.