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 18EB62A7FC for ; Thu, 21 Mar 2019 10:46:55 -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 49Xn_kbgZEEN for ; Thu, 21 Mar 2019 10:46:54 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 C37532A7F6 for ; Thu, 21 Mar 2019 10:46:54 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 2/2] sql: don't change type of function's retval after codegen References: <9a7a2794d68a949b801a3210231a35562fcf8847.1552327461.git.korablev@tarantool.org> <72283387-1BD8-420F-BBF7-8B516ADC1675@tarantool.org> From: Vladislav Shpilevoy Message-ID: <6f9d3175-4b2a-af07-79ad-e017e33fce09@tarantool.org> Date: Thu, 21 Mar 2019 17:46:51 +0300 MIME-Version: 1.0 In-Reply-To: <72283387-1BD8-420F-BBF7-8B516ADC1675@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Language: en-US Content-Transfer-Encoding: 8bit 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, "n.pettik" , Kirill Yukhin On 21/03/2019 15:51, n.pettik wrote: > >> On 11/03/2019 21:10, Nikita Pettik wrote: >>> Proper type of function's returning value is set during names resolution >>> (i.e. promotion from struct FuncDef to struct Expr, see >>> resolveExprStep()). Accidentally, it was set again during byte-code >>> generation for VDBE. What is more, in some cases it was set to a wrong >>> type. For instance, built-in function randomblob() returns value to be >>> encoded as MP_BIN, so its returning type is SCALAR. However, it was >>> reset to INTEGER (as its first argument). This patch simply removes this >>> second type promotion. >>> --- >>> src/box/sql/expr.c | 11 ----------- >>> test/sql/iproto.result | 41 +++++++++++++++++++++++++++++++++++++++++ >>> test/sql/iproto.test.lua | 15 +++++++++++++++ >>> 3 files changed, 56 insertions(+), 11 deletions(-) >>> diff --git a/test/sql/iproto.result b/test/sql/iproto.result >>> index 3a77c8e93..26d55b60c 100644 >>> --- a/test/sql/iproto.result >>> +++ b/test/sql/iproto.result >>> +-- Type set during compilation stage, and since min/max are accept >>> +-- arguments of all scalar type, we can't say nothing more than >>> +-- SCALAR. >>> +-- >>> +cn:execute("SELECT min(1, 2, 3);") >>> +--- >>> +- metadata: >>> + - name: min(1, 2, 3) >>> + type: scalar >> >> This is the case, when a first argument type would be ok. As I >> understand, it is illegal to calculate min of multiple different >> types, so its rettype should be equal to its first argument. It >> is not? > > Unfortunately, it is legal: > > tarantool> SELECT min('abc', 1); > --- > - - [1] > … > > It is to be resolved in scope of this issue: > https://github.com/tarantool/tarantool/issues/4032 > > Thanks for the patchset and the explanations! As I see, Kostja is ok with your type name changes. Technically the patch LGTM.