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 D821E6E1C9; Thu, 11 Nov 2021 13:55:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D821E6E1C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1636628137; bh=xXt8KOgHDnrv/cauMbgD8MHpZwzJbsr0uKBAUxNkzZ0=; 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=NXt10xcSi1YyrEInFqus7jN9dKZNFnjTdMtYRWEJSLMl1yjrgUEzvOEUr/Qxwbz5U 7TXyVXvZoEO339YV/EpWrGJPKExJ6Tqao0Okm0d0fLVGtg8yk52TxkbjBBR4TK+O7D 14ZNKbmJ6eXzIhl9+Dm94CQVlxXL5oXaNgafiBJk= 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 9BDB76E1C9 for ; Thu, 11 Nov 2021 13:49:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9BDB76E1C9 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1ml7dl-00052u-Ni; Thu, 11 Nov 2021 13:49:10 +0300 To: kyukhin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Thu, 11 Nov 2021 13:49:09 +0300 Message-Id: <6bc58f8b8e007cfc4efd17dd71ff1495eecd4b3c.1636627579.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: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9731B3922EC063979EC8F5BB1F79852547911E65F5173D5CB00894C459B0CD1B951A3F40DC75074C2AE92B19838CA8ACEBD7B9CED87D255677A0345C203294F53 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE763424119D34F5CBFEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637CD8995A08F41566CEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F26A4A2B20A1B87BD0A45AAEFF671E6F5FCC7F00164DA146DAFE8445B8C89999728AA50765F790063783E00425F71A4181389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8A9FF340AA05FB58CF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8BDC0F6C5B2EEF3D0C75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C7E9FEBB9C11794A16CC32B0CEEE2351CB4B7D10E01863BB89C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFCDE59DDCCE53AF2B699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D347215713CF3EEE9D1CF08A8437BC66973A45CA96A5948CB386359887C6D9A40108B13181A8BA261421D7E09C32AA3244C7045848DF25040785622F0C0993693AD39C99C45E8D137E9729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj4t8MBgWr8bLEg6hNAEORQw== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D7986AC4491E83A8C790E30EE2006C4B083D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 11/21] sql: refactor ROW_COUNT() function 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" Part of #4145 --- src/box/sql/func.c | 12 +++++++++++- src/box/sql/main.c | 10 ---------- src/box/sql/sqlInt.h | 8 +------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index c5428d87b..014fd9af2 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -988,6 +988,16 @@ func_round(struct sql_context *ctx, int argc, struct Mem *argv) return mem_set_double(res, (double)(int64_t)(d + delta)); } +/** Implementation of the ROW_COUNT() function. */ +static void +func_row_count(struct sql_context *ctx, int argc, struct Mem *argv) +{ + (void)argc; + (void)argv; + assert(sql_get()->nChange >= 0); + return mem_set_uint(ctx->pOut, sql_get()->nChange); +} + static const unsigned char * mem_as_ustr(struct Mem *mem) { @@ -1869,7 +1879,7 @@ static struct sql_func_definition definitions[] = { {"ROUND", 1, {FIELD_TYPE_DOUBLE}, FIELD_TYPE_DOUBLE, func_round, NULL}, {"ROUND", 2, {FIELD_TYPE_DOUBLE, FIELD_TYPE_INTEGER}, FIELD_TYPE_DOUBLE, func_round, NULL}, - {"ROW_COUNT", 0, {}, FIELD_TYPE_INTEGER, sql_row_count, NULL}, + {"ROW_COUNT", 0, {}, FIELD_TYPE_INTEGER, func_row_count, NULL}, {"SOUNDEX", 1, {FIELD_TYPE_STRING}, FIELD_TYPE_STRING, soundexFunc, NULL}, {"SUBSTR", 2, {FIELD_TYPE_STRING, FIELD_TYPE_INTEGER}, diff --git a/src/box/sql/main.c b/src/box/sql/main.c index a4247c760..ae872aaa1 100644 --- a/src/box/sql/main.c +++ b/src/box/sql/main.c @@ -220,16 +220,6 @@ setupLookaside(sql * db, void *pBuf, int sz, int cnt) return 0; } -void -sql_row_count(struct sql_context *context, int argc, struct Mem *argv) -{ - (void)argc; - (void)argv; - sql *db = sql_context_db_handle(context); - assert(db->nChange >= 0); - sql_result_uint(context, db->nChange); -} - /* * Close all open savepoints. * This procedure is trivial as savepoints are allocated on the "region" and diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 9361775b1..c8f711ed2 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -470,12 +470,6 @@ enum sql_subtype { void sql_randomness(int N, void *P); -/** - * Return the number of affected rows in the last SQL statement. - */ -void -sql_row_count(struct sql_context *context, int argc, struct Mem *argv); - int sql_column_count(sql_stmt * pStmt); @@ -1065,7 +1059,7 @@ struct sql { u8 dfltLockMode; /* Default locking-mode for attached dbs */ u8 mTrace; /* zero or more sql_TRACE flags */ u32 magic; /* Magic number for detect library misuse */ - /** Value returned by sql_row_count(). */ + /** Value returned by ROW_COUNT(). */ int nChange; int aLimit[SQL_N_LIMIT]; /* Limits */ int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */ -- 2.25.1