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 5EF276EC40; Thu, 19 Aug 2021 08:33:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5EF276EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1629351222; bh=pxjdE1gnNOIp2+tdAI/KlcSdrUlyVGVLC/2OhCIcn0Y=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=A0mgVS4rT+VckTAmaG62SgxyZwyhB1fxbZP0a6YadVmjVILGn3mRnb6WWg8svSTxV tR9g2OzqJmqo3+axbg6sWDseGX966qb5OcEnpa5jW3HEFV6/4m9uyNrtUAb/hUkH08 4z9MZUTBMMYIWm6keNHFRxN3vqoesv1DKjrDsFqs= 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 004AE6EC5B for ; Thu, 19 Aug 2021 08:31:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 004AE6EC5B Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1mGaeK-0000BF-6h; Thu, 19 Aug 2021 08:31:32 +0300 To: vdavydov@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Thu, 19 Aug 2021 08:31:32 +0300 Message-Id: <5f7df02aac30a94723228d805df47d31541925f0.1629350815.git.imeevma@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9ECFD080E047A606F56291F8739A291D6182A05F5380850401EFF07254287D5BEA81D295B46078C103A798C471E3C802D47068EB3C1E92C7B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79AF9A4DE526B45BBEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637CDB0FA248422B0DF8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8ABA4993876ACEB210782ABE7FE9F0E44117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6300D3B61E77C8D3B089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CF160826E4E1956AEB22A29C8DE81608BFFD37DF338BE2A979C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF5A3EDA775A1E0ED0699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349379E7F8541B6C9A65AB2134B8CD9ABD463A2512D832B34CD0381E4E04456A4E2D3B1572DF3297F71D7E09C32AA3244C00BA4BC453AA872095933AF505D52826C86C126E7119A0FE729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojGSxK+6r6oBHXUMHDFAIPDw== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D22CCFC2354CA89520BDEFAA51CCC82DB83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 4/5] sql: do not use struct func for finalization 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: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch removes struct func from finalization of SQL built-in aggregate functions. Part of #6105 --- src/box/sql/func.c | 30 ++++++++++++++++++++++++++---- src/box/sql/vdbe.c | 2 +- src/box/sql/vdbe.h | 2 ++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index adbc6d5a4..e09224bb8 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -3008,9 +3008,31 @@ int sql_emit_func_finalize(struct Vdbe *vdbe, struct Expr *expr, int reg, uint8_t argc) { - struct func *func = sql_func_find(expr); - if (func == NULL) - return -1; - sqlVdbeAddOp4(vdbe, OP_AggFinal, reg, argc, 0, (char *)func, P4_FUNC); + void (*finalize)(sql_context *ctx); + switch(expr->func_id) { + case TK_AVG: + finalize = avgFinalize; + break; + case TK_SUM: + finalize = sumFinalize; + break; + case TK_COUNT: + finalize = countFinalize; + break; + case TK_TOTAL: + finalize = totalFinalize; + break; + case TK_GROUP_CONCAT: + finalize = groupConcatFinalize; + break; + case TK_MAX: + case TK_MIN: + finalize = minMaxFinalize; + break; + default: + unreachable(); + } + sqlVdbeAddOp4(vdbe, OP_AggFinal, reg, argc, 0, (char *)finalize, + P4_STATIC); return 0; } diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index c63dbaa5a..f821ac98a 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -4221,7 +4221,7 @@ case OP_AggFinal: { mem_create(&t); ctx.pOut = &t; ctx.pMem = pMem; - ((struct func_sql_builtin *)pOp->p4.func)->finalize(&ctx); + pOp->p4.finalize(&ctx); if (ctx.is_aborted) goto abort_due_to_error; assert((pMem->flags & MEM_Dyn) == 0); diff --git a/src/box/sql/vdbe.h b/src/box/sql/vdbe.h index e40a1a0b3..1f6e566e1 100644 --- a/src/box/sql/vdbe.h +++ b/src/box/sql/vdbe.h @@ -97,6 +97,8 @@ struct VdbeOp { * Information about ephemeral space field types and key parts. */ struct sql_space_info *space_info; + /* Finalize method for SQL built-in aggregate function. */ + void (*finalize)(sql_context *ctx); } p4; #ifdef SQL_ENABLE_EXPLAIN_COMMENTS char *zComment; /* Comment to improve readability */ -- 2.25.1