From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 183F76EC40; Tue, 21 Sep 2021 13:40:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 183F76EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632220858; bh=n8nIOw0VnDTxjofm/rB5DKIFtqB8vcP5hUDR7MilOQY=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=LVmDWOsFsLERPT4fnReqmMmDI6S+GD2uQHOYnQ4qN9HtohcORZyYlB35pHlSRPGt3 kaZ/DIEeUgkDiguGIj1s/mrJBR4dVSV1zi6+0FqyOcK7zMZVjuJtf/RC5h1x9OsD07 nVvvpuj/ayBz6VZtvhkXREAaPx4k8MtE9ysRUk+Y= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [94.100.179.3]) (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 867556EC40 for ; Tue, 21 Sep 2021 13:40:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 867556EC40 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1mSdCp-0002US-Lk; Tue, 21 Sep 2021 13:40:56 +0300 Date: Tue, 21 Sep 2021 13:40:54 +0300 To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Message-ID: <20210921104054.GA16139@tarantool.org> References: <610b38cc1f01a80faf25a194d157cc3987f28f83.1631289462.git.imeevma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91AE02D33A9C88A2F6A36F53BB3AD52253F2DCAAB31849A6F00894C459B0CD1B9963EC0050D39D8880685DAEB2203EDFC403D704AB44BB88F8E7CFC23E8784A43 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79CBBCC7DE3A5D56AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637BBCE7257090F96C9EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F2FFF3695DB1F8453AAC2B86E9C2A7CE17CC7F00164DA146DAFE8445B8C89999728AA50765F7900637CAEE156C82D3D7D9389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8A9FF340AA05FB58CF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B953A8A48A05D51F175ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A563DBBF89CDAF00B8BD966BEC14FBAD41257E3B531181FB38D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75DD5744CF7ED0C6846D6546786ADF492D5A0AA20F8A030721AEF7A422EC9C267145C972DC301F7D148E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340D3A19269BBEBAAFF20E633254D5F7D2CEC474AEA0842025FD0BA8B2DCCD16248830A0531B47737D1D7E09C32AA3244CD7CC98FA3F43567C87F1B3553FBC36B2259227199D06760A729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnvI84oHUDXCl0ziOTAI+rA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D694A71A4E70A1661B086CDAC52D85EC583D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 03/13] sql: move collation to struct sql_context X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thank you for the review! My answers below. On Tue, Sep 14, 2021 at 11:22:39PM +0200, Vladislav Shpilevoy wrote: > Thanks for working on this! > > On 10.09.2021 18:01, imeevma@tarantool.org wrote: > > This patch makes it easier to get a collation by a function. > > You could also store the opcode pointer instead of iOp. But I > suspect your main reason is to get rid of the vdbe pointer? If > yes, then why? > I wanted to remove unnecessary connecton between VDBE and functions. Also, this way it will be easier for me to remove OP_CollSeq. > > diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c > > index 2ff7ce8f4..12dc9126b 100644 > > --- a/src/box/sql/vdbe.c > > +++ b/src/box/sql/vdbe.c > > @@ -1159,23 +1159,13 @@ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ > > break; > > } > > > > -/* Opcode: CollSeq P1 * * P4 > > - * > > - * P4 is a pointer to a CollSeq struct. If the next call to a user function > > - * or aggregate calls sqlGetFuncCollSeq(), this collation sequence will > > - * be returned. This is used by the built-in min(), max() and nullif() > > - * functions. > > +/* Opcode: SkipLoad P1 * * * * > > * > > * If P1 is not zero, then it is a register that a subsequent min() or > > * max() aggregate will set to true if the current row is not the minimum or > > * maximum. The P1 register is initialized to false by this instruction. > > - * > > - * The interface used by the implementation of the aforementioned functions > > - * to retrieve the collation sequence set by this opcode is not available > > - * publicly. Only built-in functions have access to this feature. > > */ > > -case OP_CollSeq: { > > - assert(pOp->p4type==P4_COLLSEQ || pOp->p4.pColl == NULL); > > +case OP_SkipLoad: { > > That is a very strange name. Couldn't OP_Bool somehow be reused? > Why is this R[p1] = false even needed? > It is possible, for example like this: diff --git a/src/box/sql/select.c b/src/box/sql/select.c index 2880f8ea0..c3f36d74f 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -5636,7 +5636,8 @@ updateAccumulator(Parse * pParse, AggInfo * pAggInfo) } if (regHit == 0 && pAggInfo->nAccumulator) regHit = ++pParse->nMem; - sqlVdbeAddOp1(v, OP_SkipLoad, regHit); + if (regHit != 0) + sqlVdbeAddOp2(v, OP_Bool, false, regHit); } struct sql_context *ctx = sql_context_new(pF->func, nArg, coll); if (ctx == NULL) { diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 12dc9126b..b17179a57 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -4182,9 +4182,8 @@ case OP_AggStep: { goto abort_due_to_error; } assert(mem_is_null(&t)); - if (pCtx->skipFlag) { - assert(pOp[-1].opcode == OP_SkipLoad); - i = pOp[-1].p1; + if (pCtx->skipFlag && pOp[-1].opcode == OP_Bool) { + i = pOp[-1].p2; if (i) mem_set_bool(&aMem[i], true); } break; However, I'm not sure if this is the correct way to use OP_Bool. This opcode is used in rather strange queries, such as the following: SELECT a, min(b) FROM t; As you can see, there can be multiple values for min (b) in "a". This behavior is discussed here: https://github.com/tarantool/tarantool/discussions/6416 Most likely, we will follow the same path as PostgreSQL and MS SQL Server, namely to prohibit such expressions. This will naturally lead to removal of OP_SkipLoad/OP_CollSeq. As for the name - I though of it when read desctiption of skipFlag field in struct sql_context. > > if (pOp->p1) { > > mem_set_bool(&aMem[pOp->p1], false); > > }