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 18F7E6E454; Thu, 10 Feb 2022 12:14:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 18F7E6E454 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1644484483; bh=G/bmGyNkIjnwIgLsukz4pRywvWYkA/gzKISIMhV9Z4I=; 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=L7grNbiO4wXL9mpVUZEAIJofo3IK6dMwb4TYdbr9dbpIKUthkvlZlmT/kZpoyeP9S J6CJv2BA3aZ7GZSv1Vj+4oq+D7SFPue9JZI6Kr9yIAhaTUpyHrQ8J7fFTm5HDl/b98 lV6uehjQxy8nf7MdRYm5xBUgcQZ0y4tnD4Ml5ShA= Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (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 14BD66E21E for ; Thu, 10 Feb 2022 12:14:13 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 14BD66E21E Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1nI5Wm-000345-8k; Thu, 10 Feb 2022 12:14:12 +0300 To: kyukhin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Thu, 10 Feb 2022 12:14:11 +0300 Message-Id: <21d56df830408195f6198307d066f3ddf2c5f692.1644484227.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-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9B74B50284A7C1A0BFDE482DFFE866438B6B3FD87C0A8FE49182A05F538085040A467ED01983F94679DD01E409F1A9EDB3CA70D02B9A8E4BBB2BA9606C3AB72AC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AEADB70076298E75EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637EA9DEEAA3ECF8E948638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8560BC7E4971E5F90FC64ACD22DA69B3D117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B2EE5AD8F952D28FBA471835C12D1D977C4224003CC836476EB9C4185024447017B076A6E789B0E975F5C1EE8F4F765FC1B9A51E5331CA6D33AA81AA40904B5D9CF19DD082D7633A078D18283394535A93AA81AA40904B5D98AA50765F79006373E673A9EC8A2C7C8D81D268191BDAD3D698AB9A7B718F8C4D1B931868CE1C5781A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B262FEC7FBD7D1F5BB5C8C57E37DE458BEDA766A37F9254B7 X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C05348A8C7D563C42A9BD8B205114C5BED056EB9971D4276C9C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EF4A2C4B6BA9DFC510699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3451BBE684D17D72219F920DDF952CA7FCC285525FC9016A0C4E18281D729DE7207399E169366C66E41D7E09C32AA3244C42EEA98EE2E15B257CC8F2BF061EF4DB259227199D06760A729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojptAT+HCMDqMYIK43BMteqA== X-Mailru-Sender: 5C3750E245F362008BC1685FEC6306ED80956B8FD049B7199DD01E409F1A9EDB1AB5AE572836FD895105BD0848736F9966FEC6BF5C9C28D97E07721503EA2E00ED97202A5A4E92BF72D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 1/4] sql: fix COUNT() optimization conditions 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 fixes the conditions under which COUNT() is optimized. At some point, the conditions were broken, but since there was no other aggregate function requiring zero arguments, this problem did not change the behavior. Needed for #2579 --- src/box/sql/select.c | 2 +- src/box/sql/sqlInt.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/box/sql/select.c b/src/box/sql/select.c index 55aaff87f..b532cac4e 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -4650,7 +4650,7 @@ is_simple_count(struct Select *select, struct AggInfo *agg_info) return NULL; assert(agg_info->aFunc->func->def->language == FUNC_LANGUAGE_SQL_BUILTIN); - if (sql_func_flag_is_set(agg_info->aFunc->func, SQL_FUNC_COUNT) || + if (strcmp(agg_info->aFunc->func->def->name, "COUNT") != 0 || (agg_info->aFunc->pExpr->x.pList != NULL && agg_info->aFunc->pExpr->x.pList->nExpr > 0)) return NULL; diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 0db16b293..f49522dc8 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -1117,8 +1117,6 @@ struct type_def { */ #define SQL_FUNC_LENGTH 0x0040 /* Built-in length() function */ #define SQL_FUNC_TYPEOF 0x0080 /* Built-in typeof() function */ -/** Built-in count() function. */ -#define SQL_FUNC_COUNT 0x0100 #define SQL_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */ #define SQL_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */ /** Built-in min() or least() function. */ -- 2.25.1