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 56C1F6D3F5; Mon, 25 Oct 2021 11:51:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 56C1F6D3F5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635151917; bh=Mu4+gHzcd8utmsfhKEl6pdRUQbg7Q8FGFs7V24JCeTs=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=tOjjOLmMT2FG+HbVLzX4Ur2WPbwgPFg1JVegKB3ibvrSrX4hxml7YNihlS9lzfnn+ L9qBSH6y2NkEncBGhn9GOWpLxk8jxZOaaevVU5b2AZ1FgvQtGYRAI/grweJcI+rag7 r3YX7wbRoIgVIIyIQSiolmnWaQxXkwkXoLOz51cw= 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 66CD16D3F5 for ; Mon, 25 Oct 2021 11:51:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 66CD16D3F5 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mevhy-0001Kh-JL; Mon, 25 Oct 2021 11:51:55 +0300 Date: Mon, 25 Oct 2021 11:51:53 +0300 To: v.shpilevoy@tarantool.org, tarantool-patches@dev.tarantool.org Message-ID: <20211025085153.GL36295@tarantool.org> References: <431c5ea816ff1264a0672d54e25fb2a8a22a6c20.1633713432.git.imeevma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <431c5ea816ff1264a0672d54e25fb2a8a22a6c20.1633713432.git.imeevma@gmail.com> X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9C7814344C8C501C8A4649CC2A06649B6A97F49A0BDC630D4182A05F5380850401EEAE37B13518343D59FE2828B6F7BE73CB76BF0BA9D8987B43F622B4BED84AE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7BF6699A3AA9BACA6EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637486F32EF78EC606F8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D82D610A2FB53F743A5A4C06295E0B5B9F117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B62CFFCC7B69C47339089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A560F4EC8CF931B2CA9F118D8FD825B16F9D596AB2F8D30B78D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75FA7FF33AA1A4D21C410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346AD04FDA812EEFF127898168BD098E8607969086CF99FB513F9C122D8C9A2FF15065FEA17E83AC4F1D7E09C32AA3244C1D625CC01B6AA94B85FD22B3D80ACC2124AF4FAF06DA24FD729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojPL6H901iH3HO9aFnZlt0Ng== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DEFDE222726727EF96B1D9AACD3E7CC9083D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 18/21] sql: remove unused code 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" Thank you for the review! I removed sql/utf.c module, dropped one unused field of struct Vdbe and removed unused prototype. Diff below. On Fri, Oct 08, 2021 at 08:32:05PM +0300, Mergen Imeev via Tarantool-patches wrote: Diff: diff --git a/src/box/CMakeLists.txt b/src/box/CMakeLists.txt index a6de36c66..e578461ef 100644 --- a/src/box/CMakeLists.txt +++ b/src/box/CMakeLists.txt @@ -55,7 +55,6 @@ set(sql_sources sql/tokenize.c sql/treeview.c sql/trigger.c - sql/utf.c sql/update.c sql/util.c sql/vdbe.c diff --git a/src/box/sql/mem.h b/src/box/sql/mem.h index 294441e5c..9533833f2 100644 --- a/src/box/sql/mem.h +++ b/src/box/sql/mem.h @@ -823,13 +823,6 @@ mem_len_unsafe(const struct Mem *mem) return len; } -/** - * Return address of memory allocated for accumulation structure of the - * aggregate function. - */ -int -mem_get_agg(const struct Mem *mem, void **accum); - /** * Simple type to str convertor. It is used to simplify * error reporting. diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 2bbf281ee..22a4aa5cd 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -3652,26 +3652,6 @@ void sqlDetach(Parse *, Expr *); int sqlAtoF(const char *z, double *, int); int sqlGetInt32(const char *, int *); -/** - * Return number of symbols in the given string. - * - * Number of symbols != byte size of string because some symbols - * are encoded with more than one byte. Also note that all - * symbols from 'str' to 'str + byte_len' would be counted, - * even if there is a '\0' somewhere between them. - * - * This function is implemented to be fast and indifferent to - * correctness of string being processed. If input string has - * even one invalid utf-8 sequence, then the resulting length - * could be arbitary in these boundaries (0 < len < byte_len). - * @param str String to be counted. - * @param byte_len Byte length of given string. - * @return number of symbols in the given string. - */ -int -sql_utf8_char_count(const unsigned char *str, int byte_len); - -u32 sqlUtf8Read(const u8 **); LogEst sqlLogEst(u64); LogEst sqlLogEstAdd(LogEst, LogEst); u64 sqlLogEstToInt(LogEst); diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c index 7c983fea5..fbd159126 100644 --- a/src/box/sql/trigger.c +++ b/src/box/sql/trigger.c @@ -805,11 +805,8 @@ sql_row_trigger_program(struct Parse *parser, struct sql_trigger *trigger, if (!parser->is_aborted) parser->is_aborted = pSubParse->is_aborted; - if (db->mallocFailed == 0) { - pProgram->aOp = - sqlVdbeTakeOpArray(v, &pProgram->nOp, - &pTop->nMaxArg); - } + if (db->mallocFailed == 0) + pProgram->aOp = sqlVdbeTakeOpArray(v, &pProgram->nOp); pProgram->nMem = pSubParse->nMem; pProgram->nCsr = pSubParse->nTab; pProgram->token = (void *)trigger; diff --git a/src/box/sql/utf.c b/src/box/sql/utf.c deleted file mode 100644 index 2d9a12806..000000000 --- a/src/box/sql/utf.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2010-2017, Tarantool AUTHORS, please see AUTHORS file. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * This file contains routines used to translate between UTF-8. - * - * Notes on UTF-8: - * - * Byte-0 Byte-1 Byte-2 Byte-3 Value - * 0xxxxxxx 00000000 00000000 0xxxxxxx - * 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx - * 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx - * 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx 000uuuuu zzzzyyyy yyxxxxxx - * - * - */ -#include "sqlInt.h" - -/* - * This lookup table is used to help decode the first byte of - * a multi-byte UTF8 character. - */ -static const unsigned char sqlUtf8Trans1[] = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x00, 0x00, -}; - -u32 -sqlUtf8Read(const unsigned char **pz /* Pointer to string from which to read char */ - ) -{ - unsigned int c; - - /* Same as READ_UTF8() above but without the zTerm parameter. - * For this routine, we assume the UTF8 string is always zero-terminated. - */ - c = *((*pz)++); - if (c >= 0xc0) { - c = sqlUtf8Trans1[c - 0xc0]; - while ((*(*pz) & 0xc0) == 0x80) { - c = (c << 6) + (0x3f & *((*pz)++)); - } - if (c < 0x80 - || (c & 0xFFFFF800) == 0xD800 - || (c & 0xFFFFFFFE) == 0xFFFE) { - c = 0xFFFD; - } - } - return c; -} - -int -sql_utf8_char_count(const unsigned char *str, int byte_len) -{ - int symbol_count = 0; - for (int i = 0; i < byte_len;) { - SQL_UTF8_FWD_1(str, i, byte_len); - symbol_count++; - } - return symbol_count; -} diff --git a/src/box/sql/vdbe.h b/src/box/sql/vdbe.h index e40a1a0b3..e482926b2 100644 --- a/src/box/sql/vdbe.h +++ b/src/box/sql/vdbe.h @@ -260,7 +260,10 @@ void sqlVdbeCountChanges(Vdbe *); sql *sqlVdbeDb(Vdbe *); void sqlVdbeSetSql(Vdbe *, const char *z, int n); void sqlVdbeSwap(Vdbe *, Vdbe *); -VdbeOp *sqlVdbeTakeOpArray(Vdbe *, int *, int *); + +struct VdbeOp * +sqlVdbeTakeOpArray(struct Vdbe *p, int *pnOp); + sql_value *sqlVdbeGetBoundValue(Vdbe *, int); char *sqlVdbeExpandSql(Vdbe *, const char *); diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index 8dbba4908..c45cc9301 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -262,7 +262,6 @@ struct Vdbe { Op *aOp; /* Space to hold the virtual machine's program */ Mem *aMem; /* The memory locations */ - Mem **apArg; /* Arguments to currently executing user function */ /** SQL metadata for DML/DQL queries. */ struct sql_column_metadata *metadata; Mem *pResultSet; /* Pointer to an array of results */ diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index 3015760e1..f5a84956c 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -447,21 +447,17 @@ sqlVdbeRunOnlyOnce(Vdbe * p) * (1) For each jump instruction with a negative P2 value (a label) * resolve the P2 value to an actual address. * - * (2) Compute the maximum number of arguments used by any SQL function - * and store that value in *pMaxFuncArgs. + * (2) Initialize the p4.xAdvance pointer on opcodes that use it. * - * (3) Initialize the p4.xAdvance pointer on opcodes that use it. - * - * (4) Reclaim the memory allocated for storing labels. + * (3) Reclaim the memory allocated for storing labels. * * This routine will only function correctly if the mkopcodeh.sh generator * script numbers the opcodes correctly. Changes to this routine must be * coordinated with changes to mkopcodeh.sh. */ static void -resolveP2Values(Vdbe * p, int *pMaxFuncArgs) +resolveP2Values(Vdbe * p) { - int nMaxArgs = *pMaxFuncArgs; Op *pOp; Parse *pParse = p->pParse; int *aLabel = pParse->aLabel; @@ -506,7 +502,6 @@ resolveP2Values(Vdbe * p, int *pMaxFuncArgs) sqlDbFree(p->db, pParse->aLabel); pParse->aLabel = 0; pParse->nLabel = 0; - *pMaxFuncArgs = nMaxArgs; } /* @@ -526,17 +521,15 @@ sqlVdbeCurrentAddr(Vdbe * p) * vdbeFreeOpArray() function. * * Before returning, *pnOp is set to the number of entries in the returned - * array. Also, *pnMaxArg is set to the larger of its current value and - * the number of entries in the Vdbe.apArg[] array required to execute the - * returned program. + * array. */ -VdbeOp * -sqlVdbeTakeOpArray(Vdbe * p, int *pnOp, int *pnMaxArg) +struct VdbeOp * +sqlVdbeTakeOpArray(struct Vdbe *p, int *pnOp) { VdbeOp *aOp = p->aOp; assert(aOp && !p->db->mallocFailed); - resolveP2Values(p, pnMaxArg); + resolveP2Values(p); *pnOp = p->nOp; p->aOp = 0; return aOp; @@ -1485,7 +1478,6 @@ sqlVdbeMakeReady(Vdbe * p, /* The VDBE */ int nVar; /* Number of parameters */ int nMem; /* Number of VM memory registers */ int nCursor; /* Number of cursors required */ - int nArg; /* Number of arguments in subprograms */ int n; /* Loop counter */ struct ReusableSpace x; /* Reusable bulk memory */ @@ -1499,7 +1491,6 @@ sqlVdbeMakeReady(Vdbe * p, /* The VDBE */ nVar = pParse->nVar; nMem = pParse->nMem; nCursor = pParse->nTab; - nArg = pParse->nMaxArg; /* Each cursor uses a memory cell. The first cursor (cursor 0) can * use aMem[0] which is not otherwise used by the VDBE program. Allocate @@ -1521,7 +1512,7 @@ sqlVdbeMakeReady(Vdbe * p, /* The VDBE */ assert(x.nFree >= 0); assert(EIGHT_BYTE_ALIGNMENT(&x.pSpace[x.nFree])); - resolveP2Values(p, &nArg); + resolveP2Values(p); if (pParse->explain && nMem < 10) { nMem = 10; } @@ -1541,7 +1532,6 @@ sqlVdbeMakeReady(Vdbe * p, /* The VDBE */ x.nNeeded = 0; p->aMem = allocSpace(&x, p->aMem, nMem * sizeof(Mem)); p->aVar = allocSpace(&x, p->aVar, nVar * sizeof(Mem)); - p->apArg = allocSpace(&x, p->apArg, nArg * sizeof(Mem *)); p->apCsr = allocSpace(&x, p->apCsr, nCursor * sizeof(VdbeCursor *)); if (x.nNeeded == 0)