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 F0B086F867; Fri, 4 Feb 2022 02:29:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F0B086F867 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1643930998; bh=jsbKjnWjGV3iGhsc5rMlslMXexf0A5QeiZt8avLMWQ4=; 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=jpVj+5OP+txlPq3jucoMmKCz0hGNj+zWghVNeMBpsgR6ZRdVY2u1O5VjLXW2RXKGl +bYdDZ8D00Z5Fl4mw29uTpUHVBTjnz3w6JYN3/LXT/ow27WU+UhBhQSHzt7U5zjYmE Q4Qt2d328FKft4QmQzS9qKQlXUVg97T416TCM2eQ= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 589416F867 for ; Fri, 4 Feb 2022 02:29:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 589416F867 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1nFlY4-0004M0-J8; Fri, 04 Feb 2022 02:29:56 +0300 Message-ID: <08ca2f7e-77fd-d4ce-fb87-e0c1b07e29cd@tarantool.org> Date: Fri, 4 Feb 2022 00:29:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Content-Language: en-US To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <344a9ef9b7eca47ae257d0ea944866d27ff589e6.1643722506.git.imeevma@gmail.com> In-Reply-To: <344a9ef9b7eca47ae257d0ea944866d27ff589e6.1643722506.git.imeevma@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9C2F57BB0C041E51F2280071BFB1F8BEE5985854889F4AE7E00894C459B0CD1B93C850E9DA7E6E72EBE8F48AE0013927039958708B6BFFA703B45A48541D55DDE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72E0BB8D059315229EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D3A9DC970DD6E2F6EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BEBC5CAB6D411FFA6F2CEBF8658E9456D4FF51D647C12B3D4CC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BDAE3FA6833AEA0C275ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: 0D63561A33F958A5BEE038B98A7622D55C2343E2DC38DE296C5914BFE9215AA7D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75BF6B963DD989C0FC410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34FACF503ACC83041B456327EE93E203BF2A4A17129434E0472DCD458F387AC3824FBFA68578CD8E8B1D7E09C32AA3244C7B316CB76103BC9D63B6B6EFD2C411393C6EB905E3A8056B729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojR8wit7+bEcdpY6vcXk2+AA== X-Mailru-Sender: 689FA8AB762F739339CABD9B3CA9A7D6BD6A8ED2BE579BF6F44CE6D649BE01CA3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E25FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 3/4] sql: introduce custom aggregate functions 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the patch! See 3 comments below. After you done with them, send to a next reviewer right away. > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index b69bf7fd6..cda872194 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -2060,9 +2060,12 @@ sql_func_find(struct Expr *expr) > return NULL; > } > int n = expr->x.pList != NULL ? expr->x.pList->nExpr : 0; > - if (func->def->param_count != n) { > + int argc = func->def->aggregate == FUNC_AGGREGATE_GROUP ? > + func->def->param_count - 1 : func->def->param_count; 1. Why -1 for aggregates? I see it is somehow related to the last argument being used for state, but it looks intricate. A comment here would be enough. > + assert(argc >= 0); > + if (argc != n) { > diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT, name, > - tt_sprintf("%d", func->def->param_count), n); > + tt_sprintf("%d", argc), n); > return NULL; > } > return func;> diff --git a/test/sql-tap/gh-2579-custom-aggregate.test.lua b/test/sql-tap/gh-2579-custom-aggregate.test.lua > new file mode 100755 > index 000000000..213e2e870 > --- /dev/null > +++ b/test/sql-tap/gh-2579-custom-aggregate.test.lua > @@ -0,0 +1,113 @@ > +#!/usr/bin/env tarantool > +local build_path = os.getenv("BUILDDIR") > +package.cpath = build_path..'/test/sql-tap/?.so;'..build_path..'/test/sql-tap/?.dylib;'..package.cpath 2. Lets split it at 80th line column. > + > +local test = require("sqltester") > +test:plan(5) > + > +test:execsql([[ > + CREATE TABLE t (i INT PRIMARY KEY); > + INSERT INTO t VALUES(1), (2), (3), (4), (5); > + ]]) 3. You probably forgot to left shift the expression for one tab.